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