Tests: added tests for "path" option in Python application.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import grp
|
||||
import os
|
||||
import pwd
|
||||
import re
|
||||
import time
|
||||
@@ -790,6 +791,42 @@ last line: 987654321
|
||||
|
||||
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):
|
||||
self.load('threads', threads=4)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user