Coverage for tests/main.py: 100%
124 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
1import http 1abcdef
2from typing import FrozenSet, List, Optional 1abcdef
4from fastapi import FastAPI, Path, Query 1abcdef
6app = FastAPI() 1abcdef
9@app.api_route("/api_route") 1abcdef
10def non_operation(): 1abcdef
11 return {"message": "Hello World"} 1ghijkl
14def non_decorated_route(): 1abcdef
15 return {"message": "Hello World"} 1ghijkl
18app.add_api_route("/non_decorated_route", non_decorated_route) 1abcdef
21@app.get("/text") 1abcdef
22def get_text(): 1abcdef
23 return "Hello World" 1234567
26@app.get("/path/{item_id}") 1abcdef
27def get_id(item_id): 1abcdef
28 return item_id 189!#$%
31@app.get("/path/str/{item_id}") 1abcdef
32def get_str_id(item_id: str): 1abcdef
33 return item_id 1'()*+,-./:;=?@[]^_
36@app.get("/path/int/{item_id}") 1abcdef
37def get_int_id(item_id: int): 1abcdef
38 return item_id 2` { | } ~ ab
41@app.get("/path/float/{item_id}") 1abcdef
42def get_float_id(item_id: float): 1abcdef
43 return item_id 2bbcbdbebfbgbhbibjbkblbmb
46@app.get("/path/bool/{item_id}") 1abcdef
47def get_bool_id(item_id: bool): 1abcdef
48 return item_id 2nbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWb
51@app.get("/path/param/{item_id}") 1abcdef
52def get_path_param_id(item_id: Optional[str] = Path()): 1abcdef
53 return item_id 2XbYbZb0b1b2b
56@app.get("/path/param-minlength/{item_id}") 1abcdef
57def get_path_param_min_length(item_id: str = Path(min_length=3)): 1abcdef
58 return item_id 23b4b5b6b7b8b
61@app.get("/path/param-maxlength/{item_id}") 1abcdef
62def get_path_param_max_length(item_id: str = Path(max_length=3)): 1abcdef
63 return item_id 29b!b#b$b%b'b
66@app.get("/path/param-min_maxlength/{item_id}") 1abcdef
67def get_path_param_min_max_length(item_id: str = Path(max_length=3, min_length=2)): 1abcdef
68 return item_id 2(b)b*b+b,b-b
71@app.get("/path/param-gt/{item_id}") 1abcdef
72def get_path_param_gt(item_id: float = Path(gt=3)): 1abcdef
73 return item_id 2.b/b:b;b=b?b
76@app.get("/path/param-gt0/{item_id}") 1abcdef
77def get_path_param_gt0(item_id: float = Path(gt=0)): 1abcdef
78 return item_id 2@b[b]b^b_b`b
81@app.get("/path/param-ge/{item_id}") 1abcdef
82def get_path_param_ge(item_id: float = Path(ge=3)): 1abcdef
83 return item_id 2{b|b}b~bacbcccdcecfcgchc
86@app.get("/path/param-lt/{item_id}") 1abcdef
87def get_path_param_lt(item_id: float = Path(lt=3)): 1abcdef
88 return item_id 2icjckclcmcnc
91@app.get("/path/param-lt0/{item_id}") 1abcdef
92def get_path_param_lt0(item_id: float = Path(lt=0)): 1abcdef
93 return item_id 2ocpcqcrcsctc
96@app.get("/path/param-le/{item_id}") 1abcdef
97def get_path_param_le(item_id: float = Path(le=3)): 1abcdef
98 return item_id 2ucvcwcxcyczcAcBcCcDcEcFc
101@app.get("/path/param-lt-gt/{item_id}") 1abcdef
102def get_path_param_lt_gt(item_id: float = Path(lt=3, gt=1)): 1abcdef
103 return item_id 2GcHcIcJcKcLc
106@app.get("/path/param-le-ge/{item_id}") 1abcdef
107def get_path_param_le_ge(item_id: float = Path(le=3, ge=1)): 1abcdef
108 return item_id 2McNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c
111@app.get("/path/param-lt-int/{item_id}") 1abcdef
112def get_path_param_lt_int(item_id: int = Path(lt=3)): 1abcdef
113 return item_id 24c5c6c7c8c9c
116@app.get("/path/param-gt-int/{item_id}") 1abcdef
117def get_path_param_gt_int(item_id: int = Path(gt=3)): 1abcdef
118 return item_id 2!c#c$c%c'c(c
121@app.get("/path/param-le-int/{item_id}") 1abcdef
122def get_path_param_le_int(item_id: int = Path(le=3)): 1abcdef
123 return item_id 2)c*c+c,c-c.c/c:c;c=c?c@c
126@app.get("/path/param-ge-int/{item_id}") 1abcdef
127def get_path_param_ge_int(item_id: int = Path(ge=3)): 1abcdef
128 return item_id 2[c]c^c_c`c{c|c}c~cadbdcd
131@app.get("/path/param-lt-gt-int/{item_id}") 1abcdef
132def get_path_param_lt_gt_int(item_id: int = Path(lt=3, gt=1)): 1abcdef
133 return item_id 2ddedfdgdhdid
136@app.get("/path/param-le-ge-int/{item_id}") 1abcdef
137def get_path_param_le_ge_int(item_id: int = Path(le=3, ge=1)): 1abcdef
138 return item_id 2jdkdldmdndodpdqdrdsdtdudvdwdxdydzdAd
141@app.get("/query") 1abcdef
142def get_query(query): 1abcdef
143 return f"foo bar {query}" 2BdCdDdEdFdGd
146@app.get("/query/optional") 1abcdef
147def get_query_optional(query=None): 1abcdef
148 if query is None: 1mnopqrstuvwxyzABCD
149 return "foo bar" 1mnpqstvwyzBC
150 return f"foo bar {query}" 1oruxAD
153@app.get("/query/int") 1abcdef
154def get_query_type(query: int): 1abcdef
155 return f"foo bar {query}" 2HdIdJdKdLdMd
158@app.get("/query/int/optional") 1abcdef
159def get_query_type_optional(query: Optional[int] = None): 1abcdef
160 if query is None: 1EFGHIJKLMNOP
161 return "foo bar" 1EGIKMO
162 return f"foo bar {query}" 1FHJLNP
165@app.get("/query/int/default") 1abcdef
166def get_query_type_int_default(query: int = 10): 1abcdef
167 return f"foo bar {query}" 2NdOdPdQdRdSdTdUdVdWdXdYd
170@app.get("/query/param") 1abcdef
171def get_query_param(query=Query(default=None)): 1abcdef
172 if query is None: 1QRSTUVWXYZ01
173 return "foo bar" 1QSUWY0
174 return f"foo bar {query}" 1RTVXZ1
177@app.get("/query/param-required") 1abcdef
178def get_query_param_required(query=Query()): 1abcdef
179 return f"foo bar {query}" 2Zd0d1d2d3d4d
182@app.get("/query/param-required/int") 1abcdef
183def get_query_param_required_type(query: int = Query()): 1abcdef
184 return f"foo bar {query}" 25d6d7d8d9d!d
187@app.get("/enum-status-code", status_code=http.HTTPStatus.CREATED) 1abcdef
188def get_enum_status_code(): 1abcdef
189 return "foo bar" 2#d$d%d'd(d)d
192@app.get("/query/frozenset") 1abcdef
193def get_query_type_frozenset(query: FrozenSet[int] = Query(...)): 1abcdef
194 return ",".join(map(str, sorted(query))) 2*d+d,d-d.d/d
197@app.get("/query/list") 1abcdef
198def get_query_list(device_ids: List[int] = Query()) -> List[int]: 1abcdef
199 return device_ids 2:d;d=d?d@d[d
202@app.get("/query/list-default") 1abcdef
203def get_query_list_default(device_ids: List[int] = Query(default=[])) -> List[int]: 1abcdef
204 return device_ids 2]d^d_d`d{d|d}d~daebecede