diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2021-11-10 15:43:24 +0000 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2021-11-10 15:43:24 +0000 |
commit | 6961de1d64acf1780ee0d4b08b7c9614e481a338 (patch) | |
tree | 648e4ee6269e3fa33ca35b6bb935c51e77efd729 /test | |
parent | b424a00ec5746884f8ebb1d75b3f0fec0b3a05ff (diff) | |
download | unit-6961de1d64acf1780ee0d4b08b7c9614e481a338.tar.gz unit-6961de1d64acf1780ee0d4b08b7c9614e481a338.tar.bz2 |
Tests: added more tests for "query" routing pattern.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_routing.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/test/test_routing.py b/test/test_routing.py index c031d768..167d2640 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -1342,19 +1342,27 @@ class TestRouting(TestApplicationProto): assert self.get(url='/?a=b&c=d e')['status'] == 200 def test_routes_match_query_array(self): - self.route_match({ - "query": ["foo", "bar"] - }) + self.route_match({"query": ["foo", "bar"]}) - assert self.get()['status'] == 404, 'arr' - assert self.get(url='/?foo')['status'] == 200, 'arr 1' - assert self.get(url='/?bar')['status'] == 200, 'arr 2' + assert self.get()['status'] == 404, 'no args' + assert self.get(url='/?foo')['status'] == 200, 'arg first' + assert self.get(url='/?bar')['status'] == 200, 'arg second' assert 'success' in self.conf_delete( 'routes/0/match/query/1' - ), 'match query array configure 2' + ), 'query array remove second' + + assert self.get(url='/?foo')['status'] == 200, 'still arg first' + assert self.get(url='/?bar')['status'] == 404, 'no arg second' + + self.route_match({"query": ["!f", "foo"]}) + + assert self.get(url='/?f')['status'] == 404, 'negative arg' + assert self.get(url='/?fo')['status'] == 404, 'negative arg 2' + assert self.get(url='/?foo')['status'] == 200, 'negative arg 3' - assert self.get(url='/?bar')['status'] == 404, 'arr 2' + self.route_match({"query": []}) + assert self.get()['status'] == 200, 'empty array' def test_routes_match_query_invalid(self): self.route_match_invalid({"query": [1]}) |