summaryrefslogtreecommitdiffhomepage
path: root/test/test_configuration.py
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2018-01-17 15:52:01 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2018-01-17 15:52:01 +0300
commita949c2f08818bb9a8c8e54ed35e2a4a95a07acd3 (patch)
tree736d44e5f2ec188c47312d8cd9e2310312f00bff /test/test_configuration.py
parent37a713c217d132df89dc3726c33e4e96456d4433 (diff)
downloadunit-a949c2f08818bb9a8c8e54ed35e2a4a95a07acd3.tar.gz
unit-a949c2f08818bb9a8c8e54ed35e2a4a95a07acd3.tar.bz2
Tests: using LF line ending for test files.
Diffstat (limited to 'test/test_configuration.py')
-rw-r--r--test/test_configuration.py292
1 files changed, 146 insertions, 146 deletions
diff --git a/test/test_configuration.py b/test/test_configuration.py
index 8a3612a8..f10a5e8b 100644
--- a/test/test_configuration.py
+++ b/test/test_configuration.py
@@ -1,146 +1,146 @@
-import unittest
-import unit
-
-class TestUnitConfiguration(unit.TestUnitControl):
-
- def setUpClass():
- unit.TestUnit().check_modules('python')
-
- def test_json(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')
-
- self.assertTry('assertIn', 'negative workers', 'error',
- self.put('/applications', """
- {
- "app": {
- "type": "python",
- "workers": -1,
- "path": "/app",
- "module": "wsgi"
- }
- }
- """))
-
- self.assertTry('assertIn', 'application type only', 'error',
- self.put('/applications', """
- {
- "app": {
- "type": "python"
- }
- }
- """))
-
- self.assertIn('error', self.put('/applications', """
- {
- app": {
- "type": "python",
- "workers": 1,
- "path": "/app",
- "module": "wsgi"
- }
- }
- """), 'applications miss quote')
-
- self.assertIn('error', self.put('/applications', """
- {
- "app" {
- "type": "python",
- "workers": 1,
- "path": "/app",
- "module": "wsgi"
- }
- }
- """), 'applications miss colon')
-
- self.assertIn('error', self.put('/applications', """
- {
- "app": {
- "type": "python"
- "workers": 1,
- "path": "/app",
- "module": "wsgi"
- }
- }
- """), 'applications miss comma')
-
- self.assertIn('success', self.put('/applications', b'{ \n\r\t}'),
- 'skip space')
-
- self.assertIn('success', self.put('/applications', """
- {
- "app": {
- "type": "python",
- "workers": 1,
- "path": "../app",
- "module": "wsgi"
- }
- }
- """), 'relative path')
-
- self.assertIn('success', self.put('/applications', b"""
- {
- "ap\u0070": {
- "type": "\u0070ython",
- "workers": 1,
- "path": "\u002Fapp",
- "module": "wsgi"
- }
- }
- """), 'unicode')
-
- self.assertIn('success', self.put('/applications', """
- {
- "приложение": {
- "type": "python",
- "workers": 1,
- "path": "/app",
- "module": "wsgi"
- }
- }
- """), 'unicode 2')
-
- self.assertIn('error', self.put('/applications', b"""
- {
- "app": {
- "type": "python",
- "workers": \u0031,
- "path": "/app",
- "module": "wsgi"
- }
- }
- """), 'unicode number')
-
- 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', """
- {
- "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')
-
-if __name__ == '__main__':
- unittest.main()
+import unittest
+import unit
+
+class TestUnitConfiguration(unit.TestUnitControl):
+
+ def setUpClass():
+ unit.TestUnit().check_modules('python')
+
+ def test_json(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')
+
+ self.assertTry('assertIn', 'negative workers', 'error',
+ self.put('/applications', """
+ {
+ "app": {
+ "type": "python",
+ "workers": -1,
+ "path": "/app",
+ "module": "wsgi"
+ }
+ }
+ """))
+
+ self.assertTry('assertIn', 'application type only', 'error',
+ self.put('/applications', """
+ {
+ "app": {
+ "type": "python"
+ }
+ }
+ """))
+
+ self.assertIn('error', self.put('/applications', """
+ {
+ app": {
+ "type": "python",
+ "workers": 1,
+ "path": "/app",
+ "module": "wsgi"
+ }
+ }
+ """), 'applications miss quote')
+
+ self.assertIn('error', self.put('/applications', """
+ {
+ "app" {
+ "type": "python",
+ "workers": 1,
+ "path": "/app",
+ "module": "wsgi"
+ }
+ }
+ """), 'applications miss colon')
+
+ self.assertIn('error', self.put('/applications', """
+ {
+ "app": {
+ "type": "python"
+ "workers": 1,
+ "path": "/app",
+ "module": "wsgi"
+ }
+ }
+ """), 'applications miss comma')
+
+ self.assertIn('success', self.put('/applications', b'{ \n\r\t}'),
+ 'skip space')
+
+ self.assertIn('success', self.put('/applications', """
+ {
+ "app": {
+ "type": "python",
+ "workers": 1,
+ "path": "../app",
+ "module": "wsgi"
+ }
+ }
+ """), 'relative path')
+
+ self.assertIn('success', self.put('/applications', b"""
+ {
+ "ap\u0070": {
+ "type": "\u0070ython",
+ "workers": 1,
+ "path": "\u002Fapp",
+ "module": "wsgi"
+ }
+ }
+ """), 'unicode')
+
+ self.assertIn('success', self.put('/applications', """
+ {
+ "приложение": {
+ "type": "python",
+ "workers": 1,
+ "path": "/app",
+ "module": "wsgi"
+ }
+ }
+ """), 'unicode 2')
+
+ self.assertIn('error', self.put('/applications', b"""
+ {
+ "app": {
+ "type": "python",
+ "workers": \u0031,
+ "path": "/app",
+ "module": "wsgi"
+ }
+ }
+ """), 'unicode number')
+
+ 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', """
+ {
+ "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')
+
+if __name__ == '__main__':
+ unittest.main()