Files
Timmy-time-dashboard/tests/test_notifications.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

88 lines
2.5 KiB
Python

"""Tests for notifications/push.py — push notification system."""
from notifications.push import PushNotifier
def test_notify_creates_notification():
notifier = PushNotifier(native_enabled=False)
n = notifier.notify("Test", "Hello world", "system")
assert n.title == "Test"
assert n.message == "Hello world"
assert n.category == "system"
assert n.read is False
def test_notify_increments_id():
notifier = PushNotifier(native_enabled=False)
n1 = notifier.notify("A", "msg1")
n2 = notifier.notify("B", "msg2")
assert n2.id > n1.id
def test_recent_returns_latest_first():
notifier = PushNotifier(native_enabled=False)
notifier.notify("First", "1")
notifier.notify("Second", "2")
recent = notifier.recent(limit=2)
assert recent[0].title == "Second"
assert recent[1].title == "First"
def test_recent_filter_by_category():
notifier = PushNotifier(native_enabled=False)
notifier.notify("Swarm", "joined", "swarm")
notifier.notify("System", "boot", "system")
swarm_only = notifier.recent(category="swarm")
assert all(n.category == "swarm" for n in swarm_only)
def test_unread_count():
notifier = PushNotifier(native_enabled=False)
notifier.notify("A", "1")
notifier.notify("B", "2")
assert notifier.unread_count() == 2
def test_mark_read():
notifier = PushNotifier(native_enabled=False)
n = notifier.notify("Read me", "msg")
assert notifier.mark_read(n.id) is True
assert notifier.unread_count() == 0
def test_mark_read_nonexistent():
notifier = PushNotifier(native_enabled=False)
assert notifier.mark_read(9999) is False
def test_mark_all_read():
notifier = PushNotifier(native_enabled=False)
notifier.notify("A", "1")
notifier.notify("B", "2")
count = notifier.mark_all_read()
assert count == 2
assert notifier.unread_count() == 0
def test_clear():
notifier = PushNotifier(native_enabled=False)
notifier.notify("A", "1")
notifier.clear()
assert notifier.recent() == []
def test_listener_called():
notifier = PushNotifier(native_enabled=False)
received = []
notifier.add_listener(lambda n: received.append(n))
notifier.notify("Event", "happened")
assert len(received) == 1
assert received[0].title == "Event"
def test_max_history():
notifier = PushNotifier(max_history=5, native_enabled=False)
for i in range(10):
notifier.notify(f"N{i}", f"msg{i}")
assert len(notifier.recent(limit=100)) == 5