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 AddPagerTreeTestCase(BaseTestCase):
  4. def setUp(self):
  5. super(AddPagerTreeTestCase, self).setUp()
  6. self.url = "/projects/%s/add_pagertree/" % 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, "PagerTree")
  11. def test_it_works(self):
  12. form = {"value": "http://example.org"}
  13. self.client.login(username="[email protected]", password="password")
  14. r = self.client.post(self.url, form)
  15. self.assertRedirects(r, self.channels_url)
  16. c = Channel.objects.get()
  17. self.assertEqual(c.kind, "pagertree")
  18. self.assertEqual(c.value, "http://example.org")
  19. self.assertEqual(c.project, self.project)
  20. def test_it_rejects_bad_url(self):
  21. form = {"value": "not an URL"}
  22. self.client.login(username="[email protected]", password="password")
  23. r = self.client.post(self.url, form)
  24. self.assertContains(r, "Enter a valid URL")