Tests: get rid of classes in test files.
Class usage came from the unittest framework and it was always redundant after migration to the pytest. This commit removes classes from files containing tests to make them more readable and understandable.
This commit is contained in:
@@ -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_null():
|
||||
client.load('environment')
|
||||
|
||||
def test_python_environment_name_equals(self):
|
||||
self.load('environment')
|
||||
assert 'error' in client.conf(
|
||||
{"va\0r": "val1"}, 'applications/environment/environment'
|
||||
), 'name null'
|
||||
|
||||
assert 'error' in self.conf(
|
||||
{"var=": "val1"}, 'applications/environment/environment'
|
||||
), 'name equals'
|
||||
|
||||
def test_python_environment_value_null(self):
|
||||
self.load('environment')
|
||||
def test_python_environment_name_equals():
|
||||
client.load('environment')
|
||||
|
||||
assert 'error' in self.conf(
|
||||
{"var": "\0val"}, 'applications/environment/environment'
|
||||
), 'value null'
|
||||
assert 'error' in client.conf(
|
||||
{"var=": "val1"}, 'applications/environment/environment'
|
||||
), 'name equals'
|
||||
|
||||
def test_python_environment_update(self):
|
||||
self.load('environment')
|
||||
|
||||
self.conf({"var": "val1"}, 'applications/environment/environment')
|
||||
def test_python_environment_value_null():
|
||||
client.load('environment')
|
||||
|
||||
assert (
|
||||
self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== 'val1'
|
||||
), 'set'
|
||||
assert 'error' in client.conf(
|
||||
{"var": "\0val"}, 'applications/environment/environment'
|
||||
), 'value null'
|
||||
|
||||
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_update():
|
||||
client.load('environment')
|
||||
|
||||
def test_python_environment_replace(self):
|
||||
self.load('environment')
|
||||
client.conf({"var": "val1"}, 'applications/environment/environment')
|
||||
|
||||
self.conf({"var1": "val1"}, 'applications/environment/environment')
|
||||
assert (
|
||||
client.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== 'val1'
|
||||
), 'set'
|
||||
|
||||
assert (
|
||||
self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var1',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== 'val1'
|
||||
), 'set'
|
||||
client.conf({"var": "val2"}, 'applications/environment/environment')
|
||||
|
||||
self.conf({"var2": "val2"}, 'applications/environment/environment')
|
||||
assert (
|
||||
client.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== 'val2'
|
||||
), 'update'
|
||||
|
||||
assert (
|
||||
self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var1,var2',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== 'val2'
|
||||
), 'replace'
|
||||
|
||||
def test_python_environment_clear(self):
|
||||
self.load('environment')
|
||||
def test_python_environment_replace():
|
||||
client.load('environment')
|
||||
|
||||
self.conf(
|
||||
{"var1": "val1", "var2": "val2"},
|
||||
'applications/environment/environment',
|
||||
)
|
||||
client.conf({"var1": "val1"}, 'applications/environment/environment')
|
||||
|
||||
assert (
|
||||
self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var1,var2',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== 'val1,val2'
|
||||
), 'set'
|
||||
assert (
|
||||
client.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var1',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== 'val1'
|
||||
), 'set'
|
||||
|
||||
self.conf({}, 'applications/environment/environment')
|
||||
client.conf({"var2": "val2"}, 'applications/environment/environment')
|
||||
|
||||
assert (
|
||||
self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var1,var2',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== ''
|
||||
), 'clear'
|
||||
assert (
|
||||
client.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Variables': 'var1,var2',
|
||||
'Connection': 'close',
|
||||
}
|
||||
)['body']
|
||||
== 'val2'
|
||||
), 'replace'
|
||||
|
||||
def test_python_environment_replace_default(self):
|
||||
self.load('environment')
|
||||
|
||||
home_default = self.get(
|
||||
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'
|
||||
|
||||
assert len(home_default) > 1, 'get default'
|
||||
client.conf({}, 'applications/environment/environment')
|
||||
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user