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.

38 lines
1.3 KiB

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class AddHipChatTestCase(BaseTestCase):
  4. url = "/integrations/add_hipchat/"
  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, "appropriate HipChat room")
  9. def test_it_works(self):
  10. form = {"value": "http://example.org"}
  11. self.client.login(username="[email protected]", password="password")
  12. r = self.client.post(self.url, form)
  13. self.assertRedirects(r, "/integrations/")
  14. c = Channel.objects.get()
  15. self.assertEqual(c.kind, "hipchat")
  16. self.assertEqual(c.value, "http://example.org")
  17. def test_it_rejects_bad_url(self):
  18. form = {"value": "not an URL"}
  19. self.client.login(username="[email protected]", password="password")
  20. r = self.client.post(self.url, form)
  21. self.assertContains(r, "Enter a valid URL")
  22. def test_it_trims_whitespace(self):
  23. form = {"value": " http://example.org "}
  24. self.client.login(username="[email protected]", password="password")
  25. self.client.post(self.url, form)
  26. c = Channel.objects.get()
  27. self.assertEqual(c.value, "http://example.org")