This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Timmy-time-dashboard/tests/test_websocket.py
Alexspayne f9b84c1e2f feat: Mission Control v2 — swarm, L402, voice, marketplace, React dashboard
Major expansion of the Timmy Time Dashboard:

Backend modules:
- Swarm subsystem: registry, manager, bidder, coordinator, agent_runner, swarm_node, tasks, comms
- L402/Lightning: payment_handler, l402_proxy with HMAC macaroons
- Voice NLU: regex-based intent detection (chat, status, swarm, task, help, voice)
- Notifications: push notifier for swarm events
- Shortcuts: Siri Shortcuts iOS integration endpoints
- WebSocket: live dashboard event manager
- Inter-agent: agent-to-agent messaging layer

Dashboard routes:
- /swarm/* — swarm management and agent registry
- /marketplace — agent catalog with sat pricing
- /voice/* — voice command processing
- /mobile — mobile status endpoint
- /swarm/live — WebSocket live feed

React web dashboard (dashboard-web/):
- Sovereign Terminal design — dark theme with Bitcoin orange accents
- Three-column layout: status sidebar, workspace tabs, context panel
- Chat, Swarm, Tasks, Marketplace tab views
- JetBrains Mono typography, terminal aesthetic
- Framer Motion animations throughout

Tests: 228 passing (expanded from 93)
Includes Kimi's additional templates and QA work.
2026-02-21 12:57:38 -05:00

31 lines
931 B
Python

"""Tests for websocket/handler.py — WebSocket manager."""
import json
from websocket.handler import WebSocketManager, WSEvent
def test_ws_event_to_json():
event = WSEvent(event="test", data={"key": "val"}, timestamp="2026-01-01T00:00:00Z")
j = json.loads(event.to_json())
assert j["event"] == "test"
assert j["data"]["key"] == "val"
def test_ws_manager_initial_state():
mgr = WebSocketManager()
assert mgr.connection_count == 0
assert mgr.event_history == []
def test_ws_manager_event_history_limit():
mgr = WebSocketManager()
mgr._max_history = 5
for i in range(10):
event = WSEvent(event=f"e{i}", data={}, timestamp="t")
mgr._event_history.append(event)
# Simulate the trim that happens in broadcast
if len(mgr._event_history) > mgr._max_history:
mgr._event_history = mgr._event_history[-mgr._max_history:]
assert len(mgr._event_history) == 5