14
14
import json
15
15
from tempfile import NamedTemporaryFile
16
16
from pathlib import Path
17
- from typing import Any , TypeVar , NamedTuple , Final , cast
17
+ from typing import Any , TypeVar , NamedTuple , Final , cast , Dict , Type , Set
18
18
from urllib .parse import urlparse
19
19
from parse import parse , with_pattern
20
20
@@ -29,7 +29,7 @@ def cfg(faker: Faker) -> osparc.Configuration:
29
29
30
30
31
31
@pytest .fixture
32
- def osparc_openapi_specs () -> Generator [dict [str , Any ], None , None ]:
32
+ def osparc_openapi_specs () -> Generator [Dict [str , Any ], None , None ]:
33
33
with NamedTemporaryFile (suffix = ".json" ) as file :
34
34
file = Path (file .name )
35
35
file .write_text (json .dumps (osparc .openapi ()))
@@ -67,7 +67,7 @@ class ServerPath(NamedTuple):
67
67
68
68
69
69
@pytest .fixture
70
- def all_server_paths (osparc_openapi_specs : dict [str , Any ]) -> set [ServerPath ]:
70
+ def all_server_paths (osparc_openapi_specs : Dict [str , Any ]) -> Set [ServerPath ]:
71
71
server_paths = set ()
72
72
for path in osparc_openapi_specs ["paths" ]:
73
73
for method in osparc_openapi_specs ["paths" ][path ]:
@@ -89,9 +89,9 @@ def all_server_paths(osparc_openapi_specs: dict[str, Any]) -> set[ServerPath]:
89
89
90
90
@pytest .fixture
91
91
def create_osparc_response_model (
92
- osparc_openapi_specs : dict [str , Any ],
93
- ) -> Callable [[type [T ]], T ]:
94
- def _create_model (model_type : type [T ]) -> T :
92
+ osparc_openapi_specs : Dict [str , Any ],
93
+ ) -> Callable [[Type [T ]], T ]:
94
+ def _create_model (model_type : Type [T ]) -> T :
95
95
schemas = osparc_openapi_specs .get ("components" , {}).get ("schemas" , {})
96
96
example_data = schemas .get (model_type .__name__ , {}).get ("example" )
97
97
error_msg = "Could not extract example data for"
@@ -105,8 +105,8 @@ def _create_model(model_type: type[T]) -> T:
105
105
@pytest .fixture
106
106
def create_server_mock (
107
107
mocker : MockerFixture ,
108
- osparc_openapi_specs : dict [str , Any ],
109
- all_server_paths : set [ServerPath ],
108
+ osparc_openapi_specs : Dict [str , Any ],
109
+ all_server_paths : Set [ServerPath ],
110
110
create_osparc_response_model : Callable [[str ], BaseModel ],
111
111
) -> Callable [[int ], None ]:
112
112
def _mock_server (_status : int ) -> None :
0 commit comments