diff options
| author | Dohyeon Kim <nero.union12@gmail.com> | 2018-05-29 21:41:32 +0900 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-05-29 08:41:32 -0400 |
| commit | f1f4aeb22e7bc9b504f69f7cb111ac9bdedb5f1e (patch) | |
| tree | 4b0c8903036892d209f444b2a384f2fa41abc647 /tests/auth_tests/test_management.py | |
| parent | 0914a2003b1ad50f1d641709da86c14826bf063b (diff) | |
Fixed #28044 -- Unified the logic for createsuperuser's interactive and --noinput modes.
Diffstat (limited to 'tests/auth_tests/test_management.py')
| -rw-r--r-- | tests/auth_tests/test_management.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index b3772b1501..4f29740982 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -568,6 +568,22 @@ class CreatesuperuserManagementCommandTestCase(TestCase): test(self) + def test_blank_username_non_interactive(self): + new_io = StringIO() + + def test(self): + with self.assertRaisesMessage(CommandError, 'Username cannot be blank.'): + call_command( + 'createsuperuser', + username='', + interactive=False, + stdin=MockTTY(), + stdout=new_io, + stderr=new_io, + ) + + test(self) + def test_password_validation_bypass(self): """ Password validation can be bypassed by entering 'y' at the prompt. @@ -672,6 +688,19 @@ class CreatesuperuserManagementCommandTestCase(TestCase): test(self) + def test_existing_username_non_interactive(self): + """Creation fails if the username already exists.""" + User.objects.create(username='janet') + new_io = StringIO() + with self.assertRaisesMessage(CommandError, "Error: That username is already taken."): + call_command( + 'createsuperuser', + username='janet', + email='', + interactive=False, + stdout=new_io, + ) + def test_validation_mismatched_passwords(self): """ Creation should fail if the user enters mismatched passwords. |
