]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
:white_check_mark: Add tests for corner case with query params
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 10 Dec 2018 14:07:19 +0000 (18:07 +0400)
committerSebastián Ramírez <tiangolo@gmail.com>
Mon, 10 Dec 2018 14:07:19 +0000 (18:07 +0400)
tests/main.py
tests/test_query.py

index 5847a6dc7d6cabebb055434d47e3076a9ba8d05b..0c66c1ff9a7f074b96541b4257a161b5106ea61b 100644 (file)
@@ -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:
index fc792b84313626c47f1af2871de2dd88c8694179..cd4cc9353b988c256b8a709d7b8651e844d5e3e9 100644 (file)
@@ -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):