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

  1. from hc.api.models import Check, Ping
  2. from hc.test import BaseTestCase
  3. class DetailsTestCase(BaseTestCase):
  4. def setUp(self):
  5. super(DetailsTestCase, self).setUp()
  6. self.check = Check(user=self.alice)
  7. self.check.save()
  8. ping = Ping(owner=self.check)
  9. ping.save()
  10. # Older MySQL versions don't store microseconds. This makes sure
  11. # the ping is older than any notifications we may create later:
  12. ping.created = "2000-01-01T00:00:00+00:00"
  13. ping.save()
  14. self.url = "/checks/%s/details/" % self.check.code
  15. def test_it_works(self):
  16. self.client.login(username="[email protected]", password="password")
  17. r = self.client.get(self.url)
  18. self.assertContains(r, "How To Ping", status_code=200)
  19. def test_it_checks_ownership(self):
  20. self.client.login(username="[email protected]", password="password")
  21. r = self.client.get(self.url)
  22. assert r.status_code == 403
  23. def test_it_shows_cron_expression(self):
  24. self.check.kind = "cron"
  25. self.check.save()
  26. self.client.login(username="[email protected]", password="password")
  27. r = self.client.get(self.url)
  28. self.assertContains(r, "Cron Expression", status_code=200)