summaryrefslogtreecommitdiffhomepage
path: root/test/test_python_environment.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_python_environment.py')
-rw-r--r--test/test_python_environment.py295
1 files changed, 151 insertions, 144 deletions
diff --git a/test/test_python_environment.py b/test/test_python_environment.py
index a57e3760..6aa02c94 100644
--- a/test/test_python_environment.py
+++ b/test/test_python_environment.py
@@ -1,155 +1,162 @@
-from unit.applications.lang.python import TestApplicationPython
+from unit.applications.lang.python import ApplicationPython
prerequisites = {'modules': {'python': 'any'}}
+client = ApplicationPython()
-class TestPythonEnvironment(TestApplicationPython):
- def test_python_environment_name_null(self):
- self.load('environment')
-
- assert 'error' in self.conf(
- {"va\0r": "val1"}, 'applications/environment/environment'
- ), 'name null'
-
- def test_python_environment_name_equals(self):
- self.load('environment')
-
- assert 'error' in self.conf(
- {"var=": "val1"}, 'applications/environment/environment'
- ), 'name equals'
-
- def test_python_environment_value_null(self):
- self.load('environment')
-
- assert 'error' in 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')
-
- assert (
- self.get(
- headers={
- 'Host': 'localhost',
- 'X-Variables': 'var',
- 'Connection': 'close',
- }
- )['body']
- == 'val1'
- ), 'set'
-
- self.conf({"var": "val2"}, 'applications/environment/environment')
-
- assert (
- 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')
-
- assert (
- self.get(
- headers={
- 'Host': 'localhost',
- 'X-Variables': 'var1',
- 'Connection': 'close',
- }
- )['body']
- == 'val1'
- ), 'set'
-
- self.conf({"var2": "val2"}, 'applications/environment/environment')
-
- assert (
- 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',
- )
-
- assert (
- self.get(
- headers={
- 'Host': 'localhost',
- 'X-Variables': 'var1,var2',
- 'Connection': 'close',
- }
- )['body']
- == 'val1,val2'
- ), 'set'
-
- self.conf({}, 'applications/environment/environment')
-
- assert (
- self.get(
- headers={
- 'Host': 'localhost',
- 'X-Variables': 'var1,var2',
- 'Connection': 'close',
- }
- )['body']
- == ''
- ), 'clear'
-
- def test_python_environment_replace_default(self):
- self.load('environment')
-
- home_default = self.get(
+
+def test_python_environment_name_null():
+ client.load('environment')
+
+ assert 'error' in client.conf(
+ {"va\0r": "val1"}, 'applications/environment/environment'
+ ), 'name null'
+
+
+def test_python_environment_name_equals():
+ client.load('environment')
+
+ assert 'error' in client.conf(
+ {"var=": "val1"}, 'applications/environment/environment'
+ ), 'name equals'
+
+
+def test_python_environment_value_null():
+ client.load('environment')
+
+ assert 'error' in client.conf(
+ {"var": "\0val"}, 'applications/environment/environment'
+ ), 'value null'
+
+
+def test_python_environment_update():
+ client.load('environment')
+
+ client.conf({"var": "val1"}, 'applications/environment/environment')
+
+ assert (
+ client.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var',
+ 'Connection': 'close',
+ }
+ )['body']
+ == 'val1'
+ ), 'set'
+
+ client.conf({"var": "val2"}, 'applications/environment/environment')
+
+ assert (
+ client.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var',
+ 'Connection': 'close',
+ }
+ )['body']
+ == 'val2'
+ ), 'update'
+
+
+def test_python_environment_replace():
+ client.load('environment')
+
+ client.conf({"var1": "val1"}, 'applications/environment/environment')
+
+ assert (
+ client.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var1',
+ 'Connection': 'close',
+ }
+ )['body']
+ == 'val1'
+ ), 'set'
+
+ client.conf({"var2": "val2"}, 'applications/environment/environment')
+
+ assert (
+ client.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var1,var2',
+ 'Connection': 'close',
+ }
+ )['body']
+ == 'val2'
+ ), 'replace'
+
+
+def test_python_environment_clear():
+ client.load('environment')
+
+ client.conf(
+ {"var1": "val1", "var2": "val2"},
+ 'applications/environment/environment',
+ )
+
+ assert (
+ client.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var1,var2',
+ 'Connection': 'close',
+ }
+ )['body']
+ == 'val1,val2'
+ ), 'set'
+
+ client.conf({}, 'applications/environment/environment')
+
+ assert (
+ client.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'var1,var2',
+ 'Connection': 'close',
+ }
+ )['body']
+ == ''
+ ), 'clear'
+
+
+def test_python_environment_replace_default():
+ client.load('environment')
+
+ home_default = client.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'HOME',
+ 'Connection': 'close',
+ }
+ )['body']
+
+ assert len(home_default) > 1, 'get default'
+
+ client.conf({"HOME": "/"}, 'applications/environment/environment')
+
+ assert (
+ client.get(
headers={
'Host': 'localhost',
'X-Variables': 'HOME',
'Connection': 'close',
}
)['body']
+ == '/'
+ ), 'replace default'
+
+ client.conf({}, 'applications/environment/environment')
- assert len(home_default) > 1, 'get default'
-
- self.conf({"HOME": "/"}, 'applications/environment/environment')
-
- assert (
- self.get(
- headers={
- 'Host': 'localhost',
- 'X-Variables': 'HOME',
- 'Connection': 'close',
- }
- )['body']
- == '/'
- ), 'replace default'
-
- self.conf({}, 'applications/environment/environment')
-
- assert (
- self.get(
- headers={
- 'Host': 'localhost',
- 'X-Variables': 'HOME',
- 'Connection': 'close',
- }
- )['body']
- == home_default
- ), 'restore default'
+ assert (
+ client.get(
+ headers={
+ 'Host': 'localhost',
+ 'X-Variables': 'HOME',
+ 'Connection': 'close',
+ }
+ )['body']
+ == home_default
+ ), 'restore default'