Author: russellm
Date: 2007-07-12 10:26:37 -0500 (Thu, 12 Jul 2007)
New Revision: 5677
Modified:
django/trunk/django/test/client.py
django/trunk/tests/modeltests/test_client/fixtures/testdata.json
django/trunk/tests/modeltests/test_client/models.py
Log:
Fixed #4526 -- Modified the test Client login method to fail when a user is
inactive. Thanks, [EMAIL PROTECTED]
Modified: django/trunk/django/test/client.py
===================================================================
--- django/trunk/django/test/client.py 2007-07-12 14:41:32 UTC (rev 5676)
+++ django/trunk/django/test/client.py 2007-07-12 15:26:37 UTC (rev 5677)
@@ -225,10 +225,11 @@
"""Set the Client to appear as if it has sucessfully logged into a
site.
Returns True if login is possible; False if the provided credentials
- are incorrect, or if the Sessions framework is not available.
+ are incorrect, or the user is inactive, or if the Sessions framework is
+ not available.
"""
user = authenticate(**credentials)
- if user and 'django.contrib.sessions' in settings.INSTALLED_APPS:
+ if user and user.is_active and 'django.contrib.sessions' in
settings.INSTALLED_APPS:
obj = Session.objects.get_new_session_object()
# Create a fake request to store login details
Modified: django/trunk/tests/modeltests/test_client/fixtures/testdata.json
===================================================================
--- django/trunk/tests/modeltests/test_client/fixtures/testdata.json
2007-07-12 14:41:32 UTC (rev 5676)
+++ django/trunk/tests/modeltests/test_client/fixtures/testdata.json
2007-07-12 15:26:37 UTC (rev 5677)
@@ -16,5 +16,23 @@
"email": "[EMAIL PROTECTED]",
"date_joined": "2006-12-17 07:03:31"
}
+ },
+ {
+ "pk": "2",
+ "model": "auth.user",
+ "fields": {
+ "username": "inactive",
+ "first_name": "Inactive",
+ "last_name": "User",
+ "is_active": false,
+ "is_superuser": false,
+ "is_staff": false,
+ "last_login": "2006-12-17 07:03:31",
+ "groups": [],
+ "user_permissions": [],
+ "password": "sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161",
+ "email": "[EMAIL PROTECTED]",
+ "date_joined": "2006-12-17 07:03:31"
+ }
}
]
\ No newline at end of file
Modified: django/trunk/tests/modeltests/test_client/models.py
===================================================================
--- django/trunk/tests/modeltests/test_client/models.py 2007-07-12 14:41:32 UTC
(rev 5676)
+++ django/trunk/tests/modeltests/test_client/models.py 2007-07-12 15:26:37 UTC
(rev 5677)
@@ -228,6 +228,12 @@
login = self.client.login(username='otheruser', password='nopassword')
self.failIf(login)
+ def test_view_with_inactive_login(self):
+ "Request a page that is protected with @login, but use an inactive
login"
+
+ login = self.client.login(username='inactive', password='password')
+ self.failIf(login)
+
def test_session_modifying_view(self):
"Request a page that modifies the session"
# Session value isn't set initially
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---