You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class AddPdTestCase(BaseTestCase):
  4. url = "/integrations/add_pd/"
  5. def test_instructions_work(self):
  6. self.client.login(username="[email protected]", password="password")
  7. r = self.client.get(self.url)
  8. self.assertContains(r, "Paste the Integration Key down below")
  9. def test_it_works(self):
  10. # Integration key is 32 characters long
  11. form = {"value": "12345678901234567890123456789012"}
  12. self.client.login(username="[email protected]", password="password")
  13. r = self.client.post(self.url, form)
  14. self.assertRedirects(r, "/integrations/")
  15. c = Channel.objects.get()
  16. self.assertEqual(c.kind, "pd")
  17. self.assertEqual(c.value, "12345678901234567890123456789012")
  18. def test_it_trims_whitespace(self):
  19. form = {"value": " 123456 "}
  20. self.client.login(username="[email protected]", password="password")
  21. self.client.post(self.url, form)
  22. c = Channel.objects.get()
  23. self.assertEqual(c.value, "123456")