diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2021-05-24 04:33:42 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2021-05-24 04:33:42 +0100 |
commit | d6439002371d0bc73183c9d3d28df4f62ce0b972 (patch) | |
tree | 52dae430abdde798589a7aa7944e7c79b69b5fbe /test | |
parent | 539551c89f4028ed70e5881400fc9151af3d12e8 (diff) | |
download | unit-d6439002371d0bc73183c9d3d28df4f62ce0b972.tar.gz unit-d6439002371d0bc73183c9d3d28df4f62ce0b972.tar.bz2 |
Tests: minor fixes.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_routing.py | 90 | ||||
-rw-r--r-- | test/test_share_mount.py | 12 |
2 files changed, 25 insertions, 77 deletions
diff --git a/test/test_routing.py b/test/test_routing.py index 7392c1ab..eaa0a134 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -1041,83 +1041,31 @@ class TestRouting(TestApplicationProto): } ) + def check_headers(hds): + hds = dict({"Host": "localhost", "Connection": "close"}, **hds) + assert ( + self.get(headers=hds)['status'] == 200 + ), 'headers array match' + + def check_headers_404(hds): + hds = dict({"Host": "localhost", "Connection": "close"}, **hds) + assert ( + self.get(headers=hds)['status'] == 404 + ), 'headers array no match' + assert self.get()['status'] == 404, 'match headers array' - assert ( - self.get( - headers={ - "Host": "localhost", - "x-header1": "foo123", - "Connection": "close", - } - )['status'] - == 200 - ), 'match headers array 2' - assert ( - self.get( - headers={ - "Host": "localhost", - "x-header2": "bar", - "Connection": "close", - } - )['status'] - == 200 - ), 'match headers array 3' - assert ( - self.get( - headers={ - "Host": "localhost", - "x-header3": "bar", - "Connection": "close", - } - )['status'] - == 200 - ), 'match headers array 4' - assert ( - self.get( - headers={ - "Host": "localhost", - "x-header1": "bar", - "Connection": "close", - } - )['status'] - == 404 - ), 'match headers array 5' - assert ( - self.get( - headers={ - "Host": "localhost", - "x-header1": "bar", - "x-header4": "foo", - "Connection": "close", - } - )['status'] - == 200 - ), 'match headers array 6' + check_headers({"x-header1": "foo123"}) + check_headers({"x-header2": "bar"}) + check_headers({"x-header3": "bar"}) + check_headers_404({"x-header1": "bar"}) + check_headers({"x-header1": "bar", "x-header4": "foo"}) assert 'success' in self.conf_delete( 'routes/0/match/headers/1' ), 'match headers array configure 2' - assert ( - self.get( - headers={ - "Host": "localhost", - "x-header2": "bar", - "Connection": "close", - } - )['status'] - == 404 - ), 'match headers array 7' - assert ( - self.get( - headers={ - "Host": "localhost", - "x-header3": "foo", - "Connection": "close", - } - )['status'] - == 200 - ), 'match headers array 8' + check_headers_404({"x-header2": "bar"}) + check_headers({"x-header3": "foo"}) def test_routes_match_arguments(self): self.route_match({"arguments": {"foo": "bar"}}) diff --git a/test/test_share_mount.py b/test/test_share_mount.py index f46e1279..f22fbe75 100644 --- a/test/test_share_mount.py +++ b/test/test_share_mount.py @@ -70,8 +70,8 @@ class TestShareMount(TestApplicationProto): skip_alert(r'opening.*failed') resp = self.get(url='/mount/') - resp['status'] == 200 - resp['body'] == 'mount' + assert resp['status'] == 200 + assert resp['body'] == 'mount' assert 'success' in self.conf( {"share": temp_dir + "/assets/dir", "traverse_mounts": False}, @@ -86,8 +86,8 @@ class TestShareMount(TestApplicationProto): ), 'configure mount enable' resp = self.get(url='/mount/') - resp['status'] == 200 - resp['body'] == 'mount' + assert resp['status'] == 200 + assert resp['body'] == 'mount' def test_share_mount_two_blocks(self, temp_dir, skip_alert): skip_alert(r'opening.*failed') @@ -128,7 +128,7 @@ class TestShareMount(TestApplicationProto): 'routes/0/action', ), 'configure chroot mount default' - self.get(url='/mount/')['status'] == 200, 'chroot' + assert self.get(url='/mount/')['status'] == 200, 'chroot' assert 'success' in self.conf( { @@ -139,4 +139,4 @@ class TestShareMount(TestApplicationProto): 'routes/0/action', ), 'configure chroot mount disable' - self.get(url='/mount/')['status'] == 403, 'chroot mount' + assert self.get(url='/mount/')['status'] == 403, 'chroot mount' |