def test_view(self): """ Test signup view process """ model_factory(EmailTemplate, template_key="invitation_email", save=True) resp = self.app.get(reverse("accounts:signup")) form = resp.form form["username"] = "******" form["password1"] = "password" form["password2"] = "password" form["email"] = get_fake_email() response = form.submit() self.assertEqual(response.status, "302 FOUND")
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)