- changed status to open
interaction with localeurl
When using django-oauth-plus in conjunction with localeur, it seems that all Client.get(...) requests need to be parametrized with follow=True.
This works to a point, but fails when requesting user authorization. This issue is documented in more detail here: http://stackoverflow.com/questions/6584856/django-oauth-plus-tutorial-error-no-module-named-views
Not really sure if this is a bug in the code, as I'm still learning django, and have only worked through the oauth-plus tutorial once.
Comments (9)
-
David Larlet
-
bborowin
-
assigned issue to
David Larlet
David,
I changed settings.py to use the mysql db engine instead of postgresql (tests failed to launch otherwise):
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'oauthprovider', 'USER': 'oauthprovider', 'PASSWORD': 'oauthprovider', 'HOST': '', 'PORT': '', } }I've also updated urls.py (didn't work out of the box with Django 1.3):
#(r'^admin/(.*)', admin.site.root), (r'^admin/(.*)', include(admin.site.urls)),
When I run tests, this is the first failure I get (followed by tons more):
File "/usr/local/lib/python2.6/dist-packages/django_oauth_plus-2.0-py2.6.egg/oauth_provider/tests.py", line 298, in oauth_provider.tests Failed example: response = c.get("/oauth/authorize/", parameters) Exception raised: Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/django/test/_doctest.py", line 1267, in __run compileflags, 1) in test.globs File "<doctest oauth_provider.tests[50]>", line 1, in <module> response = c.get("/oauth/authorize/", parameters) File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 445, in get response = super(Client, self).get(path, data=data, **extra) File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 229, in get return self.request(**r) File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "/usr/local/lib/python2.6/dist-packages/django_oauth_plus-2.0-py2.6.egg/oauth_provider/views.py", line 94, in user_authorization authorize_view = get_callable(authorize_view_str) File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 124, in wrapper result = func(*args) File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py", line 91, in get_callable lookup_view = getattr(import_module(mod_name), func_name) File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module __import__(name) ImportError: No module named views -
assigned issue to
-
David Larlet
Did you change/set your OAUTH_AUTHORIZE_VIEW (and OAUTH_CALLBACK_VIEW) settings?
You need to define which views will be called when the authorization page is reached (or in case of a callback). By default it's 'oauth_provider.views.fake_authorize_view' but it's recommended to provide your own.
-
bborowin
Yes, I have this line at the bottom of my settings.py:
OAUTH_AUTHORIZE_VIEW = 'django-oauth-plus-example.views.oauth_authorize'
I didn't have the callback view specified, but after adding it, the tests still fail.
-
bborowin
- attached test.out
Attached is the complete test output. I'm running Python 2.6.6 and Django 1.3rc
EDIT: Wrong test.out file, sorry.
-
bborowin
- attached test.out
Here's the actual test output file!
-
bborowin
- attached test.out
Sorry, I shouldn't have posted anything until I have had my morning coffee :-) Please disregard comments 5 and 6..
The tests pass, with the modifications in settings and urls as described in comment 2
When I add
'localeurl.middleware.LocaleURLMiddleware',
at the end of the MiddlewareClasses section, the tests start to fail:
FAIL: tests (oauth_provider) Doctest: oauth_provider.tests ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/django/test/_doctest.py", line 2180, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for oauth_provider.tests File "/home/bartek/SAT/django-oauth-plus/examples/provider/../../oauth_provider/tests.py", line 0, in tests ---------------------------------------------------------------------- File "/home/bartek/SAT/django-oauth-plus/examples/provider/../../oauth_provider/tests.py", line 196, in oauth_provider.tests Failed example: response.status_code Expected: 401 Got: 301 ---------------------------------------------------------------------- File "/home/bartek/SAT/django-oauth-plus/examples/provider/../../oauth_provider/tests.py", line 199, in oauth_provider.tests Failed example: response._headers['www-authenticate'] Exception raised: Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/django/test/_doctest.py", line 1267, in __run compileflags, 1) in test.globs File "<doctest oauth_provider.tests[13]>", line 1, in <module> response._headers['www-authenticate'] KeyError: 'www-authenticate' ----------------------------------------------------------------------etc, etc. Attached is the full test output.
It seems that localeurl introduces a redirect with each request, but django-oauth-plus doesn't follow it automatically?
This is the original issue I've had, and I attempted to work around it by adding *, follow=True* to each .get(...) request, when working through the tutorial.
-
David Larlet
- changed status to invalid
Hi,
If localeurl introduces a redirection, you'll have to explicitly add a follow=True to the test client because by default it just stop on each redirect to be able to test the redirection in itself.
I close the bug as invalid given that it's a normal Django behavior.
Thanks, David
-
bborowin
Agreed, this is beyond the scope of this project. Blame my lack of django-fu :-)
- Log in to comment »
Hello,
I updated the documentation on the wiki page, can you tell me if there is still an issue with your import? Is it possible that you paste your entire history before getting the error? Are you able to launch tests successfully?
Thanks, David