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