Fix legacy historical recent matches fast path
This commit is contained in:
@@ -168,7 +168,7 @@ class HistoricalSnapshotRefreshTests(unittest.TestCase):
|
||||
self.assertEqual(len(payload["data"]["items"]), 1)
|
||||
self.assertFalse(payload["data"].get("fallback_used", False))
|
||||
|
||||
def test_legacy_all_servers_recent_matches_uses_snapshot_fast_path(self) -> None:
|
||||
def test_legacy_recent_matches_uses_snapshot_fast_path(self) -> None:
|
||||
snapshot = {
|
||||
"generated_at": "2026-06-10T04:00:00Z",
|
||||
"source_range_start": "2026-06-09T21:00:00Z",
|
||||
@@ -191,7 +191,7 @@ class HistoricalSnapshotRefreshTests(unittest.TestCase):
|
||||
patch("app.payloads.list_recent_historical_matches") as fallback_loader,
|
||||
):
|
||||
payload = build_recent_historical_matches_payload(
|
||||
server_slug="all-servers",
|
||||
server_slug="comunidad-hispana-01",
|
||||
limit=20,
|
||||
)
|
||||
|
||||
@@ -199,8 +199,73 @@ class HistoricalSnapshotRefreshTests(unittest.TestCase):
|
||||
fallback_loader.assert_not_called()
|
||||
self.assertEqual(payload["data"]["context"], "historical-recent-matches")
|
||||
self.assertEqual(payload["data"]["legacy_endpoint_policy"], "snapshot-read-only-fast-path")
|
||||
self.assertEqual(payload["data"]["server_slug"], "comunidad-hispana-01")
|
||||
self.assertEqual(payload["data"]["items"][0]["match_id"], "match-1")
|
||||
|
||||
def test_legacy_second_server_recent_matches_uses_snapshot_fast_path(self) -> None:
|
||||
snapshot = {
|
||||
"generated_at": "2026-06-10T04:00:00Z",
|
||||
"source_range_start": "2026-06-09T21:00:00Z",
|
||||
"source_range_end": "2026-06-09T22:00:00Z",
|
||||
"is_stale": False,
|
||||
"payload": {
|
||||
"items": [
|
||||
{
|
||||
"match_id": "match-2",
|
||||
"closed_at": "2026-06-09T22:00:00Z",
|
||||
}
|
||||
],
|
||||
"limit": 100,
|
||||
},
|
||||
}
|
||||
with (
|
||||
patch("app.payloads._get_historical_snapshot_record", return_value=snapshot),
|
||||
patch("app.payloads.get_historical_data_source_kind", return_value="rcon"),
|
||||
patch("app.payloads.get_rcon_historical_read_model") as rcon_loader,
|
||||
patch("app.payloads.list_recent_historical_matches") as fallback_loader,
|
||||
):
|
||||
payload = build_recent_historical_matches_payload(
|
||||
server_slug="comunidad-hispana-02",
|
||||
limit=20,
|
||||
)
|
||||
|
||||
rcon_loader.assert_not_called()
|
||||
fallback_loader.assert_not_called()
|
||||
self.assertEqual(payload["data"]["server_slug"], "comunidad-hispana-02")
|
||||
self.assertEqual(payload["data"]["items"][0]["match_id"], "match-2")
|
||||
|
||||
def test_legacy_all_servers_recent_matches_still_uses_snapshot_fast_path(self) -> None:
|
||||
snapshot = {
|
||||
"generated_at": "2026-06-10T04:00:00Z",
|
||||
"source_range_start": "2026-06-09T21:00:00Z",
|
||||
"source_range_end": "2026-06-09T22:00:00Z",
|
||||
"is_stale": False,
|
||||
"payload": {
|
||||
"items": [
|
||||
{
|
||||
"match_id": "match-all",
|
||||
"closed_at": "2026-06-09T22:00:00Z",
|
||||
}
|
||||
],
|
||||
"limit": 100,
|
||||
},
|
||||
}
|
||||
with (
|
||||
patch("app.payloads._get_historical_snapshot_record", return_value=snapshot),
|
||||
patch("app.payloads.get_historical_data_source_kind", return_value="rcon"),
|
||||
patch("app.payloads.get_rcon_historical_read_model") as rcon_loader,
|
||||
patch("app.payloads.list_recent_historical_matches") as fallback_loader,
|
||||
):
|
||||
payload = build_recent_historical_matches_payload(
|
||||
server_slug="all-servers",
|
||||
limit=20,
|
||||
)
|
||||
|
||||
rcon_loader.assert_not_called()
|
||||
fallback_loader.assert_not_called()
|
||||
self.assertEqual(payload["data"]["server_slug"], "all-servers")
|
||||
self.assertEqual(payload["data"]["items"][0]["match_id"], "match-all")
|
||||
|
||||
def test_legacy_server_summary_uses_snapshot_fast_path(self) -> None:
|
||||
snapshot = {
|
||||
"generated_at": "2026-06-10T04:00:00Z",
|
||||
|
||||
Reference in New Issue
Block a user