diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2018-01-24 15:43:04 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2018-01-24 15:43:04 +0300 |
commit | 331514fcf75dde719267efc970979524312d268e (patch) | |
tree | 6a283e37438734661d4afad0e08e95ad6cb1b1f9 /test/test_configuration.py | |
parent | 771e9d3cc3a59585a3d8a6ae2baddb18f335c3dd (diff) | |
download | unit-331514fcf75dde719267efc970979524312d268e.tar.gz unit-331514fcf75dde719267efc970979524312d268e.tar.bz2 |
Tests: using "expectedFailure" decorator instead of assertTry().
Diffstat (limited to 'test/test_configuration.py')
-rw-r--r-- | test/test_configuration.py | 187 |
1 files changed, 128 insertions, 59 deletions
diff --git a/test/test_configuration.py b/test/test_configuration.py index f10a5e8b..b4fac30e 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -6,17 +6,54 @@ class TestUnitConfiguration(unit.TestUnitControl): def setUpClass(): unit.TestUnit().check_modules('python') - def test_json(self): + def test_json_leading_zero(self): self.assertIn('error', self.put('/', '00'), 'leading zero') - def test_json_applications(self): - self.assertIn('error', self.put('/applications', '"{}"'), - 'applications string') - self.assertIn('error', self.put('/applications', '{'), - 'applications miss brace') + def test_json_unicode(self): + self.assertIn('success', self.put('/applications', b""" + { + "ap\u0070": { + "type": "\u0070ython", + "workers": 1, + "path": "\u002Fapp", + "module": "wsgi" + } + } + """), 'unicode') - self.assertTry('assertIn', 'negative workers', 'error', - self.put('/applications', """ + def test_json_unicode_2(self): + self.assertIn('success', self.put('/applications', """ + { + "приложение": { + "type": "python", + "workers": 1, + "path": "/app", + "module": "wsgi" + } + } + """), 'unicode 2') + + def test_json_unicode_number(self): + self.assertIn('error', self.put('/applications', b""" + { + "app": { + "type": "python", + "workers": \u0031, + "path": "/app", + "module": "wsgi" + } + } + """), 'unicode number') + + def test_applications_open_brace(self): + self.assertIn('error', self.put('/applications', '{'), 'open brace') + + def test_applications_string(self): + self.assertIn('error', self.put('/applications', '"{}"'), 'string') + + @unittest.expectedFailure + def test_negative_workers(self): + self.assertIn('error', self.put('/applications', """ { "app": { "type": "python", @@ -25,17 +62,19 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """)) + """), 'negative workers') - self.assertTry('assertIn', 'application type only', 'error', - self.put('/applications', """ + @unittest.expectedFailure + def test_applications_type_only(self): + self.assertIn('error', self.put('/applications', """ { "app": { "type": "python" } } - """)) + """), 'type only') + def test_applications_miss_quote(self): self.assertIn('error', self.put('/applications', """ { app": { @@ -45,8 +84,9 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """), 'applications miss quote') + """), 'miss quote') + def test_applications_miss_colon(self): self.assertIn('error', self.put('/applications', """ { "app" { @@ -56,8 +96,9 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """), 'applications miss colon') + """), 'miss colon') + def test_applications_miss_comma(self): self.assertIn('error', self.put('/applications', """ { "app": { @@ -67,11 +108,13 @@ class TestUnitConfiguration(unit.TestUnitControl): "module": "wsgi" } } - """), 'applications miss comma') + """), 'miss comma') + def test_applications_skip_spaces(self): self.assertIn('success', self.put('/applications', b'{ \n\r\t}'), - 'skip space') + 'skip spaces') + def test_applications_relative_path(self): self.assertIn('success', self.put('/applications', """ { "app": { @@ -83,64 +126,90 @@ class TestUnitConfiguration(unit.TestUnitControl): } """), 'relative path') - self.assertIn('success', self.put('/applications', b""" + @unittest.expectedFailure + def test_listeners_empty(self): + self.assertIn('error', self.put('/listeners', '{"*:7080":{}}'), + 'listener empty') + + def test_listeners_no_app(self): + self.assertIn('error', self.put('/listeners', + '{"*:7080":{"application":"app"}}'), 'listeners no app') + + def test_listeners_wildcard(self): + self.assertIn('success', self.put('/', """ { - "ap\u0070": { - "type": "\u0070ython", - "workers": 1, - "path": "\u002Fapp", - "module": "wsgi" + "listeners": { + "*:7080": { + "application":"app" + } + }, + "applications": { + "app": { + "type": "python", + "workers": 1, + "path": "/app", + "module": "wsgi" + } } } - """), 'unicode') + """), 'listeners wildcard') - self.assertIn('success', self.put('/applications', """ + def test_listeners_explicit(self): + self.assertIn('success', self.put('/', """ { - "приложение": { - "type": "python", - "workers": 1, - "path": "/app", - "module": "wsgi" + "listeners": { + "127.0.0.1:7081": { + "application":"app" + } + }, + "applications": { + "app": { + "type": "python", + "workers": 1, + "path": "/app", + "module": "wsgi" + } } } - """), 'unicode 2') + """), 'explicit') - self.assertIn('error', self.put('/applications', b""" + def test_listeners_explicit_ipv6(self): + self.assertIn('success', self.put('/', """ { - "app": { - "type": "python", - "workers": \u0031, - "path": "/app", - "module": "wsgi" + "listeners": { + "[::1]:7082": { + "application":"app" + } + }, + "applications": { + "app": { + "type": "python", + "workers": 1, + "path": "/app", + "module": "wsgi" + } } } - """), 'unicode number') + """), 'explicit ipv6') - def test_json_listeners(self): - self.assertTry('assertIn', 'listener empty', 'error', - self.put('/listeners', '{"*:7080":{}}')) - self.assertIn('error', self.put('/listeners', - '{"*:7080":{"application":"app"}}'), 'listeners no app') - - self.put('/applications', """ + def test_listeners_no_port(self): + self.assertIn('success', self.put('/', """ { - "app": { - "type": "python", - "workers": 1, - "path": "/app", - "module": "wsgi" + "listeners": { + "[::1]:7082": { + "application":"app" + } + }, + "applications": { + "app": { + "type": "python", + "workers": 1, + "path": "/app", + "module": "wsgi" + } } } - """) - - self.assertIn('success', self.put('/listeners', - '{"*:7080":{"application":"app"}}'), 'listeners wildcard') - self.assertIn('success', self.put('/listeners', - '{"127.0.0.1:7081":{"application":"app"}}'), 'listeners explicit') - self.assertIn('success', self.put('/listeners', - '{"[::1]:7082":{"application":"app"}}'), 'listeners explicit ipv6') - self.assertIn('error', self.put('/listeners', - '{"127.0.0.1":{"application":"app"}}'), 'listeners no port') + """), 'no port') if __name__ == '__main__': unittest.main() |