diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2018-04-02 15:50:05 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2018-04-02 15:50:05 +0300 |
commit | 2028f3a04be9836ff0f904a487f05bcff75d528d (patch) | |
tree | 5fcbb33b0672051ca138dad281dba950688add79 /test | |
parent | 5177b085b13be78d216441d21480caf81eb968c2 (diff) | |
download | unit-2028f3a04be9836ff0f904a487f05bcff75d528d.tar.gz unit-2028f3a04be9836ff0f904a487f05bcff75d528d.tar.bz2 |
Tests: use "%Z" directive while parsing Date header.
Diffstat (limited to '')
-rw-r--r-- | test/test_perl_application.py | 8 | ||||
-rw-r--r-- | test/test_python_application.py | 8 | ||||
-rw-r--r-- | test/test_ruby_application.py | 8 | ||||
-rw-r--r-- | test/unit.py | 2 |
4 files changed, 19 insertions, 7 deletions
diff --git a/test/test_perl_application.py b/test/test_perl_application.py index 755e115b..3d42f829 100644 --- a/test/test_perl_application.py +++ b/test/test_perl_application.py @@ -21,8 +21,12 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl): headers = resp['headers'] self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+', '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, { 'Content-Length': str(len(body)), 'Content-Type': 'text/html', diff --git a/test/test_python_application.py b/test/test_python_application.py index 1a6f4a1e..1a1a8741 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -21,8 +21,12 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): headers = resp['headers'] self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+', '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, { 'Content-Length': str(len(body)), 'Content-Type': 'text/html', diff --git a/test/test_ruby_application.py b/test/test_ruby_application.py index 796afc54..035ae65e 100644 --- a/test/test_ruby_application.py +++ b/test/test_ruby_application.py @@ -21,8 +21,12 @@ class TestUnitRubyApplication(unit.TestUnitApplicationRuby): headers = resp['headers'] self.assertRegex(headers.pop('Server'), r'Unit/[\d\.]+', '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, { 'Content-Length': str(len(body)), 'Content-Type': 'text/html', diff --git a/test/unit.py b/test/unit.py index cdf9ff62..e522e2da 100644 --- a/test/unit.py +++ b/test/unit.py @@ -335,7 +335,7 @@ class TestUnitApplicationProto(TestUnitControl): return time.mktime(time.gmtime()) 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): with open(self.testdir + '/unit.log', 'r') as f: |