Tests: use "%Z" directive while parsing Date header.
This commit is contained in:
@@ -21,8 +21,12 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl):
|
|||||||
headers = resp['headers']
|
headers = resp['headers']
|
||||||
self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+',
|
self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+',
|
||||||
'server header')
|
'server header')
|
||||||
self.assertLess(abs(self.date_to_sec_epoch(headers.pop('Date')) -
|
|
||||||
self.sec_epoch()), 5, 'date header')
|
date = headers.pop('Date')
|
||||||
|
self.assertEqual(date[-4:], ' GMT', 'date header timezone')
|
||||||
|
self.assertLess(abs(self.date_to_sec_epoch(date) - self.sec_epoch()), 5,
|
||||||
|
'date header')
|
||||||
|
|
||||||
self.assertDictEqual(headers, {
|
self.assertDictEqual(headers, {
|
||||||
'Content-Length': str(len(body)),
|
'Content-Length': str(len(body)),
|
||||||
'Content-Type': 'text/html',
|
'Content-Type': 'text/html',
|
||||||
|
|||||||
@@ -21,8 +21,12 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython):
|
|||||||
headers = resp['headers']
|
headers = resp['headers']
|
||||||
self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+',
|
self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+',
|
||||||
'server header')
|
'server header')
|
||||||
self.assertLess(abs(self.date_to_sec_epoch(headers.pop('Date')) -
|
|
||||||
self.sec_epoch()), 5, 'date header')
|
date = headers.pop('Date')
|
||||||
|
self.assertEqual(date[-4:], ' GMT', 'date header timezone')
|
||||||
|
self.assertLess(abs(self.date_to_sec_epoch(date) - self.sec_epoch()), 5,
|
||||||
|
'date header')
|
||||||
|
|
||||||
self.assertDictEqual(headers, {
|
self.assertDictEqual(headers, {
|
||||||
'Content-Length': str(len(body)),
|
'Content-Length': str(len(body)),
|
||||||
'Content-Type': 'text/html',
|
'Content-Type': 'text/html',
|
||||||
|
|||||||
@@ -21,8 +21,12 @@ class TestUnitRubyApplication(unit.TestUnitApplicationRuby):
|
|||||||
headers = resp['headers']
|
headers = resp['headers']
|
||||||
self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+',
|
self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+',
|
||||||
'server header')
|
'server header')
|
||||||
self.assertLess(abs(self.date_to_sec_epoch(headers.pop('Date')) -
|
|
||||||
self.sec_epoch()), 5, 'date header')
|
date = headers.pop('Date')
|
||||||
|
self.assertEqual(date[-4:], ' GMT', 'date header timezone')
|
||||||
|
self.assertLess(abs(self.date_to_sec_epoch(date) - self.sec_epoch()), 5,
|
||||||
|
'date header')
|
||||||
|
|
||||||
self.assertDictEqual(headers, {
|
self.assertDictEqual(headers, {
|
||||||
'Content-Length': str(len(body)),
|
'Content-Length': str(len(body)),
|
||||||
'Content-Type': 'text/html',
|
'Content-Type': 'text/html',
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ class TestUnitApplicationProto(TestUnitControl):
|
|||||||
return time.mktime(time.gmtime())
|
return time.mktime(time.gmtime())
|
||||||
|
|
||||||
def date_to_sec_epoch(self, date):
|
def date_to_sec_epoch(self, date):
|
||||||
return time.mktime(time.strptime(date, '%a, %d %b %Y %H:%M:%S GMT'))
|
return time.mktime(time.strptime(date, '%a, %d %b %Y %H:%M:%S %Z'))
|
||||||
|
|
||||||
def search_in_log(self, pattern):
|
def search_in_log(self, pattern):
|
||||||
with open(self.testdir + '/unit.log', 'r') as f:
|
with open(self.testdir + '/unit.log', 'r') as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user