1
+ import sys
1
2
from flask_parameter_validation .docs_blueprint import get_route_docs
2
3
3
4
def test_http_ok (client ):
4
5
r = client .get ("/docs/" )
5
6
assert r .status_code == 200
6
7
r = client .get ("/docs/json" )
7
8
assert r .status_code == 200
8
-
9
+ import sys
9
10
def test_routes_added (app ):
10
11
routes = []
11
12
for rule in app .url_map .iter_rules ():
@@ -20,18 +21,19 @@ def test_doc_types_of_default(app):
20
21
"query" : "Query" ,
21
22
"route" : "Route"
22
23
}
24
+ optional_as_str = "Optional" if sys .version_info >= (3 ,10 ) else "Union"
23
25
types = {
24
- "bool" : {"opt" : "Optional [bool, NoneType]" , "n_opt" : "bool" },
25
- "date" : {"opt" : "Optional [date, NoneType]" , "n_opt" : "date" },
26
- "datetime" : {"opt" : "Optional [datetime, NoneType]" , "n_opt" : "datetime" },
27
- "dict" : {"opt" : "Optional [dict, NoneType]" , "n_opt" : "dict" },
28
- "float" : {"opt" : "Optional [float, NoneType]" , "n_opt" : "float" },
29
- "int" : {"opt" : "Optional [int, NoneType]" , "n_opt" : "int" },
30
- "int_enum" : {"opt" : "Optional [Binary, NoneType]" , "n_opt" : "Binary" },
31
- "list" : {"opt" : "Optional [List[int], NoneType]" , "n_opt" : "List[str]" },
32
- "str" : {"opt" : "Optional [str, NoneType]" , "n_opt" : "str" },
33
- "str_enum" : {"opt" : "Optional [Fruits, NoneType]" , "n_opt" : "Fruits" },
34
- "time" : {"opt" : "Optional [time, NoneType]" , "n_opt" : "time" },
26
+ "bool" : {"opt" : f" { optional_as_str } [bool, NoneType]" , "n_opt" : "bool" },
27
+ "date" : {"opt" : f" { optional_as_str } [date, NoneType]" , "n_opt" : "date" },
28
+ "datetime" : {"opt" : f" { optional_as_str } [datetime, NoneType]" , "n_opt" : "datetime" },
29
+ "dict" : {"opt" : f" { optional_as_str } [dict, NoneType]" , "n_opt" : "dict" },
30
+ "float" : {"opt" : f" { optional_as_str } [float, NoneType]" , "n_opt" : "float" },
31
+ "int" : {"opt" : f" { optional_as_str } [int, NoneType]" , "n_opt" : "int" },
32
+ "int_enum" : {"opt" : f" { optional_as_str } [Binary, NoneType]" , "n_opt" : "Binary" },
33
+ "list" : {"opt" : f" { optional_as_str } [List[int], NoneType]" , "n_opt" : "List[str]" },
34
+ "str" : {"opt" : f" { optional_as_str } [str, NoneType]" , "n_opt" : "str" },
35
+ "str_enum" : {"opt" : f" { optional_as_str } [Fruits, NoneType]" , "n_opt" : "Fruits" },
36
+ "time" : {"opt" : f" { optional_as_str } [time, NoneType]" , "n_opt" : "time" },
35
37
"union" : {"opt" : "Union[bool, int, NoneType]" , "n_opt" : "Union[bool, int]" }
36
38
}
37
39
route_unsupported_types = ["dict" , "list" ]
0 commit comments