update 2. GTP-6, второй этап поправки ошибок
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
@@ -27,7 +29,7 @@ class FakeWebSocket:
|
||||
return None
|
||||
|
||||
|
||||
def test_stale_browser_device_falls_back_to_only_live_active_agent(tmp_path: Path) -> None:
|
||||
def test_stale_browser_device_cannot_redirect_to_another_agent(tmp_path: Path) -> None:
|
||||
database = LocalTestDatabase(tmp_path / "build111.sqlite3")
|
||||
database.create_all()
|
||||
hub = VmixAgentHub(database) # type: ignore[arg-type]
|
||||
@@ -47,20 +49,21 @@ def test_stale_browser_device_falls_back_to_only_live_active_agent(tmp_path: Pat
|
||||
},
|
||||
)
|
||||
await hub.pair_device("GFX-BUILD111", user)
|
||||
with pytest.raises(HTTPException) as error:
|
||||
await hub.assign_match(
|
||||
wfl_user_id=user.id, tournament_external_id="1437",
|
||||
game_external_id="902918", device_id="STALE-BROWSER-DEVICE",
|
||||
wait_for_mapping=False,
|
||||
)
|
||||
assert error.value.status_code == 409
|
||||
assert not [item for item in ws.sent if item.get("type") == "match.assign"]
|
||||
# An explicitly selected owned Agent still receives the new match.
|
||||
result = await hub.assign_match(
|
||||
wfl_user_id=user.id,
|
||||
tournament_external_id="1437",
|
||||
game_external_id="902918",
|
||||
device_id="STALE-BROWSER-DEVICE",
|
||||
wait_for_mapping=False,
|
||||
wfl_user_id=user.id, tournament_external_id="1437", game_external_id="902918",
|
||||
device_id="GFX-BUILD111", wait_for_mapping=False,
|
||||
)
|
||||
assert result is not None
|
||||
assert result["device_id"] == "GFX-BUILD111"
|
||||
assert result["delivered"] is True
|
||||
assert result["device_id"] == "GFX-BUILD111" and result["delivered"]
|
||||
assert result["mapping_apply"]["deferred"] is True
|
||||
match_assigns = [item for item in ws.sent if item.get("type") == "match.assign"]
|
||||
assert len(match_assigns) == 1
|
||||
assert match_assigns[0]["game_id"] == "902918"
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user