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.

50 lines
1.9 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.objects.create(project=self.project)
  7. ping = Ping.objects.create(owner=self.check)
  8. # Older MySQL versions don't store microseconds. This makes sure
  9. # the ping is older than any notifications we may create later:
  10. ping.created = "2000-01-01T00:00:00+00:00"
  11. ping.save()
  12. self.url = "/checks/%s/details/" % self.check.code
  13. def test_it_works(self):
  14. self.client.login(username="[email protected]", password="password")
  15. r = self.client.get(self.url)
  16. self.assertContains(r, "How To Ping", status_code=200)
  17. # The page should contain timezone strings
  18. self.assertContains(r, "Europe/Riga")
  19. def test_it_checks_ownership(self):
  20. self.client.login(username="[email protected]", password="password")
  21. r = self.client.get(self.url)
  22. self.assertEqual(r.status_code, 404)
  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)
  29. def test_it_allows_cross_team_access(self):
  30. self.bobs_profile.current_project = None
  31. self.bobs_profile.save()
  32. self.client.login(username="[email protected]", password="password")
  33. r = self.client.get(self.url)
  34. self.assertEqual(r.status_code, 200)
  35. def test_it_shows_new_check_notice(self):
  36. self.client.login(username="[email protected]", password="password")
  37. r = self.client.get(self.url + "?new")
  38. self.assertContains(r, "Your new check is ready!", status_code=200)