diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2021-02-04 15:09:54 +0000 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2021-02-04 15:09:54 +0000 |
commit | 42725137f7a19991680c78a0b2d69bcbf1f9ab63 (patch) | |
tree | 0092d24f45f29daeaf9ef263879a04809685b439 /test/test_python_application.py | |
parent | f2d96335664f561cab4ff2ff02f5cd3333af3b3a (diff) | |
download | unit-42725137f7a19991680c78a0b2d69bcbf1f9ab63.tar.gz unit-42725137f7a19991680c78a0b2d69bcbf1f9ab63.tar.bz2 |
Tests: added tests for "path" option in Python application.
Diffstat (limited to '')
-rw-r--r-- | test/test_python_application.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/test_python_application.py b/test/test_python_application.py index 5ad0901d..709df3ff 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -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) |