Commit 31552279 authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

fix: call SRM's location query under /internal

Every other SRM call in this client targets /internal/...; retrieve_location
omitted the prefix, so the request never reached the endpoint.

SRM serves its whole internal API under that base (srm/interface-contract.md
"Base path: http://srm:8081/internal"

), and oeg/interface-contract.md K.3 lists
this route as /internal/network-queries/location.

The failure was quiet rather than loud: SRM answers 404 for the unknown route,
_request turns any 404 into NotFoundException, and retrieve_location relabels
that as IDENTIFIER_NOT_FOUND. A misrouted call therefore surfaced to the caller
as a plausible "no such device" rather than as a broken deployment.

No test observed the request path -- the mock transport answers any URL -- so
the suite stayed green. Adding that assertion.

Co-Authored-By: default avatarClaude Opus 5 <noreply@anthropic.com>
parent de444148
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ class SRMClient:
        try:
            data = await self._request(
                "POST",
                "/network-queries/location",
                "/internal/network-queries/location",
                json=query.model_dump(mode="json", exclude_none=True),
                headers=headers,
            )
+26 −0
Original line number Diff line number Diff line
@@ -225,3 +225,29 @@ async def test_location_query_body_omits_none_parameters(

    assert sent["parameters"] == {}
    assert result.area.radius_m == 800


async def test_location_query_targets_the_internal_base_path(
    monkeypatch: pytest.MonkeyPatch,
) -> None:
    called: dict[str, str] = {}

    def handler(request: httpx.Request) -> httpx.Response:
        called["path"] = request.url.path
        return httpx.Response(
            200,
            json={
                "last_location_time": "2023-10-17T13:18:23.682Z",
                "area": {
                    "area_type": "circle",
                    "center": {"latitude": 45.75, "longitude": 4.86},
                    "radius_m": 800,
                },
            },
        )

    client = _client(monkeypatch, handler)

    await client.retrieve_location(_location_query())

    assert called["path"] == "/internal/network-queries/location"