Tests: reworked python tests with application.

This commit is contained in:
Andrey Zelenkov
2018-02-20 20:34:41 +03:00
parent babf67712e
commit 09f2009df5
12 changed files with 104 additions and 191 deletions

View File

@@ -0,0 +1,4 @@
def application(environ, start_response):
start_response('204 No Content', [])
return []

View File

@@ -0,0 +1,12 @@
import atexit
def application(environ, start_response):
test_dir = environ.get('HTTP_TEST_DIR')
def create_file():
open(test_dir + '/atexit', 'w')
atexit.register(create_file)
start_response('200', [('Content-Length', '0')])
return []

View File

@@ -0,0 +1,3 @@
def application(env, start_response):
start_response('200', [('Content-Length', '0')])
return []

View File

@@ -0,0 +1,10 @@
def application(environ, start_response):
content_length = int(environ.get('CONTENT_LENGTH', 0))
body = bytes(environ['wsgi.input'].read(content_length))
start_response('200', [
('Content-Type', environ.get('CONTENT_TYPE')),
('Content-Length', str(len(body)))
])
return [body]

View File

@@ -0,0 +1,7 @@
def application(environ, start_response):
start_response('200', [
('Content-Length', '0'),
('Query-String', environ.get('QUERY_STRING'))
])
return []

View File

@@ -0,0 +1,7 @@
def application(environ, start_response):
start_response('200', [
('Content-Length', '0'),
('Server-Port', environ.get('SERVER_PORT'))
])
return []

View File

@@ -0,0 +1,15 @@
def application(environ, start_response):
content_length = int(environ.get('CONTENT_LENGTH', 0))
body = bytes(environ['wsgi.input'].read(content_length))
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')),
('Http-Host', environ.get('HTTP_HOST')),
('Server-Protocol', environ.get('SERVER_PROTOCOL')),
('Custom-Header', environ.get('HTTP_CUSTOM_HEADER'))
])
return [body]