Esempio n. 1
0
 def test_inactive_save(self):
     """ Test that form creates inactive user """
     form = SignupForm()
     form.cleaned_data = {'password1': 'password'}
     with patch.object(form, 'send_email'):
         user = form.save()
         self.assertFalse(user.is_active)
Esempio n. 2
0
 def test_save_commit(self):
     """ Test that form creates inactive user """
     form = SignupForm()
     form.cleaned_data = {'password1': 'password'}
     with patch.object(form, 'send_email'):
         user = form.save(False)
         self.assertTrue(user.id is None)
Esempio n. 3
0
 def test_email_send(self):
     user = model_factory(User, email=get_fake_email(), save=True)
     form = SignupForm()
     form.instance = user
     email_meth = Mock()
     with patch('salest.core.models.EmailTemplate.send', email_meth):
         form.send_email()
         self.assertEqual(email_meth.call_count, 1)
         confirm_exists = UserConfirmation.objects.filter(
                                                     user=user).exists()
         self.assertTrue(confirm_exists)