Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added tests for d21f3d9.

  • Loading branch information...
commit 06f79354d009b9fe10149bf597c1570569e7d348 1 parent d21f3d9
@apollo13 apollo13 authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 django/contrib/auth/tests/signals.py
View
17 django/contrib/auth/tests/signals.py
@@ -1,6 +1,8 @@
+from django.contrib.auth import signals
+from django.contrib.auth.models import User
from django.test import TestCase
+from django.test.client import RequestFactory
from django.test.utils import override_settings
-from django.contrib.auth import signals
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
@@ -47,3 +49,16 @@ def test_logout(self):
self.client.get('/logout/next_page/')
self.assertEqual(len(self.logged_out), 1)
self.assertEqual(self.logged_out[0].username, 'testclient')
+
+ def test_update_last_login(self):
+ """Ensure that only `last_login` is updated in `update_last_login`"""
+ user = User.objects.get(pk=3)
+ old_last_login = user.last_login
+
+ user.username = "This username shouldn't get saved"
+ request = RequestFactory().get('/login')
+ signals.user_logged_in.send(sender=user.__class__, request=request,
+ user=user)
+ user = User.objects.get(pk=3)
+ self.assertEqual(user.username, 'staff')
+ self.assertNotEqual(user.last_login, old_last_login)
Please sign in to comment.
Something went wrong with that request. Please try again.