Commit 8e685c86 authored by Łukasz Nowak's avatar Łukasz Nowak

promise: Format times in check_surykatka_json

Since standard date format is used in the ssl_certificate checks, do the
same for readability and consistency in bot_status.
parent 8a6dd37a
......@@ -52,20 +52,21 @@ class RunPromise(GenericPromise):
return
timetuple = email.utils.parsedate(bot_status['date'])
last_bot_datetime = datetime.datetime.fromtimestamp(time.mktime(timetuple))
last_bot_datetime_string = email.utils.formatdate(time.mktime(timetuple))
delta = self.utcnow - last_bot_datetime
# sanity check
if delta < datetime.timedelta(minutes=0):
logError('Last bot datetime %s is in future, UTC now %s',
last_bot_datetime, self.utcnow)
last_bot_datetime_string, self.utcnow_string)
return
if delta > datetime.timedelta(minutes=15):
logError('Last bot datetime %s is more than 15 minutes old, UTC now %s',
last_bot_datetime, self.utcnow)
last_bot_datetime_string, self.utcnow_string)
return
self.appendInfo(
'%s: Last bot status from %s ok, UTC now is %s' %
(key, last_bot_datetime, self.utcnow))
(key, last_bot_datetime_string, self.utcnow_string))
def senseSslCertificate(self):
key = 'ssl_certificate'
......
......@@ -114,8 +114,8 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"bot_status: Last bot status from 2222-12-13 09:10:11 ok, "
"UTC now is 2222-12-13 09:11:12"
"bot_status: Last bot status from Fri, 13 Dec 2222 08:10:11 -0000 "
"ok, UTC now is Wed, 13 Dec 2222 09:11:12 -0000"
)
def test_bot_status_future(self):
......@@ -140,8 +140,8 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"bot_status: Last bot datetime 2223-12-13 09:10:11 is in "
"future, UTC now 2222-12-13 09:11:12"
"bot_status: Last bot datetime Sat, 13 Dec 2223 08:10:11 -0000 is "
"in future, UTC now Wed, 13 Dec 2222 09:11:12 -0000"
)
def test_bot_status_old(self):
......@@ -166,8 +166,8 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"bot_status: Last bot datetime 2223-12-13 09:10:11 is "
"more than 15 minutes old, UTC now 2223-12-13 09:26:12"
"bot_status: Last bot datetime Sat, 13 Dec 2223 08:10:11 -0000 is "
"more than 15 minutes old, UTC now Wed, 13 Dec 2223 09:26:12 -0000"
)
def test_not_bot_status(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment