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.

48 lines
1.6 KiB

6 years ago
  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, project=self.project)
  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. # The page should contain timezone strings
  20. self.assertContains(r, "Europe/Riga")
  21. def test_it_checks_ownership(self):
  22. self.client.login(username="[email protected]", password="password")
  23. r = self.client.get(self.url)
  24. self.assertEqual(r.status_code, 404)
  25. def test_it_shows_cron_expression(self):
  26. self.check.kind = "cron"
  27. self.check.save()
  28. self.client.login(username="[email protected]", password="password")
  29. r = self.client.get(self.url)
  30. self.assertContains(r, "Cron Expression", status_code=200)
  31. def test_it_allows_cross_team_access(self):
  32. self.bobs_profile.current_team = None
  33. self.bobs_profile.save()
  34. self.client.login(username="[email protected]", password="password")
  35. r = self.client.get(self.url)
  36. self.assertEqual(r.status_code, 200)