Commit 0d91448e authored by Łukasz Nowak's avatar Łukasz Nowak

promise: Improve bot status problem reporting in check_surykatka_json

parent b25e3e3a
......@@ -65,7 +65,9 @@ class RunPromise(GenericPromise):
return
bot_status = bot_status_list[0]
if bot_status.get('text') != 'loop':
appendError("No type loop detected in %r", self.json_file)
appendError(
"bot_status is %r instead of 'loop' in %r",
str(bot_status.get('text')), self.json_file)
return
timetuple = email.utils.parsedate(bot_status['date'])
last_bot_datetime = datetime.datetime.fromtimestamp(time.mktime(timetuple))
......
......@@ -118,6 +118,32 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
"UTC now is Wed, 13 Dec 2222 09:11:12 -0000"
)
def test_no_loop(self):
self.writeSurykatkaPromise(
{
'report': 'bot_status',
'json-file': self.json_file,
'test-utcnow': 'Wed, 13 Dec 2222 09:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
"bot_status": [
{
"date": "Wed, 13 Dec 2222 09:10:11 -0000",
"text": "error"
}
]
}
""")
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"bot_status: ERROR bot_status is 'error' instead of 'loop' in '%s'" % (
self.json_file,)
)
def test_bot_status_future(self):
self.writeSurykatkaPromise(
{
......
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