forked from Rockachopa/Timmy-time-dashboard
Complete the module consolidation planned in REFACTORING_PLAN.md: Modules merged: - work_orders/ + task_queue/ → swarm/ (subpackages) - self_modify/ + self_tdd/ + upgrades/ → self_coding/ (subpackages) - tools/ → creative/tools/ - chat_bridge/ + telegram_bot/ + shortcuts/ + voice/ → integrations/ (new) - ws_manager/ + notifications/ + events/ + router/ → infrastructure/ (new) - agents/ + agent_core/ + memory/ → timmy/ (subpackages) Updated across codebase: - 66 source files: import statements rewritten - 13 test files: import + patch() target strings rewritten - pyproject.toml: wheel includes (28→14), entry points updated - CLAUDE.md: singleton paths, module map, entry points table - AGENTS.md: file convention updates - REFACTORING_PLAN.md: execution status, success metrics Extras: - Module-level CLAUDE.md added to 6 key packages (Phase 6.2) - Zero test regressions: 1462 tests passing https://claude.ai/code/session_01JNjWfHqusjT3aiN4vvYgUk
32 lines
865 B
Python
32 lines
865 B
Python
"""Tests for ws_manager/handler.py — WebSocket manager."""
|
|
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from infrastructure.ws_manager.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 == []
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_ws_manager_event_history_limit():
|
|
"""History is trimmed to max_history after broadcasts."""
|
|
mgr = WebSocketManager()
|
|
mgr._max_history = 5
|
|
for i in range(10):
|
|
await mgr.broadcast(f"e{i}", {})
|
|
assert len(mgr.event_history) == 5
|
|
assert mgr.event_history[0].event == "e5"
|