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.

29 lines
1.1 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(user=self.alice, project=self.project)
  7. self.check.save()
  8. def test_it_works(self):
  9. r = self.client.delete("/api/v1/checks/%s" % self.check.code,
  10. HTTP_X_API_KEY="X" * 32)
  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"])