|
|
@ -37,11 +37,11 @@ class AddSmsTestCase(BaseTestCase): |
|
|
|
self.assertEqual(c.project, self.project) |
|
|
|
|
|
|
|
def test_it_rejects_bad_number(self): |
|
|
|
form = {"value": "not a phone number address"} |
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
r = self.client.post(self.url, form) |
|
|
|
self.assertContains(r, "Invalid phone number format.") |
|
|
|
for v in ["not a phone number address", False, 15, "+123456789A"]: |
|
|
|
form = {"value": v} |
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
r = self.client.post(self.url, form) |
|
|
|
self.assertContains(r, "Invalid phone number format.") |
|
|
|
|
|
|
|
def test_it_trims_whitespace(self): |
|
|
|
form = {"value": " +1234567890 "} |
|
|
@ -65,3 +65,13 @@ class AddSmsTestCase(BaseTestCase): |
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
r = self.client.get(self.url) |
|
|
|
self.assertEqual(r.status_code, 403) |
|
|
|
|
|
|
|
def test_it_strips_invisible_formatting_characters(self): |
|
|
|
form = {"label": "My Phone", "value": "\u202c+1234567890\u202c"} |
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
r = self.client.post(self.url, form) |
|
|
|
self.assertRedirects(r, self.channels_url) |
|
|
|
|
|
|
|
c = Channel.objects.get() |
|
|
|
self.assertEqual(c.phone_number, "+1234567890") |