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.

28 lines
1.0 KiB

  1. from hc.api.models import Check
  2. from hc.test import BaseTestCase
  3. class DeleteCheckTestCase(BaseTestCase):
  4. def setUp(self):
  5. super(DeleteCheckTestCase, self).setUp()
  6. self.check = Check.objects.create(project=self.project)
  7. def test_it_works(self):
  8. r = self.client.delete("/api/v1/checks/%s" % self.check.code,
  9. HTTP_X_API_KEY="X" * 32)
  10. self.assertEqual(r.status_code, 200)
  11. self.assertEqual(r["Access-Control-Allow-Origin"], "*")
  12. # It should be gone--
  13. self.assertFalse(Check.objects.filter(code=self.check.code).exists())
  14. def test_it_handles_missing_check(self):
  15. url = "/api/v1/checks/07c2f548-9850-4b27-af5d-6c9dc157ec02"
  16. r = self.client.delete(url, HTTP_X_API_KEY="X" * 32)
  17. self.assertEqual(r.status_code, 404)
  18. def test_it_handles_options(self):
  19. r = self.client.options("/api/v1/checks/%s" % self.check.code)
  20. self.assertEqual(r.status_code, 204)
  21. self.assertIn("DELETE", r["Access-Control-Allow-Methods"])