summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auth_tests/test_management.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py
index 575975fd90..8cd7b378c0 100644
--- a/tests/auth_tests/test_management.py
+++ b/tests/auth_tests/test_management.py
@@ -505,6 +505,32 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
test(self)
+ @override_settings(AUTH_USER_MODEL='auth_tests.CustomUserWithFK')
+ def test_fields_with_fk_via_option_interactive(self):
+ new_io = StringIO()
+ group = Group.objects.create(name='mygroup')
+ email = Email.objects.create(email='mymail@gmail.com')
+
+ @mock_inputs({'password': 'nopasswd'})
+ def test(self):
+ call_command(
+ 'createsuperuser',
+ interactive=True,
+ username=email.pk,
+ email=email.email,
+ group=group.pk,
+ stdout=new_io,
+ stdin=MockTTY(),
+ )
+
+ command_output = new_io.getvalue().strip()
+ self.assertEqual(command_output, 'Superuser created successfully.')
+ u = CustomUserWithFK._default_manager.get(email=email)
+ self.assertEqual(u.username, email)
+ self.assertEqual(u.group, group)
+
+ test(self)
+
@override_settings(AUTH_USER_MODEL='auth_tests.CustomUserWithM2m')
def test_fields_with_m2m(self):
new_io = StringIO()