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

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. from hc.api.models import Check, Ping
  2. from hc.test import BaseTestCase
  3. class LogTestCase(BaseTestCase):
  4. def setUp(self):
  5. super(LogTestCase, self).setUp()
  6. self.check = Check(user=self.alice)
  7. self.check.save()
  8. ping = Ping(owner=self.check)
  9. ping.save()
  10. def test_it_works(self):
  11. url = "/checks/%s/log/" % self.check.code
  12. self.client.login(username="[email protected]", password="password")
  13. r = self.client.get(url)
  14. self.assertContains(r, "Local Time", status_code=200)
  15. def test_team_access_works(self):
  16. url = "/checks/%s/log/" % self.check.code
  17. # Logging in as bob, not alice. Bob has team access so this
  18. # should work.
  19. self.client.login(username="[email protected]", password="password")
  20. r = self.client.get(url)
  21. self.assertEqual(r.status_code, 200)
  22. def test_it_handles_bad_uuid(self):
  23. url = "/checks/not-uuid/log/"
  24. self.client.login(username="[email protected]", password="password")
  25. r = self.client.get(url)
  26. assert r.status_code == 400
  27. def test_it_handles_missing_uuid(self):
  28. # Valid UUID but there is no check for it:
  29. url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/log/"
  30. self.client.login(username="[email protected]", password="password")
  31. r = self.client.get(url)
  32. assert r.status_code == 404
  33. def test_it_checks_ownership(self):
  34. url = "/checks/%s/log/" % self.check.code
  35. self.client.login(username="[email protected]", password="password")
  36. r = self.client.get(url)
  37. assert r.status_code == 403