summaryrefslogtreecommitdiffhomepage
path: root/test/test_python_environment.py
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-05-30 17:44:29 +0300
committerAndrei Belov <defan@nginx.com>2019-05-30 17:44:29 +0300
commit4921df052be8437d912f3c60faa9a667890e4498 (patch)
tree3678c551f148a0d177721597de978c090237f205 /test/test_python_environment.py
parent3b7a7ff2aa5840d4238584410ee1ebc6860fb9c5 (diff)
parent7da320a93af07765e79c929287704936c431f3cd (diff)
downloadunit-4921df052be8437d912f3c60faa9a667890e4498.tar.gz
unit-4921df052be8437d912f3c60faa9a667890e4498.tar.bz2
Merged with the default branch.1.9.0-1
Diffstat (limited to 'test/test_python_environment.py')
-rw-r--r--test/test_python_environment.py223
1 files changed, 137 insertions, 86 deletions
diff --git a/test/test_python_environment.py b/test/test_python_environment.py
index 71e4d5b7..744f4947 100644
--- a/test/test_python_environment.py
+++ b/test/test_python_environment.py
@@ -1,128 +1,179 @@
-import unittest
-import unit
+from unit.applications.lang.python import TestApplicationPython
-class TestUnitPythonEnvironment(unit.TestUnitApplicationPython):
- def setUpClass():
- unit.TestUnit().check_modules('python')
+class TestPythonEnvironment(TestApplicationPython):
+ prerequisites = ['python']
def test_python_environment_name_null(self):
self.load('environment')
- self.assertIn('error', self.conf({
- "va\0r": "val1"
- }, 'applications/environment/environment'), 'name null')
+ self.assertIn(
+ 'error',
+ self.conf(
+ {"va\0r": "val1"}, 'applications/environment/environment'
+ ),
+ 'name null',
+ )
def test_python_environment_name_equals(self):
self.load('environment')
- self.assertIn('error', self.conf({
- "var=": "val1"
- }, 'applications/environment/environment'), 'name equals')
+ self.assertIn(
+ 'error',
+ self.conf(
+ {"var=": "val1"}, 'applications/environment/environment'
+ ),
+ 'name equals',
+ )
def test_python_environment_value_null(self):
self.load('environment')
- self.assertIn('error', self.conf({
- "var": "\0val"
- }, 'applications/environment/environment'), 'value null')
+ self.assertIn(
+ 'error',
+ self.conf(
+ {"var": "\0val"}, 'applications/environment/environment'
+ ),
+ 'value null',
+ )
def test_python_environment_update(self):
self.load('environment')
- self.conf({
- "var": "val1"
- }, 'applications/environment/environment')
-
- self.assertEqual(self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'var',
- 'Connection': 'close'
- })['body'], 'val1,', 'set')
-
- self.conf({
- "var": "val2"
- }, 'applications/environment/environment')
-
- self.assertEqual(self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'var',
- 'Connection': 'close'
- })['body'], 'val2,', 'update')
+ self.conf({"var": "val1"}, 'applications/environment/environment')
+
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var',
+ 'Connection': 'close',
+ }
+ )['body'],
+ 'val1,',
+ 'set',
+ )
+
+ self.conf({"var": "val2"}, 'applications/environment/environment')
+
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var',
+ 'Connection': 'close',
+ }
+ )['body'],
+ 'val2,',
+ 'update',
+ )
def test_python_environment_replace(self):
self.load('environment')
- self.conf({
- "var1": "val1"
- }, 'applications/environment/environment')
-
- self.assertEqual(self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'var1',
- 'Connection': 'close'
- })['body'], 'val1,', 'set')
-
- self.conf({
- "var2": "val2"
- }, 'applications/environment/environment')
-
- self.assertEqual(self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'var1,var2',
- 'Connection': 'close'
- })['body'], 'val2,', 'replace')
+ self.conf({"var1": "val1"}, 'applications/environment/environment')
+
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var1',
+ 'Connection': 'close',
+ }
+ )['body'],
+ 'val1,',
+ 'set',
+ )
+
+ self.conf({"var2": "val2"}, 'applications/environment/environment')
+
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var1,var2',
+ 'Connection': 'close',
+ }
+ )['body'],
+ 'val2,',
+ 'replace',
+ )
def test_python_environment_clear(self):
self.load('environment')
- self.conf({
- "var1": "val1",
- "var2": "val2"
- }, 'applications/environment/environment')
-
- self.assertEqual(self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'var1,var2',
- 'Connection': 'close'
- })['body'], 'val1,val2,', 'set')
+ self.conf(
+ {"var1": "val1", "var2": "val2"},
+ 'applications/environment/environment',
+ )
+
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var1,var2',
+ 'Connection': 'close',
+ }
+ )['body'],
+ 'val1,val2,',
+ 'set',
+ )
self.conf({}, 'applications/environment/environment')
- self.assertEqual(self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'var1,var2',
- 'Connection': 'close'
- })['body'], '', 'clear')
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var1,var2',
+ 'Connection': 'close',
+ }
+ )['body'],
+ '',
+ 'clear',
+ )
def test_python_environment_replace_default(self):
self.load('environment')
- pwd_default = self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'PWD',
- 'Connection': 'close'
- })['body']
+ pwd_default = self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'PWD',
+ 'Connection': 'close',
+ }
+ )['body']
self.assertGreater(len(pwd_default), 1, 'get default')
- self.conf({
- "PWD": "new/pwd"
- }, 'applications/environment/environment')
+ self.conf({"PWD": "new/pwd"}, 'applications/environment/environment')
- self.assertEqual(self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'PWD',
- 'Connection': 'close'
- })['body'], 'new/pwd,', 'replace default')
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'PWD',
+ 'Connection': 'close',
+ }
+ )['body'],
+ 'new/pwd,',
+ 'replace default',
+ )
self.conf({}, 'applications/environment/environment')
- self.assertEqual(self.get(headers={
- 'Host': 'localhost',
- 'X-Variables': 'PWD',
- 'Connection': 'close'
- })['body'], pwd_default, 'restore default')
+ self.assertEqual(
+ self.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'PWD',
+ 'Connection': 'close',
+ }
+ )['body'],
+ pwd_default,
+ 'restore default',
+ )
+
if __name__ == '__main__':
- TestUnitPythonEnvironment.main()
+ TestPythonEnvironment.main()