from typing import Iterator, cast import pytest import respx from .mock import OwsClientMock def pytest_configure(config: pytest.Config) -> None: config.addinivalue_line( "markers", "ows_client(assert_all_called=False, assert_all_mocked=False): " "configure the ows_client_mock fixture. ", ) @pytest.fixture def ows_client_mock(request: pytest.FixtureRequest) -> Iterator[OwsClientMock]: ows_client_marker = request.node.get_closest_marker("ows_client") ows_client_mock = OwsClientMock() mock_router = ( ows_client_mock.mock if ows_client_marker is None else cast(respx.MockRouter, ows_client_mock.mock(**ows_client_marker.kwargs)) ) with mock_router: yield ows_client_mock