Added tests for d21f3d9b17.

This commit is contained in:
Florian Apolloner 2012-09-17 21:50:13 +02:00
parent d21f3d9b17
commit 06f79354d0
1 changed files with 17 additions and 2 deletions

View File

@ -1,6 +1,8 @@
from django.test import TestCase
from django.test.utils import override_settings
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
@override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
@ -47,3 +49,16 @@ class SignalTestCase(TestCase):
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)