Skip to content

Commit a383155

Browse files
committed
Update WebSocket tests for new log format, dependency
1 parent ffc1fc1 commit a383155

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

universal-telemetry-software/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cantools>=39.4.0
99
# Test dependencies
1010
pytest>=7.4.0
1111
pytest-asyncio>=0.21.0
12+
pytest-timeout>=2.1.0
1213
requests>=2.31.0
1314

1415
PyGObject

universal-telemetry-software/tests/test_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@ def handle_error(error):
369369
logger.info(f" {msg}")
370370

371371
# Check for WebSocket connection
372-
connection_logs = [msg for msg in console_messages if "WebSocket connected" in msg]
372+
connection_logs = [msg for msg in console_messages if "[WebSocket] Connected" in msg]
373373
assert len(connection_logs) > 0, \
374374
f"WebSocket connection not established. Errors: {page_errors}. Console: {console_messages[:15]}"
375375
logger.info("✓ Pecan established WebSocket connection")
376-
376+
377377
# Check for data reception (should see at least first message)
378-
data_logs = [msg for msg in console_messages if "Received WebSocket message #" in msg]
378+
data_logs = [msg for msg in console_messages if "[WebSocket] Message #" in msg]
379379
assert len(data_logs) > 0, \
380380
f"No WebSocket messages received. Console: {console_messages[:15]}"
381381
logger.info(f"✓ Pecan received {len(data_logs)} WebSocket messages")

universal-telemetry-software/tests/test_websocket_v2.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,16 @@ async def test_ping_returns_pong(self):
6262
await ws.connect()
6363
ts = int(time.time() * 1000)
6464
await ws.send_message({"type": "ping", "timestamp": ts})
65-
msg = await ws.receive_message(timeout=5)
65+
66+
# Server may send CAN batch frames before the pong — skip non-dict messages
67+
msg = None
68+
for _ in range(10):
69+
candidate = await ws.receive_message(timeout=5)
70+
if candidate is None:
71+
break
72+
if isinstance(candidate, dict) and candidate.get("type") == "pong":
73+
msg = candidate
74+
break
6675

6776
assert msg is not None, "No pong response received"
6877
assert msg["type"] == "pong"

0 commit comments

Comments
 (0)