|
|
@ -19,27 +19,6 @@ class PingTestCase(TestCase): |
|
|
|
ping = Ping.objects.latest("id") |
|
|
|
assert ping.scheme == "http" |
|
|
|
|
|
|
|
def test_it_changes_status_of_paused_check(self): |
|
|
|
self.check.status = "paused" |
|
|
|
self.check.save() |
|
|
|
|
|
|
|
r = self.client.get("/ping/%s/" % self.check.code) |
|
|
|
assert r.status_code == 200 |
|
|
|
|
|
|
|
self.check.refresh_from_db() |
|
|
|
assert self.check.status == "up" |
|
|
|
|
|
|
|
def test_post_works(self): |
|
|
|
csrf_client = Client(enforce_csrf_checks=True) |
|
|
|
r = csrf_client.post("/ping/%s/" % self.check.code) |
|
|
|
assert r.status_code == 200 |
|
|
|
|
|
|
|
def test_head_works(self): |
|
|
|
csrf_client = Client(enforce_csrf_checks=True) |
|
|
|
r = csrf_client.head("/ping/%s/" % self.check.code) |
|
|
|
assert r.status_code == 200 |
|
|
|
assert Ping.objects.count() == 1 |
|
|
|
|
|
|
|
def test_it_handles_bad_uuid(self): |
|
|
|
r = self.client.get("/ping/not-uuid/") |
|
|
|
assert r.status_code == 400 |
|
|
@ -70,8 +49,7 @@ class PingTestCase(TestCase): |
|
|
|
r = self.client.get("/ping/%s/" % self.check.code, |
|
|
|
HTTP_X_FORWARDED_FOR=ip) |
|
|
|
ping = Ping.objects.latest("id") |
|
|
|
assert r.status_code == 200 |
|
|
|
assert ping.remote_addr == "1.1.1.1" |
|
|
|
### Assert the expected response status code and ping's remote address |
|
|
|
|
|
|
|
ip = "1.1.1.1, 2.2.2.2" |
|
|
|
r = self.client.get("/ping/%s/" % self.check.code, |
|
|
@ -84,9 +62,12 @@ class PingTestCase(TestCase): |
|
|
|
r = self.client.get("/ping/%s/" % self.check.code, |
|
|
|
HTTP_X_FORWARDED_PROTO="https") |
|
|
|
ping = Ping.objects.latest("id") |
|
|
|
assert r.status_code == 200 |
|
|
|
assert ping.scheme == "https" |
|
|
|
### Assert the expected response status code and ping's scheme |
|
|
|
|
|
|
|
def test_it_never_caches(self): |
|
|
|
r = self.client.get("/ping/%s/" % self.check.code) |
|
|
|
assert "no-cache" in r.get("Cache-Control") |
|
|
|
|
|
|
|
### Test that when a ping is made a check with a paused status changes status |
|
|
|
### Test that a post to a ping works |
|
|
|
### Test that the csrf_client head works |