Files
TSSBOT/tests/test_receiver_bridge.py
T
NotSoToothless 24335a2677 Auto merge dev → main (#1353)
* feat(gateway): hashed key store with grant + hot reload

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(gateway): channel registry + aiohttp app (keyed auth, whoami, per-channel ws/proxy)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(gateway): manage_keys CLI (add/list/revoke)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(gateway): retire srebot_external, run relay-gateway under PM2

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(gateway): point ecosystem + README at relay-gateway

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(tss): replay outbox producer for relay gateway

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(tss): forward processed games to relay outbox

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(tss-api): db helpers, app skeleton, info endpoint, fixtures

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(tss-api): player, games, history, search endpoints

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(tss-api): live, match, scoreboard, matches-search, maps

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(tss-api): filter-required leaderboards (players/vehicles/stats)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(tss-api): tournament list/detail/standings/matches

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat: wire tss upstream through gateway + tssbot-api PM2 app

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 03:38:20 -07:00

34 lines
1.0 KiB
Python

import json
import importlib
import sys
from pathlib import Path
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "SHARED"))
@pytest.fixture
def bridge(tmp_path, monkeypatch):
monkeypatch.setenv("STORAGE_VOL_PATH", str(tmp_path))
import BOT.receiver_bridge as rb
importlib.reload(rb)
return rb
async def test_publish_replay_batch_writes_tss_envelope(bridge, tmp_path):
await bridge.publish_replay_batch([{"sessionIdHex": "abc", "x": 1}])
line = (tmp_path / "tss_bridge_outbox.jsonl").read_text(encoding="utf-8").strip()
env = json.loads(line)
assert env["type"] == "tss.replay_batch"
assert env["source"] == "tss"
assert env["version"] == 1
assert env["payload"]["replays"][0]["sessionIdHex"] == "abc"
assert isinstance(env["sent_at"], float)
async def test_publish_replay_batch_empty_is_noop(bridge, tmp_path):
await bridge.publish_replay_batch([])
assert not (tmp_path / "tss_bridge_outbox.jsonl").exists()