Cover mapping shapes with tests

This commit is contained in:
Daniyar Yeralin 2020-08-12 14:37:24 -04:00
parent baa5cd2ca6
commit e8c83f100e
2 changed files with 8 additions and 1 deletions

View File

@ -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}"

View File

@ -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):