Remove dead task DB fast-path and update task tests

This commit is contained in:
2026-04-07 20:00:13 +02:00
parent 0a70e40d8b
commit e21f153946
9 changed files with 96 additions and 25 deletions

View File

@@ -69,6 +69,7 @@ def _make_app(
app = MagicMock()
app.state.db = db
app.state.http_session = http_session
app.state.settings = MagicMock(database_path="/tmp/fake.db")
return app
@@ -78,7 +79,11 @@ async def test_run_re_resolve_no_unresolved_ips_skips() -> None:
"""The task should return immediately when no NULL-country IPs exist."""
app = _make_app(unresolved_ips=[])
with patch("app.tasks.geo_re_resolve.geo_service") as mock_geo:
with patch(
"app.tasks.geo_re_resolve.open_db",
new_callable=AsyncMock,
return_value=app.state.db,
), patch("app.tasks.geo_re_resolve.geo_service") as mock_geo:
mock_geo.get_unresolved_ips = AsyncMock(return_value=[])
await _run_re_resolve(app)
@@ -116,7 +121,11 @@ async def test_run_re_resolve_calls_lookup_batch_with_db() -> None:
}
app = _make_app(unresolved_ips=ips, lookup_result=result)
with patch("app.tasks.geo_re_resolve.geo_service") as mock_geo:
with patch(
"app.tasks.geo_re_resolve.open_db",
new_callable=AsyncMock,
return_value=app.state.db,
), patch("app.tasks.geo_re_resolve.geo_service") as mock_geo:
mock_geo.get_unresolved_ips = AsyncMock(return_value=ips)
mock_geo.lookup_batch = AsyncMock(return_value=result)
@@ -140,7 +149,11 @@ async def test_run_re_resolve_logs_correct_counts(caplog: Any) -> None:
}
app = _make_app(unresolved_ips=ips, lookup_result=result)
with patch("app.tasks.geo_re_resolve.geo_service") as mock_geo:
with patch(
"app.tasks.geo_re_resolve.open_db",
new_callable=AsyncMock,
return_value=app.state.db,
), patch("app.tasks.geo_re_resolve.geo_service") as mock_geo:
mock_geo.get_unresolved_ips = AsyncMock(return_value=ips)
mock_geo.lookup_batch = AsyncMock(return_value=result)
@@ -163,7 +176,11 @@ async def test_run_re_resolve_handles_all_resolved() -> None:
}
app = _make_app(unresolved_ips=ips, lookup_result=result)
with patch("app.tasks.geo_re_resolve.geo_service") as mock_geo:
with patch(
"app.tasks.geo_re_resolve.open_db",
new_callable=AsyncMock,
return_value=app.state.db,
), patch("app.tasks.geo_re_resolve.geo_service") as mock_geo:
mock_geo.get_unresolved_ips = AsyncMock(return_value=ips)
mock_geo.lookup_batch = AsyncMock(return_value=result)