Ticket #4526: tests.py

File tests.py, 659 bytes (added by marcin@…, 16 years ago)
Line 
1from django.test import TestCase
2from django.contrib.auth.models import User
3
4class LoginTestCase(TestCase):
5    def test_login(self):
6        """
7        Check the behavior of client.login.
8        """
9       
10        user = User.objects.create_user('marcink', 'mk@somewhere', 'mk')
11        user.is_active = True
12        user.save()
13
14        self.assert_(self.client.login(username='marcink', password='mk'))
15
16        user.is_active = False
17        user.save()
18
19        # this is where the bug appears.  The expected behavior is for
20        # the login method to fail.
21        self.assert_(not self.client.login(username='marcink', password='mk'))
22       
Back to Top