|
|
@ -33,6 +33,14 @@ class BadgeTestCase(BaseTestCase): |
|
|
|
self.assertEqual(r.status_code, 204) |
|
|
|
self.assertEqual(r["Access-Control-Allow-Origin"], "*") |
|
|
|
|
|
|
|
def test_it_handles_new(self): |
|
|
|
r = self.client.get(self.json_url) |
|
|
|
doc = r.json() |
|
|
|
self.assertEqual(doc["status"], "up") |
|
|
|
self.assertEqual(doc["total"], 1) |
|
|
|
self.assertEqual(doc["grace"], 0) |
|
|
|
self.assertEqual(doc["down"], 0) |
|
|
|
|
|
|
|
def test_it_handles_started_but_down(self): |
|
|
|
self.check.last_start = now() |
|
|
|
self.check.tags = "foo" |
|
|
@ -40,7 +48,11 @@ class BadgeTestCase(BaseTestCase): |
|
|
|
self.check.save() |
|
|
|
|
|
|
|
r = self.client.get(self.json_url) |
|
|
|
self.assertContains(r, "down") |
|
|
|
doc = r.json() |
|
|
|
self.assertEqual(doc["status"], "down") |
|
|
|
self.assertEqual(doc["total"], 1) |
|
|
|
self.assertEqual(doc["grace"], 0) |
|
|
|
self.assertEqual(doc["down"], 1) |
|
|
|
|
|
|
|
def test_it_shows_grace_badge(self): |
|
|
|
self.check.last_ping = now() - td(days=1, minutes=10) |
|
|
@ -49,7 +61,11 @@ class BadgeTestCase(BaseTestCase): |
|
|
|
self.check.save() |
|
|
|
|
|
|
|
r = self.client.get(self.json_url) |
|
|
|
self.assertContains(r, "late") |
|
|
|
doc = r.json() |
|
|
|
self.assertEqual(doc["status"], "late") |
|
|
|
self.assertEqual(doc["total"], 1) |
|
|
|
self.assertEqual(doc["grace"], 1) |
|
|
|
self.assertEqual(doc["down"], 0) |
|
|
|
|
|
|
|
def test_it_shows_started_but_grace_badge(self): |
|
|
|
self.check.last_start = now() |
|
|
@ -59,7 +75,11 @@ class BadgeTestCase(BaseTestCase): |
|
|
|
self.check.save() |
|
|
|
|
|
|
|
r = self.client.get(self.json_url) |
|
|
|
self.assertContains(r, "late") |
|
|
|
doc = r.json() |
|
|
|
self.assertEqual(doc["status"], "late") |
|
|
|
self.assertEqual(doc["total"], 1) |
|
|
|
self.assertEqual(doc["grace"], 1) |
|
|
|
self.assertEqual(doc["down"], 0) |
|
|
|
|
|
|
|
def test_it_handles_special_characters(self): |
|
|
|
self.check.tags = "db@dc1" |
|
|
|