Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgaard-itis committed Nov 1, 2024
1 parent 5b47cc2 commit da0965f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions clients/python/test/test_osparc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import json
from tempfile import NamedTemporaryFile
from pathlib import Path
from typing import Any, Type, TypeVar
from typing import Any, TypeVar


@pytest.fixture
Expand Down Expand Up @@ -49,7 +49,7 @@ def dev_mode_enabled(monkeypatch: pytest.MonkeyPatch) -> None:
@pytest.fixture
def create_server_mock(
mocker: MockerFixture,
) -> Generator[Callable[[int, BaseModel], None], None, None]:
) -> Callable[[int, BaseModel], None]:
def _mock_server(_status: int, _body: BaseModel) -> None:
def _sideeffect(
method: str,
Expand All @@ -67,7 +67,7 @@ def _sideeffect(

mocker.patch("urllib3.PoolManager.request", side_effect=_sideeffect)

yield _mock_server
return _mock_server


T = TypeVar("T", bound=BaseModel)
Expand All @@ -76,13 +76,13 @@ def _sideeffect(
@pytest.fixture
def create_osparc_response_model(
osparc_openapi_specs: dict[str, Any],
) -> Generator[Callable[[Type[T]], T], None, None]:
def _create_model(model_type: Type[T]) -> T:
) -> Callable[[type[T]], T]:
def _create_model(model_type: type[T]) -> T:
schemas = osparc_openapi_specs.get("components", {}).get("schemas", {})
example_data = schemas.get(model_type.__name__, {}).get("example", {})
error_msg = "Could not extract example data for"
error_msg += f" '{model_type.__name__}' from openapi specs"
assert example_data, error_msg
return model_type.model_validate(example_data)

yield _create_model
return _create_model

0 comments on commit da0965f

Please sign in to comment.