diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2018-02-20 20:34:41 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2018-02-20 20:34:41 +0300 |
commit | 09f2009df564ab2063ee4713ba24247039945146 (patch) | |
tree | 5c719060dd4af2ca932da96d93d77eeebc6c5f25 /test/unit.py | |
parent | babf67712e4226527730e2fb8c96babdf5486ca5 (diff) | |
download | unit-09f2009df564ab2063ee4713ba24247039945146.tar.gz unit-09f2009df564ab2063ee4713ba24247039945146.tar.bz2 |
Tests: reworked python tests with application.
Diffstat (limited to 'test/unit.py')
-rw-r--r-- | test/unit.py | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/test/unit.py b/test/unit.py index 43f4d632..2d50d64b 100644 --- a/test/unit.py +++ b/test/unit.py @@ -77,12 +77,6 @@ class TestUnit(unittest.TestCase): self.testdir + '/unit.log', self.testdir + '/control.unit.sock'): exit("Could not start unit") - def python_application(self, name, code): - os.mkdir(self.testdir + '/' + name) - - with open(self.testdir + '/' + name + '/wsgi.py', 'w') as f: - f.write(code) - def _stop(self): with open(self.testdir + '/unit.pid', 'r') as f: pid = f.read().rstrip() @@ -283,20 +277,41 @@ class TestUnitApplicationProto(TestUnitControl): current_dir = os.path.dirname(os.path.abspath(__file__)) +class TestUnitApplicationPython(TestUnitApplicationProto): + def load(self, script, name=None): + if name is None: + name = script + + self.conf({ + "listeners": { + "*:7080": { + "application": name + } + }, + "applications": { + name: { + "type": "python", + "processes": { "spare": 0 }, + "path": self.current_dir + '/python/' + script, + "module": "wsgi" + } + } + }) + class TestUnitApplicationPerl(TestUnitApplicationProto): - def load(self, dir, name='psgi.pl'): + def load(self, script, name='psgi.pl'): self.conf({ "listeners": { "*:7080": { - "application": dir + "application": script } }, "applications": { - dir: { + script: { "type": "perl", "processes": { "spare": 0 }, - "working_directory": self.current_dir + '/perl/' + dir, - "script": self.current_dir + '/perl/' + dir + '/' + name + "working_directory": self.current_dir + '/perl/' + script, + "script": self.current_dir + '/perl/' + script + '/' + name } } }) |