diff options
Diffstat (limited to 'test/test_routing.py')
-rw-r--r-- | test/test_routing.py | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/test/test_routing.py b/test/test_routing.py index 167d2640..fda429a4 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- import pytest -from unit.applications.proto import TestApplicationProto +from unit.applications.lang.python import TestApplicationPython from unit.option import option -class TestRouting(TestApplicationProto): +class TestRouting(TestApplicationPython): prerequisites = {'modules': {'python': 'any'}} def setup_method(self): @@ -12,7 +12,10 @@ class TestRouting(TestApplicationProto): { "listeners": {"*:7080": {"pass": "routes"}}, "routes": [ - {"match": {"method": "GET"}, "action": {"return": 200},} + { + "match": {"method": "GET"}, + "action": {"return": 200}, + } ], "applications": {}, } @@ -289,7 +292,7 @@ class TestRouting(TestApplicationProto): "listeners": {"*:7080": {"pass": "applications/" + path}}, "applications": { name: { - "type": "python", + "type": self.get_application_type(), "processes": {"spare": 0}, "path": option.test_dir + '/python/empty', "working_directory": option.test_dir @@ -313,7 +316,7 @@ class TestRouting(TestApplicationProto): "listeners": {"*:7080": {"pass": "applications/" + path}}, "applications": { name: { - "type": "python", + "type": self.get_application_type(), "processes": {"spare": 0}, "path": option.test_dir + '/python/empty', "working_directory": option.test_dir @@ -333,7 +336,7 @@ class TestRouting(TestApplicationProto): "listeners": {"*:7081": {"pass": "applications/empty"}}, "applications": { "empty": { - "type": "python", + "type": self.get_application_type(), "processes": {"spare": 0}, "path": option.test_dir + '/python/empty', "working_directory": option.test_dir + '/python/empty', @@ -387,7 +390,7 @@ class TestRouting(TestApplicationProto): { "applications": { "app": { - "type": "python", + "type": self.get_application_type(), "processes": {"spare": 0}, "path": "/app", "module": "wsgi", @@ -430,7 +433,7 @@ class TestRouting(TestApplicationProto): { "applications": { "app": { - "type": "python", + "type": self.get_application_type(), "processes": {"spare": 0}, "path": "/app", "module": "wsgi", @@ -476,7 +479,7 @@ class TestRouting(TestApplicationProto): "routes": [{"action": {"proxy": "http://127.0.0.1:7081"}}], "applications": { "app": { - "type": "python", + "type": self.get_application_type(), "processes": {"spare": 0}, "path": "/app", "module": "wsgi", @@ -490,11 +493,15 @@ class TestRouting(TestApplicationProto): 'routes/0/action', ), 'proxy share' assert 'error' in self.conf( - {"proxy": "http://127.0.0.1:7081", "pass": "applications/app",}, + { + "proxy": "http://127.0.0.1:7081", + "pass": "applications/app", + }, 'routes/0/action', ), 'proxy pass' assert 'error' in self.conf( - {"share": temp_dir, "pass": "applications/app"}, 'routes/0/action', + {"share": temp_dir, "pass": "applications/app"}, + 'routes/0/action', ), 'share pass' def test_routes_rules_two(self): @@ -693,7 +700,8 @@ class TestRouting(TestApplicationProto): assert self.post()['status'] == 404, 'routes edit POST' assert 'success' in self.conf_post( - {"match": {"method": "POST"}, "action": {"return": 200}}, 'routes', + {"match": {"method": "POST"}, "action": {"return": 200}}, + 'routes', ), 'routes edit configure 2' assert 'GET' == self.conf_get( 'routes/0/match/method' @@ -733,7 +741,8 @@ class TestRouting(TestApplicationProto): assert self.post()['status'] == 404, 'routes edit POST 5' assert 'success' in self.conf_post( - {"match": {"method": "POST"}, "action": {"return": 200}}, 'routes', + {"match": {"method": "POST"}, "action": {"return": 200}}, + 'routes', ), 'routes edit configure 6' assert self.get()['status'] == 404, 'routes edit GET 6' @@ -1042,9 +1051,7 @@ class TestRouting(TestApplicationProto): def check_headers(hds): hds = dict({"Host": "localhost", "Connection": "close"}, **hds) - assert ( - self.get(headers=hds)['status'] == 200 - ), 'headers array match' + assert self.get(headers=hds)['status'] == 200, 'headers array match' def check_headers_404(hds): hds = dict({"Host": "localhost", "Connection": "close"}, **hds) @@ -1262,9 +1269,7 @@ class TestRouting(TestApplicationProto): self.get(url='/?foo=bar&blah=test')['status'] == 200 ), 'multiple 2' assert self.get(url='/?foo=bar&blah')['status'] == 404, 'multiple 3' - assert ( - self.get(url='/?foo=bar&blah=tes')['status'] == 404 - ), 'multiple 4' + assert self.get(url='/?foo=bar&blah=tes')['status'] == 404, 'multiple 4' assert ( self.get(url='/?foo=b%61r&bl%61h=t%65st')['status'] == 200 ), 'multiple 5' @@ -1494,9 +1499,7 @@ class TestRouting(TestApplicationProto): sock, port = sock_port() sock2, port2 = sock_port() - self.route_match( - {"source": "127.0.0.1:" + str(port) + "-" + str(port)} - ) + self.route_match({"source": "127.0.0.1:" + str(port) + "-" + str(port)}) assert self.get(sock=sock)['status'] == 200, 'range single' assert self.get(sock=sock2)['status'] == 404, 'range single 2' @@ -1544,7 +1547,10 @@ class TestRouting(TestApplicationProto): def test_routes_source_addr(self): assert 'success' in self.conf( - {"*:7080": {"pass": "routes"}, "[::1]:7081": {"pass": "routes"},}, + { + "*:7080": {"pass": "routes"}, + "[::1]:7081": {"pass": "routes"}, + }, 'listeners', ), 'source listeners configure' @@ -1650,7 +1656,10 @@ class TestRouting(TestApplicationProto): def test_routes_source_cidr(self): assert 'success' in self.conf( - {"*:7080": {"pass": "routes"}, "[::1]:7081": {"pass": "routes"},}, + { + "*:7080": {"pass": "routes"}, + "[::1]:7081": {"pass": "routes"}, + }, 'listeners', ), 'source listeners configure' |