Opened 17 years ago

Last modified 17 years ago

#5979 closed

Django tests fail if SITE_ID is not 1. — at Initial Version

Reported by: Todd O'Bryan Owned by: nobody
Component: Testing framework Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The following tests fail if the SITE_ID is set to 2, for example. They work fine if it's 1.

======================================================================
ERROR: Request a logout after logging in


Traceback (most recent call last):

File "/home/tobryan1/workspace/django/tests/modeltests/test_client/models.py", line 315, in test_logout

self.assertRedirects(response, 'http://testserver/accounts/login/?next=/test_client/login_protected_view/')

File "/usr/lib/python2.5/site-packages/django/test/testcases.py", line 98, in assertRedirects

redirect_response = response.client.get(path, QueryDict(query))

File "/usr/lib/python2.5/site-packages/django/test/client.py", line 219, in get

return self.request(r)

File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 81, in get_response

response = callback(request, *callback_args, callback_kwargs)

File "/usr/lib/python2.5/site-packages/django/contrib/auth/views.py", line 32, in login

current_site = Site.objects.get_current()

File "/usr/lib/python2.5/site-packages/django/contrib/sites/models.py", line 22, in get_current

current_site = self.get(pk=sid)

File "/usr/lib/python2.5/site-packages/django/db/models/manager.py", line 69, in get

return self.get_query_set().get(*args, kwargs)

File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 263, in get

raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name

DoesNotExist: Site matching query does not exist.

======================================================================
ERROR: Request a page that is protected with @login_required


Traceback (most recent call last):

File "/home/tobryan1/workspace/django/tests/modeltests/test_client/models.py", line 245, in test_view_with_login

self.assertRedirects(response, 'http://testserver/accounts/login/?next=/test_client/login_protected_view/')

File "/usr/lib/python2.5/site-packages/django/test/testcases.py", line 98, in assertRedirects

redirect_response = response.client.get(path, QueryDict(query))

File "/usr/lib/python2.5/site-packages/django/test/client.py", line 219, in get

return self.request(r)

File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 81, in get_response

response = callback(request, *callback_args, callback_kwargs)

File "/usr/lib/python2.5/site-packages/django/contrib/auth/views.py", line 32, in login

current_site = Site.objects.get_current()

File "/usr/lib/python2.5/site-packages/django/contrib/sites/models.py", line 22, in get_current

current_site = self.get(pk=sid)

File "/usr/lib/python2.5/site-packages/django/db/models/manager.py", line 69, in get

return self.get_query_set().get(*args, kwargs)

File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 263, in get

raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name

DoesNotExist: Site matching query does not exist.

======================================================================
ERROR: Request a page that is protected with @login_required(redirect_field_name='redirect_to')


Traceback (most recent call last):

File "/home/tobryan1/workspace/django/tests/modeltests/test_client/models.py", line 277, in test_view_with_login_and_custom_redirect

self.assertRedirects(response, 'http://testserver/accounts/login/?redirect_to=/test_client/login_protected_view_custom_redirect/')

File "/usr/lib/python2.5/site-packages/django/test/testcases.py", line 98, in assertRedirects

redirect_response = response.client.get(path, QueryDict(query))

File "/usr/lib/python2.5/site-packages/django/test/client.py", line 219, in get

return self.request(r)

File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 81, in get_response

response = callback(request, *callback_args, callback_kwargs)

File "/usr/lib/python2.5/site-packages/django/contrib/auth/views.py", line 32, in login

current_site = Site.objects.get_current()

File "/usr/lib/python2.5/site-packages/django/contrib/sites/models.py", line 22, in get_current

current_site = self.get(pk=sid)

File "/usr/lib/python2.5/site-packages/django/db/models/manager.py", line 69, in get

return self.get_query_set().get(*args, kwargs)

File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 263, in get

raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name

DoesNotExist: Site matching query does not exist.

======================================================================
ERROR: Request a page that is protected with a @login_required method


Traceback (most recent call last):

File "/home/tobryan1/workspace/django/tests/modeltests/test_client/models.py", line 261, in test_view_with_method_login

self.assertRedirects(response, 'http://testserver/accounts/login/?next=/test_client/login_protected_method_view/')

File "/usr/lib/python2.5/site-packages/django/test/testcases.py", line 98, in assertRedirects

redirect_response = response.client.get(path, QueryDict(query))

File "/usr/lib/python2.5/site-packages/django/test/client.py", line 219, in get

return self.request(r)

File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 81, in get_response

response = callback(request, *callback_args, callback_kwargs)

File "/usr/lib/python2.5/site-packages/django/contrib/auth/views.py", line 32, in login

current_site = Site.objects.get_current()

File "/usr/lib/python2.5/site-packages/django/contrib/sites/models.py", line 22, in get_current

current_site = self.get(pk=sid)

File "/usr/lib/python2.5/site-packages/django/db/models/manager.py", line 69, in get

return self.get_query_set().get(*args, kwargs)

File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 263, in get

raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name

DoesNotExist: Site matching query does not exist.

======================================================================
ERROR: Request a page that is protected with a @permission_required method


Traceback (most recent call last):

File "/home/tobryan1/workspace/django/tests/modeltests/test_client/models.py", line 339, in test_view_with_method_permissions

self.assertRedirects(response, 'http://testserver/accounts/login/?next=/test_client/permission_protected_method_view/')

File "/usr/lib/python2.5/site-packages/django/test/testcases.py", line 98, in assertRedirects

redirect_response = response.client.get(path, QueryDict(query))

File "/usr/lib/python2.5/site-packages/django/test/client.py", line 219, in get

return self.request(r)

File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 81, in get_response

response = callback(request, *callback_args, callback_kwargs)

File "/usr/lib/python2.5/site-packages/django/contrib/auth/views.py", line 32, in login

current_site = Site.objects.get_current()

File "/usr/lib/python2.5/site-packages/django/contrib/sites/models.py", line 22, in get_current

current_site = self.get(pk=sid)

File "/usr/lib/python2.5/site-packages/django/db/models/manager.py", line 69, in get

return self.get_query_set().get(*args, kwargs)

File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 263, in get

raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name

DoesNotExist: Site matching query does not exist.

======================================================================
ERROR: Request a page that is protected with @permission_required


Traceback (most recent call last):

File "/home/tobryan1/workspace/django/tests/modeltests/test_client/models.py", line 322, in test_view_with_permissions

self.assertRedirects(response, 'http://testserver/accounts/login/?next=/test_client/permission_protected_view/')

File "/usr/lib/python2.5/site-packages/django/test/testcases.py", line 98, in assertRedirects

redirect_response = response.client.get(path, QueryDict(query))

File "/usr/lib/python2.5/site-packages/django/test/client.py", line 219, in get

return self.request(r)

File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 81, in get_response

response = callback(request, *callback_args, callback_kwargs)

File "/usr/lib/python2.5/site-packages/django/contrib/auth/views.py", line 32, in login

current_site = Site.objects.get_current()

File "/usr/lib/python2.5/site-packages/django/contrib/sites/models.py", line 22, in get_current

current_site = self.get(pk=sid)

File "/usr/lib/python2.5/site-packages/django/db/models/manager.py", line 69, in get

return self.get_query_set().get(*args, kwargs)

File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 263, in get

raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name

DoesNotExist: Site matching query does not exist.


Ran 214 tests in 245.089s

FAILED (errors=6)

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top