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.

47 lines
1.5 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. from django.contrib.auth.models import User
  2. from hc.api.models import Check, Ping
  3. from hc.test import BaseTestCase
  4. class LogTestCase(BaseTestCase):
  5. def setUp(self):
  6. super(LogTestCase, self).setUp()
  7. self.check = Check(user=self.alice)
  8. self.check.save()
  9. ping = Ping(owner=self.check)
  10. ping.save()
  11. def test_it_works(self):
  12. url = "/checks/%s/log/" % self.check.code
  13. self.client.login(username="[email protected]", password="password")
  14. r = self.client.get(url)
  15. self.assertContains(r, "Dates and times are", status_code=200)
  16. def test_it_handles_bad_uuid(self):
  17. url = "/checks/not-uuid/log/"
  18. self.client.login(username="[email protected]", password="password")
  19. r = self.client.get(url)
  20. assert r.status_code == 400
  21. def test_it_handles_missing_uuid(self):
  22. # Valid UUID but there is no check for it:
  23. url = "/checks/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/log/"
  24. self.client.login(username="[email protected]", password="password")
  25. r = self.client.get(url)
  26. assert r.status_code == 404
  27. def test_it_checks_ownership(self):
  28. charlie = User(username="charlie", email="[email protected]")
  29. charlie.set_password("password")
  30. charlie.save()
  31. url = "/checks/%s/log/" % self.check.code
  32. self.client.login(username="[email protected]", password="password")
  33. r = self.client.get(url)
  34. assert r.status_code == 403