Example #1
0
 def test_no_email(self, requests_mock):
     requests_mock.return_value = FakeResponse(200, "ok")
     no_email_request = self.request.post(reverse("subscribe"))
     no_email_response = ajax_subscribe(no_email_request)
     self.assertEqual(no_email_response.status_code, 200)
     self.assertContains(no_email_response, "Failed")
     self.assertFalse(requests_mock.called)
Example #2
0
 def test_no_email(self, requests_mock):
     requests_mock.return_value = FakeResponse(200, "ok")
     no_email_request = self.request.post(reverse("subscribe"))
     no_email_response = ajax_subscribe(no_email_request)
     self.assertEqual(no_email_response.status_code, 200)
     self.assertContains(no_email_response, "Failed")
     self.assertFalse(requests_mock.called)
Example #3
0
 def test_valid_email(self, requests_mock):
     requests_mock.return_value = FakeResponse(200, "ok")
     valid_email = "*****@*****.**"
     valid_email_request = self.request.post(reverse("subscribe"),
                                             {"email": valid_email})
     valid_email_response = ajax_subscribe(valid_email_request)
     self.assertEqual(valid_email_response.status_code, 200)
     self.assertContains(valid_email_response, "OK")
     self.assertTrue(requests_mock.called)
Example #4
0
 def test_valid_email(self, requests_mock):
     requests_mock.return_value = FakeResponse(200, "ok")
     valid_email = "*****@*****.**"
     valid_email_request = self.request.post(reverse("subscribe"),
         {"email": valid_email})
     valid_email_response = ajax_subscribe(valid_email_request)
     self.assertEqual(valid_email_response.status_code, 200)
     self.assertContains(valid_email_response, "OK")
     self.assertTrue(requests_mock.called)
Example #5
0
 def test_email_fail(self, requests_mock):
     requests_mock.return_value = MagicMock(status_code=200,
                                            json={'error': "wrong_code"})
     response = ajax_subscribe(self.request)
     self.assertContains(response, 'Failed')
Example #6
0
 def test_email_ok(self, requests_mock):
     requests_mock.return_value = FakeResponse(200, "ok")
     response = ajax_subscribe(self.request)
     self.assertContains(response, 'OK')
Example #7
0
 def test_email_fail(self, requests_mock):
     requests_mock.return_value = MagicMock(status_code=200, json={
         'error': "wrong_code"
     })
     response = ajax_subscribe(self.request)
     self.assertContains(response, 'Failed')
Example #8
0
 def test_email_ok(self, requests_mock):
     requests_mock.return_value = FakeResponse(200, "ok")
     response = ajax_subscribe(self.request)
     self.assertContains(response, 'OK')