|
|
@ -22,7 +22,7 @@ class NotificationStatusTestCase(BaseTestCase): |
|
|
|
self.url = "/api/v1/notifications/%s/status" % self.n.code |
|
|
|
|
|
|
|
def test_it_handles_twilio_failed_status(self): |
|
|
|
r = self.client.post(self.url, {"MessageStatus": "failed"}) |
|
|
|
r = self.csrf_client.post(self.url, {"MessageStatus": "failed"}) |
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
self.n.refresh_from_db() |
|
|
@ -33,7 +33,7 @@ class NotificationStatusTestCase(BaseTestCase): |
|
|
|
self.assertTrue(self.channel.email_verified) |
|
|
|
|
|
|
|
def test_it_handles_twilio_undelivered_status(self): |
|
|
|
r = self.client.post(self.url, {"MessageStatus": "undelivered"}) |
|
|
|
r = self.csrf_client.post(self.url, {"MessageStatus": "undelivered"}) |
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
self.n.refresh_from_db() |
|
|
@ -43,7 +43,7 @@ class NotificationStatusTestCase(BaseTestCase): |
|
|
|
self.assertIn("status=undelivered", self.channel.last_error) |
|
|
|
|
|
|
|
def test_it_handles_twilio_delivered_status(self): |
|
|
|
r = self.client.post(self.url, {"MessageStatus": "delivered"}) |
|
|
|
r = self.csrf_client.post(self.url, {"MessageStatus": "delivered"}) |
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
self.n.refresh_from_db() |
|
|
@ -56,7 +56,7 @@ class NotificationStatusTestCase(BaseTestCase): |
|
|
|
self.n.created = self.n.created - timedelta(minutes=61) |
|
|
|
self.n.save() |
|
|
|
|
|
|
|
r = self.client.post(self.url, {"MessageStatus": "failed"}) |
|
|
|
r = self.csrf_client.post(self.url, {"MessageStatus": "failed"}) |
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
# The notification should not have the error field set: |
|
|
@ -66,15 +66,15 @@ class NotificationStatusTestCase(BaseTestCase): |
|
|
|
def test_it_handles_missing_notification(self): |
|
|
|
fake_code = "07c2f548-9850-4b27-af5d-6c9dc157ec02" |
|
|
|
url = f"/api/v1/notifications/{fake_code}/status" |
|
|
|
r = self.client.post(url, {"MessageStatus": "failed"}) |
|
|
|
r = self.csrf_client.post(url, {"MessageStatus": "failed"}) |
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
def test_it_requires_post(self): |
|
|
|
r = self.client.get(self.url) |
|
|
|
r = self.csrf_client.get(self.url) |
|
|
|
self.assertEqual(r.status_code, 405) |
|
|
|
|
|
|
|
def test_it_handles_error_key(self): |
|
|
|
r = self.client.post(self.url, {"error": "Something went wrong."}) |
|
|
|
r = self.csrf_client.post(self.url, {"error": "Something went wrong."}) |
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
self.n.refresh_from_db() |
|
|
@ -87,7 +87,7 @@ class NotificationStatusTestCase(BaseTestCase): |
|
|
|
def test_it_handles_mark_not_verified_key(self): |
|
|
|
payload = {"error": "Received complaint.", "mark_not_verified": "1"} |
|
|
|
|
|
|
|
r = self.client.post(self.url, payload) |
|
|
|
r = self.csrf_client.post(self.url, payload) |
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
self.channel.refresh_from_db() |
|
|
@ -95,7 +95,7 @@ class NotificationStatusTestCase(BaseTestCase): |
|
|
|
self.assertFalse(self.channel.email_verified) |
|
|
|
|
|
|
|
def test_it_handles_twilio_call_status_failed(self): |
|
|
|
r = self.client.post(self.url, {"CallStatus": "failed"}) |
|
|
|
r = self.csrf_client.post(self.url, {"CallStatus": "failed"}) |
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
self.n.refresh_from_db() |
|
|
|