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