summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2018-06-07 12:59:49 +0430
committerTim Graham <timograham@gmail.com>2018-06-07 19:49:25 -0400
commit6df3d3680167ec84e32fe5994c0cffc1460e4c37 (patch)
treeec4bd322b56bebea4e4b9a2b16365661e57fcefb
parent98e8c0293b96de7dea74817476847c363d9c2496 (diff)
Added a missing test for createsuperuser management command.
-rw-r--r--tests/auth_tests/test_management.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py
index 73cf66699b..da0ec73626 100644
--- a/tests/auth_tests/test_management.py
+++ b/tests/auth_tests/test_management.py
@@ -701,6 +701,34 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
stdout=new_io,
)
+ def test_existing_username_provided_via_option_and_interactive(self):
+ """call_command() gets username='janet' and interactive=True."""
+ new_io = StringIO()
+ entered_passwords = ['password', 'password']
+ User.objects.create(username='janet')
+
+ def return_passwords():
+ return entered_passwords.pop(0)
+
+ @mock_inputs({
+ 'password': return_passwords,
+ 'username': 'janet1',
+ 'email': 'test@test.com'
+ })
+ def test(self):
+ call_command(
+ 'createsuperuser',
+ username='janet',
+ interactive=True,
+ stdin=MockTTY(),
+ stdout=new_io,
+ stderr=new_io,
+ )
+ msg = 'Error: That username is already taken.\nSuperuser created successfully.'
+ self.assertEqual(new_io.getvalue().strip(), msg)
+
+ test(self)
+
def test_validation_mismatched_passwords(self):
"""
Creation should fail if the user enters mismatched passwords.