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

from hc.api.models import Check
from hc.test import BaseTestCase
class DeleteCheckTestCase(BaseTestCase):
def setUp(self):
super(DeleteCheckTestCase, self).setUp()
self.check = Check.objects.create(project=self.project)
def test_it_works(self):
r = self.client.delete("/api/v1/checks/%s" % self.check.code,
HTTP_X_API_KEY="X" * 32)
self.assertEqual(r.status_code, 200)
self.assertEqual(r["Access-Control-Allow-Origin"], "*")
# It should be gone--
self.assertFalse(Check.objects.filter(code=self.check.code).exists())
def test_it_handles_missing_check(self):
url = "/api/v1/checks/07c2f548-9850-4b27-af5d-6c9dc157ec02"
r = self.client.delete(url, HTTP_X_API_KEY="X" * 32)
self.assertEqual(r.status_code, 404)
def test_it_handles_options(self):
r = self.client.options("/api/v1/checks/%s" % self.check.code)
self.assertEqual(r.status_code, 204)
self.assertIn("DELETE", r["Access-Control-Allow-Methods"])