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.2 KiB

9 years ago
9 years ago
9 years ago
  1. from django.contrib.auth.models import User
  2. from django.test import TestCase
  3. from hc.api.models import Channel
  4. class AddChannelTestCase(TestCase):
  5. def setUp(self):
  6. self.alice = User(username="alice")
  7. self.alice.set_password("password")
  8. self.alice.save()
  9. def test_it_works(self):
  10. url = "/integrations/add/"
  11. form = {"kind": "email", "value": "[email protected]"}
  12. self.client.login(username="alice", password="password")
  13. r = self.client.post(url, form)
  14. assert r.status_code == 302
  15. assert Channel.objects.count() == 1
  16. def test_it_rejects_bad_kind(self):
  17. url = "/integrations/add/"
  18. form = {"kind": "dog", "value": "Lassie"}
  19. self.client.login(username="alice", password="password")
  20. r = self.client.post(url, form)
  21. assert r.status_code == 400, r.status_code
  22. def test_instructions_work(self):
  23. self.client.login(username="alice", password="password")
  24. for frag in ("email", "webhook", "pd", "slack", "hipchat"):
  25. url = "/integrations/add_%s/" % frag
  26. r = self.client.get(url)
  27. self.assertContains(r, "Integration Settings", status_code=200)