Overwrite Check.last_start value

This commit is contained in:
Pēteris Caune 2018-12-21 14:02:25 +02:00
parent fe04429fad
commit eee6fc12f4
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
2 changed files with 1 additions and 17 deletions

View File

@ -219,9 +219,6 @@ class Check(models.Model):
def ping(self, remote_addr, scheme, method, ua, body, action):
if action == "start":
# If we receive multiple start events in a row,
# we remember the first one, not the last one
if self.last_start is None:
self.last_start = timezone.now()
# DOn't update "last_ping" field.
else:

View File

@ -168,16 +168,3 @@ class PingTestCase(TestCase):
self.check.refresh_from_db()
self.assertTrue(self.check.last_start)
self.assertEqual(self.check.status, "paused")
def test_start_does_not_overwrite_last_start(self):
first_start = now() - td(hours=2)
self.check.last_start = first_start
self.check.save()
r = self.client.get("/ping/%s/start" % self.check.code)
self.assertEqual(r.status_code, 200)
self.check.refresh_from_db()
# Should still be the original value
self.assertEqual(self.check.last_start, first_start)