mirror of https://github.com/tiangolo/fastapi.git
Cover mapping shapes with tests
This commit is contained in:
parent
baa5cd2ca6
commit
e8c83f100e
|
|
@ -1,5 +1,5 @@
|
|||
import http
|
||||
from typing import Optional
|
||||
from typing import Optional, Dict
|
||||
|
||||
from fastapi import FastAPI, Path, Query
|
||||
|
||||
|
|
@ -184,6 +184,11 @@ def get_query_param_required(query=Query(...)):
|
|||
return f"foo bar {query}"
|
||||
|
||||
|
||||
@app.get("/query/params")
|
||||
def get_query_params(queries: Dict[str, int] = Query({})):
|
||||
return f"foo bar {queries}"
|
||||
|
||||
|
||||
@app.get("/query/param-required/int")
|
||||
def get_query_param_required_type(query: int = Query(...)):
|
||||
return f"foo bar {query}"
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ response_not_valid_int = {
|
|||
("/query/param-required/int", 422, response_missing),
|
||||
("/query/param-required/int?query=50", 200, "foo bar 50"),
|
||||
("/query/param-required/int?query=foo", 422, response_not_valid_int),
|
||||
("/query/params?first-query=1&second-query=2", 200, "foo bar {'first-query': 1, "
|
||||
"'second-query': 2}")
|
||||
],
|
||||
)
|
||||
def test_get_path(path, expected_status, expected_response):
|
||||
|
|
|
|||
Loading…
Reference in New Issue