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.

56 lines
1.9 KiB

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