feat: add live replays and PostgreSQL maintenance tools
Build and Push Docker Container / build-and-push (push) Successful in 7m53s
Build and Push Docker Container / build-and-push (push) Successful in 7m53s
- Stream compact live replay updates across local and clustered dashboards. - Render responsive snake bodies as SVG paths with aligned custom icons. - Add cache-busted assets, replay fallback routes, and live-follow playback. - Support PostgreSQL benchmark sampling and idempotent SQLite migration. - Add dry-run cleanup for old low-quality PostgreSQL replay payloads. - Reward safe perimeter lanes and bump Prism to version 1.5.0. - Add backend, migration, dashboard, and perimeter regression coverage.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import os
|
||||
import unittest
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from server.Server import Server
|
||||
|
||||
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
REPLAY = {
|
||||
'game': {'game_id': 'game-1', 'width': 11, 'height': 11},
|
||||
'turns': [{'turn': 0, 'snakes': []}],
|
||||
}
|
||||
|
||||
class TestDashboardReplayRoute(unittest.IsolatedAsyncioTestCase):
|
||||
"""The dashboard falls back to this route when the replay websocket is down."""
|
||||
|
||||
def setUp(self):
|
||||
self.server = Server(
|
||||
data_path=REPO_ROOT,
|
||||
snake_type='PrismBattleSnake',
|
||||
storage_type='memory',
|
||||
metrics_backend='memory',
|
||||
gameplay_db_enabled=False,
|
||||
)
|
||||
self.database = AsyncMock()
|
||||
self.server.dashboard_query.gameplay_database = self.database
|
||||
|
||||
async def test_serves_replay_payload(self):
|
||||
self.database.get_game_replay.return_value = dict(REPLAY)
|
||||
|
||||
response = await self.server.app.test_client().get('/dashboard/game/game-1')
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
payload = await response.get_json()
|
||||
self.assertEqual(payload['game']['game_id'], 'game-1')
|
||||
self.assertEqual(len(payload['turns']), 1)
|
||||
self.database.get_game_replay.assert_awaited_once_with('game-1')
|
||||
|
||||
async def test_unknown_game_returns_404(self):
|
||||
self.database.get_game_replay.return_value = None
|
||||
|
||||
response = await self.server.app.test_client().get('/dashboard/game/nope')
|
||||
|
||||
self.assertEqual(response.status_code, 404)
|
||||
payload = await response.get_json()
|
||||
self.assertEqual(payload['error'], 'game_not_found')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user