Coverage for tests/test_invalid_path_param.py: 100%
45 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, Tuple 1abcdef
3import pytest 1abcdef
4from fastapi import FastAPI 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/{id}") 1ghijkl
16 def read_items(id: List[Item]): 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/{id}") 1mnopqr
28 def read_items(id: Tuple[Item, Item]): 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/{id}") 1stuvwx
40 def read_items(id: Dict[str, Item]): 1stuvwx
41 pass # pragma: no cover
44def test_invalid_simple_list(): 1abcdef
45 with pytest.raises(AssertionError): 1yzABCD
46 app = FastAPI() 1yzABCD
48 @app.get("/items/{id}") 1yzABCD
49 def read_items(id: list): 1yzABCD
50 pass # pragma: no cover
53def test_invalid_simple_tuple(): 1abcdef
54 with pytest.raises(AssertionError): 1EFGHIJ
55 app = FastAPI() 1EFGHIJ
57 @app.get("/items/{id}") 1EFGHIJ
58 def read_items(id: tuple): 1EFGHIJ
59 pass # pragma: no cover
62def test_invalid_simple_set(): 1abcdef
63 with pytest.raises(AssertionError): 1KLMNOP
64 app = FastAPI() 1KLMNOP
66 @app.get("/items/{id}") 1KLMNOP
67 def read_items(id: set): 1KLMNOP
68 pass # pragma: no cover
71def test_invalid_simple_dict(): 1abcdef
72 with pytest.raises(AssertionError): 1QRSTUV
73 app = FastAPI() 1QRSTUV
75 @app.get("/items/{id}") 1QRSTUV
76 def read_items(id: dict): 1QRSTUV
77 pass # pragma: no cover