Fix websocket replay tests
This commit is contained in:
@@ -694,7 +694,17 @@ class TestLocalServerMoreCoverage:
|
||||
assert queue.get_nowait() == "existing"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_mark_route_activity_triggers_notification(self, server_with_no_apps):
|
||||
async def test_handle_session_data_marks_activity(self, server_with_no_apps, monkeypatch):
|
||||
ws = MagicMock()
|
||||
ws.send_bytes = AsyncMock()
|
||||
server_with_no_apps._websocket_connections["rk"] = ws
|
||||
server_with_no_apps._route_last_activity["rk"] = 0.0
|
||||
|
||||
await server_with_no_apps.handle_session_data("rk", b"data")
|
||||
assert server_with_no_apps._route_last_activity["rk"] > 0.0
|
||||
ws.send_bytes.assert_awaited_once_with(b"data")
|
||||
|
||||
def test_mark_route_activity_triggers_notification(self, server_with_no_apps):
|
||||
"""Test that mark_route_activity triggers SSE notification."""
|
||||
import asyncio
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
from aiohttp import WSMsgType, web
|
||||
@@ -59,9 +60,16 @@ async def test_websocket_creates_session_on_resize(tmp_path):
|
||||
server.session_manager.routes["test"] = "sid"
|
||||
server.session_manager.sessions["sid"] = DummySession()
|
||||
|
||||
# Replay buffer should be sent on reconnect
|
||||
replay_session = server.session_manager.sessions["sid"]
|
||||
replay_session.get_replay_buffer = AsyncMock(return_value=b"replay")
|
||||
|
||||
client = await _make_client(server)
|
||||
try:
|
||||
ws = await client.ws_connect("/ws/test")
|
||||
msg = await ws.receive(timeout=1)
|
||||
assert msg.type == WSMsgType.BINARY
|
||||
assert msg.data == b"replay"
|
||||
await ws.close()
|
||||
finally:
|
||||
await client.close()
|
||||
|
||||
Reference in New Issue
Block a user