From a2ccb6e31758dc7c9b23c73b97fe2307a8aa6763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Mon, 10 Dec 2018 18:07:19 +0400 Subject: [PATCH] :white_check_mark: Add tests for corner case with query params --- tests/main.py | 5 +++++ tests/test_query.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/tests/main.py b/tests/main.py index 5847a6dc7..0c66c1ff9 100644 --- a/tests/main.py +++ b/tests/main.py @@ -179,6 +179,11 @@ def get_query_type_optional(query: int = None): return f"foo bar {query}" +@app.get("/query/int/default") +def get_query_type_optional(query: int = 10): + return f"foo bar {query}" + + @app.get("/query/param") def get_query_param(query=Query(None)): if query is None: diff --git a/tests/test_query.py b/tests/test_query.py index fc792b843..cd4cc9353 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -36,6 +36,9 @@ response_not_valid_int = { ("/query/int?query=42.5", 422, response_not_valid_int), ("/query/int?query=baz", 422, response_not_valid_int), ("/query/int?not_declared=baz", 422, response_missing), + ("/query/int/default", 200, "foo bar 10"), + ("/query/int/default?query=50", 200, "foo bar 50"), + ("/query/int/default?query=foo", 422, response_not_valid_int), ], ) def test_get_path(path, expected_status, expected_response):