Tests: added tests for "path" option in Python application.
This commit is contained in:
8
test/python/path/wsgi.py
Normal file
8
test/python/path/wsgi.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def application(environ, start_response):
|
||||||
|
body = os.pathsep.join(sys.path).encode()
|
||||||
|
|
||||||
|
start_response('200', [('Content-Length', str(len(body)))])
|
||||||
|
return [body]
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import grp
|
import grp
|
||||||
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
@@ -790,6 +791,42 @@ last line: 987654321
|
|||||||
|
|
||||||
assert self.get()['status'] not in [200, 204], 'callable response inv'
|
assert self.get()['status'] not in [200, 204], 'callable response inv'
|
||||||
|
|
||||||
|
def test_python_application_path(self):
|
||||||
|
self.load('path')
|
||||||
|
|
||||||
|
def set_path(path):
|
||||||
|
assert 'success' in self.conf(path, 'applications/path/path')
|
||||||
|
|
||||||
|
def get_path():
|
||||||
|
return self.get()['body'].split(os.pathsep)
|
||||||
|
|
||||||
|
default_path = self.conf_get('/config/applications/path/path')
|
||||||
|
assert 'success' in self.conf(
|
||||||
|
{"PYTHONPATH": default_path},
|
||||||
|
'/config/applications/path/environment',
|
||||||
|
)
|
||||||
|
|
||||||
|
self.conf_delete('/config/applications/path/path')
|
||||||
|
sys_path = get_path()
|
||||||
|
|
||||||
|
set_path('"/blah"')
|
||||||
|
assert ['/blah', *sys_path] == get_path(), 'check path'
|
||||||
|
|
||||||
|
set_path('"/new"')
|
||||||
|
assert ['/new', *sys_path] == get_path(), 'check path update'
|
||||||
|
|
||||||
|
set_path('["/blah1", "/blah2"]')
|
||||||
|
assert ['/blah1', '/blah2', *sys_path] == get_path(), 'check path array'
|
||||||
|
|
||||||
|
def test_python_application_path_invalid(self):
|
||||||
|
self.load('path')
|
||||||
|
|
||||||
|
def check_path(path):
|
||||||
|
assert 'error' in self.conf(path, 'applications/path/path')
|
||||||
|
|
||||||
|
check_path('{}')
|
||||||
|
check_path('["/blah", []]')
|
||||||
|
|
||||||
def test_python_application_threads(self):
|
def test_python_application_threads(self):
|
||||||
self.load('threads', threads=4)
|
self.load('threads', threads=4)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user