diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2018-01-30 16:16:42 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2018-01-30 16:16:42 +0300 |
commit | f115cb7032dc0a2a2fa5ef6f66167efdd6b93544 (patch) | |
tree | 15774ef9c70d72c0a1e98d52cdf925ad4008c32c | |
parent | cb80be00a52f3e1d708dc38271a6fa23a4d1a1d2 (diff) | |
download | unit-f115cb7032dc0a2a2fa5ef6f66167efdd6b93544.tar.gz unit-f115cb7032dc0a2a2fa5ef6f66167efdd6b93544.tar.bz2 |
Tests: small fixes.
-rw-r--r-- | test/test_configuration.py | 4 | ||||
-rw-r--r-- | test/test_python_application.py | 24 | ||||
-rw-r--r-- | test/test_python_atexit.py | 2 |
3 files changed, 9 insertions, 21 deletions
diff --git a/test/test_configuration.py b/test/test_configuration.py index 104ef272..9b3e02cc 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -158,7 +158,7 @@ class TestUnitConfiguration(unit.TestUnitControl): self.assertIn('success', self.put('/', """ { "listeners": { - "127.0.0.1:7081": { + "127.0.0.1:7080": { "application":"app" } }, @@ -177,7 +177,7 @@ class TestUnitConfiguration(unit.TestUnitControl): self.assertIn('success', self.put('/', """ { "listeners": { - "[::1]:7082": { + "[::1]:7080": { "application":"app" } }, diff --git a/test/test_python_application.py b/test/test_python_application.py index d1790bf6..d2c2b73e 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -35,15 +35,12 @@ def application(environ, start_response): content_length = int(environ.get('CONTENT_LENGTH', 0)) body = bytes(environ['wsgi.input'].read(content_length)) - start_response('200 OK', [ + start_response('200', [ ('Content-Type', environ.get('CONTENT_TYPE')), ('Content-Length', str(len(body))), ('Request-Method', environ.get('REQUEST_METHOD')), ('Request-Uri', environ.get('REQUEST_URI')), - ('Path-Info', environ.get('PATH_INFO')), ('Http-Host', environ.get('HTTP_HOST')), - ('Remote-Addr', environ.get('REMOTE_ADDR')), - ('Server-Name', environ.get('SERVER_NAME')), ('Server-Protocol', environ.get('SERVER_PROTOCOL')), ('Custom-Header', environ.get('HTTP_CUSTOM_HEADER')) ]) @@ -71,25 +68,19 @@ def application(environ, start_response): 'Content-Type': 'text/html', 'Request-Method': 'POST', 'Request-Uri': '/', - 'Path-Info': '/', 'Http-Host': 'localhost', - 'Server-Name': 'localhost', - 'Remote-Addr': '127.0.0.1', 'Server-Protocol': 'HTTP/1.1', 'Custom-Header': 'blah' }, 'headers') - self.assertEqual(r.content, str.encode(body), 'body') + self.assertEqual(r.content, body.encode(), 'body') def test_python_application_query_string(self): code, name = """ def application(environ, start_response): - start_response('200 OK', [ + start_response('200', [ ('Content-Length', '0'), - ('Request-Method', environ.get('REQUEST_METHOD')), - ('Request-Uri', environ.get('REQUEST_URI')), - ('Path-Info', environ.get('PATH_INFO')), ('Query-String', environ.get('QUERY_STRING')) ]) return [] @@ -108,10 +99,7 @@ def application(environ, start_response): headers.pop('Server') self.assertDictEqual(headers, { 'Content-Length': '0', - 'Request-Method': 'GET', - 'Query-String': 'var1=val1&var2=val2', - 'Request-Uri': '/?var1=val1&var2=val2', - 'Path-Info': '/' + 'Query-String': 'var1=val1&var2=val2' }, 'headers') @unittest.expectedFailure @@ -120,8 +108,8 @@ def application(environ, start_response): def application(environ, start_response): - start_response('200 OK', [ - ('Content-Type', 'text/html'), + start_response('200', [ + ('Content-Length', '0'), ('Server-Port', environ.get('SERVER_PORT')) ]) return [] diff --git a/test/test_python_atexit.py b/test/test_python_atexit.py index 82fa9a39..6c1b6365 100644 --- a/test/test_python_atexit.py +++ b/test/test_python_atexit.py @@ -21,7 +21,7 @@ def create_file(): atexit.register(create_file) def application(env, start_response): - start_response('200 OK', [('Content-Type','text/html')]) + start_response('200', [('Content-Length', '0')]) return [] """ % (self.testdir + '/atexit'), 'py_app' |