summaryrefslogtreecommitdiffhomepage
path: root/test/python
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2018-02-20 20:34:41 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2018-02-20 20:34:41 +0300
commit09f2009df564ab2063ee4713ba24247039945146 (patch)
tree5c719060dd4af2ca932da96d93d77eeebc6c5f25 /test/python
parentbabf67712e4226527730e2fb8c96babdf5486ca5 (diff)
downloadunit-09f2009df564ab2063ee4713ba24247039945146.tar.gz
unit-09f2009df564ab2063ee4713ba24247039945146.tar.bz2
Tests: reworked python tests with application.
Diffstat (limited to 'test/python')
-rw-r--r--test/python/204_no_content/wsgi.py4
-rw-r--r--test/python/atexit/wsgi.py12
-rw-r--r--test/python/empty/wsgi.py3
-rw-r--r--test/python/mirror/wsgi.py10
-rw-r--r--test/python/query_string/wsgi.py7
-rw-r--r--test/python/server_port/wsgi.py7
-rw-r--r--test/python/variables/wsgi.py15
7 files changed, 58 insertions, 0 deletions
diff --git a/test/python/204_no_content/wsgi.py b/test/python/204_no_content/wsgi.py
new file mode 100644
index 00000000..2184ffeb
--- /dev/null
+++ b/test/python/204_no_content/wsgi.py
@@ -0,0 +1,4 @@
+def application(environ, start_response):
+
+ start_response('204 No Content', [])
+ return []
diff --git a/test/python/atexit/wsgi.py b/test/python/atexit/wsgi.py
new file mode 100644
index 00000000..9ad300b9
--- /dev/null
+++ b/test/python/atexit/wsgi.py
@@ -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 []
diff --git a/test/python/empty/wsgi.py b/test/python/empty/wsgi.py
new file mode 100644
index 00000000..ce03850a
--- /dev/null
+++ b/test/python/empty/wsgi.py
@@ -0,0 +1,3 @@
+def application(env, start_response):
+ start_response('200', [('Content-Length', '0')])
+ return []
diff --git a/test/python/mirror/wsgi.py b/test/python/mirror/wsgi.py
new file mode 100644
index 00000000..e4df67ec
--- /dev/null
+++ b/test/python/mirror/wsgi.py
@@ -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]
diff --git a/test/python/query_string/wsgi.py b/test/python/query_string/wsgi.py
new file mode 100644
index 00000000..90f1c7ec
--- /dev/null
+++ b/test/python/query_string/wsgi.py
@@ -0,0 +1,7 @@
+def application(environ, start_response):
+
+ start_response('200', [
+ ('Content-Length', '0'),
+ ('Query-String', environ.get('QUERY_STRING'))
+ ])
+ return []
diff --git a/test/python/server_port/wsgi.py b/test/python/server_port/wsgi.py
new file mode 100644
index 00000000..89cd82b3
--- /dev/null
+++ b/test/python/server_port/wsgi.py
@@ -0,0 +1,7 @@
+def application(environ, start_response):
+
+ start_response('200', [
+ ('Content-Length', '0'),
+ ('Server-Port', environ.get('SERVER_PORT'))
+ ])
+ return []
diff --git a/test/python/variables/wsgi.py b/test/python/variables/wsgi.py
new file mode 100644
index 00000000..1d4d397d
--- /dev/null
+++ b/test/python/variables/wsgi.py
@@ -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]