diff options
| author | django-bot <ops@djangoproject.com> | 2022-02-03 20:24:19 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-07 20:37:05 +0100 |
| commit | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch) | |
| tree | f0506b668a013d0063e5fba3dbf4863b466713ba /tests/auth_tests/test_handlers.py | |
| parent | f68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff) | |
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/auth_tests/test_handlers.py')
| -rw-r--r-- | tests/auth_tests/test_handlers.py | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/auth_tests/test_handlers.py b/tests/auth_tests/test_handlers.py index 57a43f877f..a6b53a9ef1 100644 --- a/tests/auth_tests/test_handlers.py +++ b/tests/auth_tests/test_handlers.py @@ -1,6 +1,4 @@ -from django.contrib.auth.handlers.modwsgi import ( - check_password, groups_for_user, -) +from django.contrib.auth.handlers.modwsgi import check_password, groups_for_user from django.contrib.auth.models import Group, User from django.test import TransactionTestCase, override_settings @@ -15,9 +13,9 @@ class ModWsgiHandlerTestCase(TransactionTestCase): """ available_apps = [ - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'auth_tests', + "django.contrib.auth", + "django.contrib.contenttypes", + "auth_tests", ] def test_check_password(self): @@ -25,51 +23,53 @@ class ModWsgiHandlerTestCase(TransactionTestCase): check_password() returns the correct values as per https://modwsgi.readthedocs.io/en/develop/user-guides/access-control-mechanisms.html#apache-authentication-provider """ - User.objects.create_user('test', 'test@example.com', 'test') + User.objects.create_user("test", "test@example.com", "test") # User not in database - self.assertIsNone(check_password({}, 'unknown', '')) + self.assertIsNone(check_password({}, "unknown", "")) # Valid user with correct password - self.assertTrue(check_password({}, 'test', 'test')) + self.assertTrue(check_password({}, "test", "test")) # correct password, but user is inactive - User.objects.filter(username='test').update(is_active=False) - self.assertFalse(check_password({}, 'test', 'test')) + User.objects.filter(username="test").update(is_active=False) + self.assertFalse(check_password({}, "test", "test")) # Valid user with incorrect password - self.assertFalse(check_password({}, 'test', 'incorrect')) + self.assertFalse(check_password({}, "test", "incorrect")) - @override_settings(AUTH_USER_MODEL='auth_tests.CustomUser') + @override_settings(AUTH_USER_MODEL="auth_tests.CustomUser") def test_check_password_custom_user(self): """ check_password() returns the correct values as per https://modwsgi.readthedocs.io/en/develop/user-guides/access-control-mechanisms.html#apache-authentication-provider with a custom user installed. """ - CustomUser._default_manager.create_user('test@example.com', '1990-01-01', 'test') + CustomUser._default_manager.create_user( + "test@example.com", "1990-01-01", "test" + ) # User not in database - self.assertIsNone(check_password({}, 'unknown', '')) + self.assertIsNone(check_password({}, "unknown", "")) # Valid user with correct password' - self.assertTrue(check_password({}, 'test@example.com', 'test')) + self.assertTrue(check_password({}, "test@example.com", "test")) # Valid user with incorrect password - self.assertFalse(check_password({}, 'test@example.com', 'incorrect')) + self.assertFalse(check_password({}, "test@example.com", "incorrect")) def test_groups_for_user(self): """ groups_for_user() returns correct values as per https://modwsgi.readthedocs.io/en/develop/user-guides/access-control-mechanisms.html#apache-group-authorisation """ - user1 = User.objects.create_user('test', 'test@example.com', 'test') - User.objects.create_user('test1', 'test1@example.com', 'test1') - group = Group.objects.create(name='test_group') + user1 = User.objects.create_user("test", "test@example.com", "test") + User.objects.create_user("test1", "test1@example.com", "test1") + group = Group.objects.create(name="test_group") user1.groups.add(group) # User not in database - self.assertEqual(groups_for_user({}, 'unknown'), []) + self.assertEqual(groups_for_user({}, "unknown"), []) - self.assertEqual(groups_for_user({}, 'test'), [b'test_group']) - self.assertEqual(groups_for_user({}, 'test1'), []) + self.assertEqual(groups_for_user({}, "test"), [b"test_group"]) + self.assertEqual(groups_for_user({}, "test1"), []) |
