From 281899fcef10eaf815d90958d49243c5060ffac0 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Tue, 26 Mar 2019 23:38:30 +0300 Subject: Tests: style. --- test/test_python_environment.py | 215 +++++++++++++++++++++++++--------------- 1 file changed, 134 insertions(+), 81 deletions(-) (limited to 'test/test_python_environment.py') diff --git a/test/test_python_environment.py b/test/test_python_environment.py index 71e4d5b7..8ab82089 100644 --- a/test/test_python_environment.py +++ b/test/test_python_environment.py @@ -1,128 +1,181 @@ import unittest import unit -class TestUnitPythonEnvironment(unit.TestUnitApplicationPython): +class TestUnitPythonEnvironment(unit.TestUnitApplicationPython): def setUpClass(): unit.TestUnit().check_modules('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() -- cgit From 19eba1730a1ca839ed62a37f34c204f580d1b653 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Thu, 28 Mar 2019 18:43:13 +0300 Subject: Tests: unit module refactoring. --- test/test_python_environment.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'test/test_python_environment.py') diff --git a/test/test_python_environment.py b/test/test_python_environment.py index 8ab82089..8debadda 100644 --- a/test/test_python_environment.py +++ b/test/test_python_environment.py @@ -1,10 +1,9 @@ -import unittest -import unit +from unit.applications.lang.python import TestApplicationPython -class TestUnitPythonEnvironment(unit.TestUnitApplicationPython): +class TestPythonEnvironment(TestApplicationPython): def setUpClass(): - unit.TestUnit().check_modules('python') + TestApplicationPython().check_modules('python') def test_python_environment_name_null(self): self.load('environment') @@ -178,4 +177,4 @@ class TestUnitPythonEnvironment(unit.TestUnitApplicationPython): if __name__ == '__main__': - TestUnitPythonEnvironment.main() + TestPythonEnvironment.main() -- cgit From af24e4dec453af7e3dcb45347cb59bfcbc037843 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Tue, 9 Apr 2019 16:14:42 +0300 Subject: Tests: simplified module checking. --- test/test_python_environment.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/test_python_environment.py') diff --git a/test/test_python_environment.py b/test/test_python_environment.py index 8debadda..744f4947 100644 --- a/test/test_python_environment.py +++ b/test/test_python_environment.py @@ -2,8 +2,7 @@ from unit.applications.lang.python import TestApplicationPython class TestPythonEnvironment(TestApplicationPython): - def setUpClass(): - TestApplicationPython().check_modules('python') + prerequisites = ['python'] def test_python_environment_name_null(self): self.load('environment') -- cgit