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.

42 lines
1.4 KiB

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class AddPdTestCase(BaseTestCase):
  4. def setUp(self):
  5. super(AddPdTestCase, self).setUp()
  6. self.url = "/projects/%s/add_pd/" % self.project.code
  7. def test_instructions_work(self):
  8. self.client.login(username="[email protected]", password="password")
  9. r = self.client.get(self.url)
  10. self.assertContains(r, "Paste the Integration Key down below")
  11. def test_it_works(self):
  12. # Integration key is 32 characters long
  13. form = {"value": "12345678901234567890123456789012"}
  14. self.client.login(username="[email protected]", password="password")
  15. r = self.client.post(self.url, form)
  16. self.assertRedirects(r, self.channels_url)
  17. c = Channel.objects.get()
  18. self.assertEqual(c.kind, "pd")
  19. self.assertEqual(c.value, "12345678901234567890123456789012")
  20. def test_it_trims_whitespace(self):
  21. form = {"value": " 123456 "}
  22. self.client.login(username="[email protected]", password="password")
  23. self.client.post(self.url, form)
  24. c = Channel.objects.get()
  25. self.assertEqual(c.value, "123456")
  26. def test_it_requires_rw_access(self):
  27. self.bobs_membership.rw = False
  28. self.bobs_membership.save()
  29. self.client.login(username="[email protected]", password="password")
  30. r = self.client.get(self.url)
  31. self.assertEqual(r.status_code, 403)