Code

Ticket #12103: 12103_tests.diff

File 12103_tests.diff, 779 bytes (added by lasko, 4 years ago)

Tests associated to the patch. Unfortunately I did this with doctests. I intend to write this into a unittest but this should suffice for now.

Line 
1Index: django/contrib/auth/tests/forms.py
2===================================================================
3--- django/contrib/auth/tests/forms.py
4+++ django/contrib/auth/tests/forms.py
5@@ -105,6 +105,24 @@ False
6 >>> user.is_active = True
7 >>> user.save()
8 
9+# The user is inactive but allowed to login
10+
11+>>> data = {
12+...     'username': 'jsmith',
13+...     'password': 'test123',
14+... }
15+>>> user.is_active = False
16+>>> user.save()
17+>>> class AuthenticationFormWithInactiveUsersOkay(AuthenticationForm):
18+...     def confirm_login_allowed(self, user):
19+...         pass
20+>>> form = AuthenticationFormWithInactiveUsersOkay(None, data)
21+>>> form.is_valid()
22+True
23+
24+>>> user.is_active = True
25+>>> user.save()
26+
27 # The success case
28 
29 >>> form = AuthenticationForm(None, data)