Browse Source

Merge branch 'master' of github.com:healthchecks/healthchecks

pull/81/head
Pēteris Caune 8 years ago
parent
commit
4f8fdd2423
2 changed files with 7 additions and 1 deletions
  1. +2
    -1
      hc/api/models.py
  2. +5
    -0
      hc/api/tests/test_list_checks.py

+ 2
- 1
hc/api/models.py View File

@ -114,7 +114,8 @@ class Check(models.Model):
"tags": self.tags,
"timeout": int(self.timeout.total_seconds()),
"grace": int(self.grace.total_seconds()),
"n_pings": self.n_pings
"n_pings": self.n_pings,
"status": self.get_status()
}
if self.last_ping:


+ 5
- 0
hc/api/tests/test_list_checks.py View File

@ -18,11 +18,14 @@ class ListChecksTestCase(BaseTestCase):
self.a1.grace = td(seconds=900)
self.a1.last_ping = self.now
self.a1.n_pings = 1
self.a1.status = "new"
self.a1.save()
self.a2 = Check(user=self.alice, name="Alice 2")
self.a2.timeout = td(seconds=86400)
self.a2.grace = td(seconds=3600)
self.a2.last_ping = self.now
self.a2.status = "up"
self.a2.save()
def get(self):
@ -43,6 +46,7 @@ class ListChecksTestCase(BaseTestCase):
self.assertEqual(checks["Alice 1"]["ping_url"], self.a1.url())
self.assertEqual(checks["Alice 1"]["last_ping"], self.now.isoformat())
self.assertEqual(checks["Alice 1"]["n_pings"], 1)
self.assertEqual(checks["Alice 1"]["status"], "new")
next_ping = self.now + td(seconds=3600)
self.assertEqual(checks["Alice 1"]["next_ping"], next_ping.isoformat())
@ -50,6 +54,7 @@ class ListChecksTestCase(BaseTestCase):
self.assertEqual(checks["Alice 2"]["timeout"], 86400)
self.assertEqual(checks["Alice 2"]["grace"], 3600)
self.assertEqual(checks["Alice 2"]["ping_url"], self.a2.url())
self.assertEqual(checks["Alice 2"]["status"], "up")
def test_it_shows_only_users_checks(self):
bobs_check = Check(user=self.bob, name="Bob 1")


Loading…
Cancel
Save