diff --git a/basetheme_bootstrap/tests.py b/basetheme_bootstrap/tests.py index f1752c0b7c184ef5bca024c001f3fe94b46ec386..ba8fb89f1823ccf52e21bb30f17b7abc80e1c3f5 100644 --- a/basetheme_bootstrap/tests.py +++ b/basetheme_bootstrap/tests.py @@ -200,6 +200,7 @@ class SignUpWithValidationTests(TestCase): self.assertEqual(len(m), 1) def test_activate_too_late_with_user_pending_resend_email(self): + get_user_model().objects.create(username="toto") actual_account_activation_token = tokens.account_activation_token class MockedTokenGenerator(tokens.TokenGenerator): @@ -253,6 +254,24 @@ class TestWithTemplatesInPlace(SignUpTests): os.remove(t) +@override_settings( + BASETHEME_BOOTSTRAP_VALIDATE_EMAIL_BEFORE_ACTIVATION=True, +) +class SuperuserSignUpTests(TestCase): + def test_sign_up_for_superuser(self): + #even with BASETHEME_BOOTSTRAP_VALIDATE_EMAIL_BEFORE_ACTIVATION to True first user must be super and active + response = self.client.post(reverse('basetheme_bootstrap:signup'), { + 'username': "userAAA", + 'email': "bryan.brancotte@pasteur.fr", + 'password1': "user@mp.comuser@mp.comuser@mp.comuser@mp.com", + 'password2': "user@mp.comuser@mp.comuser@mp.comuser@mp.com", + 'first_name': "user" + }) + self.assertEqual(response.status_code, 302) + self.assertTrue(get_user_model().objects.get(username="userAAA").is_superuser) + self.assertTrue(get_user_model().objects.get(username="userAAA").is_active) + + class SuperuserSignUpTests(TestCase): def setUp(self):