Coverage for tests/test_invalid_sequence_param.py: 100%
32 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from typing import Dict, List, Optional, Tuple 1abcde
3import pytest 1abcde
4from fastapi import FastAPI, Query 1abcde
5from pydantic import BaseModel 1abcde
8def test_invalid_sequence(): 1abcde
9 with pytest.raises(AssertionError): 1abcde
10 app = FastAPI() 1abcde
12 class Item(BaseModel): 1abcde
13 title: str 1abcde
15 @app.get("/items/") 1abcde
16 def read_items(q: List[Item] = Query(default=None)): 1abcde
17 pass # pragma: no cover
20def test_invalid_tuple(): 1abcde
21 with pytest.raises(AssertionError): 1abcde
22 app = FastAPI() 1abcde
24 class Item(BaseModel): 1abcde
25 title: str 1abcde
27 @app.get("/items/") 1abcde
28 def read_items(q: Tuple[Item, Item] = Query(default=None)): 1abcde
29 pass # pragma: no cover
32def test_invalid_dict(): 1abcde
33 with pytest.raises(AssertionError): 1abcde
34 app = FastAPI() 1abcde
36 class Item(BaseModel): 1abcde
37 title: str 1abcde
39 @app.get("/items/") 1abcde
40 def read_items(q: Dict[str, Item] = Query(default=None)): 1abcde
41 pass # pragma: no cover
44def test_invalid_simple_dict(): 1abcde
45 with pytest.raises(AssertionError): 1abcde
46 app = FastAPI() 1abcde
48 class Item(BaseModel): 1abcde
49 title: str 1abcde
51 @app.get("/items/") 1abcde
52 def read_items(q: Optional[dict] = Query(default=None)): 1abcde
53 pass # pragma: no cover