Refactor geo re-resolve endpoint into geo_service and add typed response
This commit is contained in:
@@ -48,7 +48,9 @@ async def geo_client(tmp_path: Path) -> AsyncClient: # type: ignore[misc]
|
||||
|
||||
transport = ASGITransport(app=app)
|
||||
async with AsyncClient(transport=transport, base_url="http://test") as ac:
|
||||
await ac.post("/api/setup", json=_SETUP_PAYLOAD)
|
||||
setup_payload = _SETUP_PAYLOAD.copy()
|
||||
setup_payload["database_path"] = settings.database_path
|
||||
await ac.post("/api/setup", json=setup_payload)
|
||||
login = await ac.post(
|
||||
"/api/auth/login",
|
||||
json={"password": _SETUP_PAYLOAD["master_password"]},
|
||||
@@ -170,15 +172,15 @@ class TestReResolve:
|
||||
async def test_returns_200_with_counts(self, geo_client: AsyncClient) -> None:
|
||||
"""POST /api/geo/re-resolve returns 200 with resolved/total counts."""
|
||||
with patch(
|
||||
"app.routers.geo.geo_service.lookup_batch",
|
||||
AsyncMock(return_value={}),
|
||||
"app.routers.geo.geo_service.re_resolve_all",
|
||||
AsyncMock(return_value={"resolved": 0, "total": 0}),
|
||||
):
|
||||
resp = await geo_client.post("/api/geo/re-resolve")
|
||||
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert "resolved" in data
|
||||
assert "total" in data
|
||||
assert data["resolved"] == 0
|
||||
assert data["total"] == 0
|
||||
|
||||
async def test_empty_when_no_unresolved_ips(self, geo_client: AsyncClient) -> None:
|
||||
"""Returns resolved=0, total=0 when geo_cache has no NULL country_code rows."""
|
||||
|
||||
Reference in New Issue
Block a user