Commit efcc40ee authored by Łukasz Nowak's avatar Łukasz Nowak

check_surykatka_json: flake8ize

parent 6b4f9dfb
......@@ -71,7 +71,6 @@ 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):
......@@ -181,8 +180,7 @@ class RunPromise(GenericPromise):
appendError(
'HTTP Header dict was %s instead of %s' % (
json.dumps(entry['http_header_dict'], sort_keys=True),
json.dumps(http_header_dict, sort_keys=True),
))
json.dumps(http_header_dict, sort_keys=True),))
error = True
db_ip_list = [q['ip'] for q in entry_list]
if len(ip_list):
......
......@@ -512,8 +512,8 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"http://www.erp5.com/ : http_query: OK with status code 302 on IPs 127.0.0.1 "
"127.0.0.2"
"http://www.erp5.com/ : http_query: OK with status code 302 on IPs "
"127.0.0.1 127.0.0.2"
)
def test_http_with_header_dict(self):
......@@ -523,16 +523,19 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'http://www.erp5.com/',
'status-code': '200',
'http-header-dict': '{"Vary": "Accept-Encoding", "Cache-Control": "max-age=300, public"}',
'http-header-dict': '{"Vary": "Accept-Encoding", "Cache-Control": '
'"max-age=300, public"}',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson(
"""{
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
"ip": "176.31.129.213",
"http_header_dict": {"Vary": "Accept-Encoding", "Cache-Control": "max-age=300, public"},
"http_header_dict": {"Vary": "Accept-Encoding", """
""""Cache-Control": "max-age=300, public"},
"status_code": 200,
"url": "http://www.erp5.com/"
}
......@@ -546,7 +549,8 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"http://www.erp5.com/ : http_query: OK with status code 200 "
"and HTTP Header dict {\"Cache-Control\": \"max-age=300, public\", \"Vary\": \"Accept-Encoding\"}"
"and HTTP Header dict {\"Cache-Control\": \"max-age=300, public\", "
"\"Vary\": \"Accept-Encoding\"}"
)
def test_http_with_bad_header_dict(self):
......@@ -556,16 +560,19 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'http://www.erp5.com/',
'status-code': '200',
'http-header-dict': '{"Vary": "Accept-Encoding", "Cache-Control": "max-age=300, public"}',
'http-header-dict': '{"Vary": "Accept-Encoding", "Cache-Control": '
'"max-age=300, public"}',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson(
"""{
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
"ip": "176.31.129.213",
"http_header_dict": {"Vary": "Accept-Encoding,Cookie", "Cache-Control": "max-age=300, public"},
"http_header_dict": {"Vary": "Accept-Encoding,Cookie", """
""""Cache-Control": "max-age=300, public"},
"status_code": 200,
"url": "http://www.erp5.com/"
}
......@@ -580,8 +587,10 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"http://www.erp5.com/ : http_query: ERROR HTTP Header dict was "
"{\"Cache-Control\": \"max-age=300, public\", \"Vary\": \"Accept-Encoding,Cookie\"} "
"instead of {\"Cache-Control\": \"max-age=300, public\", \"Vary\": \"Accept-Encoding\"}"
"{\"Cache-Control\": \"max-age=300, public\", \"Vary\": "
"\"Accept-Encoding,Cookie\"} "
"instead of {\"Cache-Control\": \"max-age=300, public\", \"Vary\": "
"\"Accept-Encoding\"}"
)
def test_no_ip_list(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