import asyncio import httpx from app.fixtures.ofl import OflClient def test_fetch_fixture_uses_json_endpoint(monkeypatch) -> None: requested_urls: list[str] = [] class FakeResponse: def raise_for_status(self) -> None: return None def json(self) -> dict[str, object]: return {"name": "LED Bar-3 HCL Bar", "modes": []} class FakeAsyncClient: def __init__(self, *args, **kwargs) -> None: pass async def __aenter__(self) -> "FakeAsyncClient": return self async def __aexit__(self, exc_type, exc, tb) -> None: return None async def get(self, url: str) -> FakeResponse: requested_urls.append(url) return FakeResponse() monkeypatch.setattr(httpx, "AsyncClient", FakeAsyncClient) payload = asyncio.run(OflClient().fetch_fixture("eurolite", "led-bar-3-hcl-bar")) assert payload["name"] == "LED Bar-3 HCL Bar" assert requested_urls == ["https://open-fixture-library.org/eurolite/led-bar-3-hcl-bar.json"]