test: close coverage gaps for timmy_serve CLI, voice_enhanced, WebSocket, and swarm live page
- Add 8 tests for timmy_serve/cli.py (start, invoice, status commands)
covering default args, custom args, and output validation
- Add 8 tests for voice_enhanced route covering all intent types
(status, help, swarm, voice, chat fallback) plus error handling
- Add 17 tests for websocket/handler.py covering broadcast to
multiple clients, dead connection cleanup, history trimming,
connect/disconnect, and all convenience broadcast methods
- Add 4 tests for the new GET /swarm/live page route
Total new tests: 37
2026-02-21 13:45:24 -05:00
|
|
|
"""Tests for timmy_serve/cli.py — Serve-mode CLI commands."""
|
|
|
|
|
|
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
|
|
|
|
|
|
from timmy_serve.cli import app
|
|
|
|
|
|
|
|
|
|
runner = CliRunner()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestStartCommand:
|
|
|
|
|
def test_start_default_port(self):
|
feat: swarm E2E, MCP tools, timmy-serve L402, tests, notifications
Major Features:
- Auto-spawn persona agents (Echo, Forge, Seer) on app startup
- WebSocket broadcasts for real-time swarm UI updates
- MCP tool integration: web search, file I/O, shell, Python execution
- New /tools dashboard page showing agent capabilities
- Real timmy-serve start with L402 payment gating middleware
- Browser push notifications for briefings and task events
Tests:
- test_docker_agent.py: 9 tests for Docker agent runner
- test_swarm_integration_full.py: 18 E2E lifecycle tests
- Fixed all pytest warnings (436 tests, 0 warnings)
Improvements:
- Fixed coroutine warnings in coordinator broadcasts
- Fixed ResourceWarning for unclosed process pipes
- Added pytest-asyncio config to pyproject.toml
- Test isolation with proper event loop cleanup
2026-02-22 19:01:04 -05:00
|
|
|
result = runner.invoke(app, ["start", "--dry-run"])
|
test: close coverage gaps for timmy_serve CLI, voice_enhanced, WebSocket, and swarm live page
- Add 8 tests for timmy_serve/cli.py (start, invoice, status commands)
covering default args, custom args, and output validation
- Add 8 tests for voice_enhanced route covering all intent types
(status, help, swarm, voice, chat fallback) plus error handling
- Add 17 tests for websocket/handler.py covering broadcast to
multiple clients, dead connection cleanup, history trimming,
connect/disconnect, and all convenience broadcast methods
- Add 4 tests for the new GET /swarm/live page route
Total new tests: 37
2026-02-21 13:45:24 -05:00
|
|
|
assert result.exit_code == 0
|
|
|
|
|
assert "8402" in result.output
|
|
|
|
|
assert "L402 payment proxy active" in result.output
|
|
|
|
|
|
|
|
|
|
def test_start_custom_port(self):
|
feat: swarm E2E, MCP tools, timmy-serve L402, tests, notifications
Major Features:
- Auto-spawn persona agents (Echo, Forge, Seer) on app startup
- WebSocket broadcasts for real-time swarm UI updates
- MCP tool integration: web search, file I/O, shell, Python execution
- New /tools dashboard page showing agent capabilities
- Real timmy-serve start with L402 payment gating middleware
- Browser push notifications for briefings and task events
Tests:
- test_docker_agent.py: 9 tests for Docker agent runner
- test_swarm_integration_full.py: 18 E2E lifecycle tests
- Fixed all pytest warnings (436 tests, 0 warnings)
Improvements:
- Fixed coroutine warnings in coordinator broadcasts
- Fixed ResourceWarning for unclosed process pipes
- Added pytest-asyncio config to pyproject.toml
- Test isolation with proper event loop cleanup
2026-02-22 19:01:04 -05:00
|
|
|
result = runner.invoke(app, ["start", "--port", "9000", "--dry-run"])
|
test: close coverage gaps for timmy_serve CLI, voice_enhanced, WebSocket, and swarm live page
- Add 8 tests for timmy_serve/cli.py (start, invoice, status commands)
covering default args, custom args, and output validation
- Add 8 tests for voice_enhanced route covering all intent types
(status, help, swarm, voice, chat fallback) plus error handling
- Add 17 tests for websocket/handler.py covering broadcast to
multiple clients, dead connection cleanup, history trimming,
connect/disconnect, and all convenience broadcast methods
- Add 4 tests for the new GET /swarm/live page route
Total new tests: 37
2026-02-21 13:45:24 -05:00
|
|
|
assert result.exit_code == 0
|
|
|
|
|
assert "9000" in result.output
|
|
|
|
|
|
|
|
|
|
def test_start_custom_host(self):
|
feat: swarm E2E, MCP tools, timmy-serve L402, tests, notifications
Major Features:
- Auto-spawn persona agents (Echo, Forge, Seer) on app startup
- WebSocket broadcasts for real-time swarm UI updates
- MCP tool integration: web search, file I/O, shell, Python execution
- New /tools dashboard page showing agent capabilities
- Real timmy-serve start with L402 payment gating middleware
- Browser push notifications for briefings and task events
Tests:
- test_docker_agent.py: 9 tests for Docker agent runner
- test_swarm_integration_full.py: 18 E2E lifecycle tests
- Fixed all pytest warnings (436 tests, 0 warnings)
Improvements:
- Fixed coroutine warnings in coordinator broadcasts
- Fixed ResourceWarning for unclosed process pipes
- Added pytest-asyncio config to pyproject.toml
- Test isolation with proper event loop cleanup
2026-02-22 19:01:04 -05:00
|
|
|
result = runner.invoke(app, ["start", "--host", "127.0.0.1", "--dry-run"])
|
test: close coverage gaps for timmy_serve CLI, voice_enhanced, WebSocket, and swarm live page
- Add 8 tests for timmy_serve/cli.py (start, invoice, status commands)
covering default args, custom args, and output validation
- Add 8 tests for voice_enhanced route covering all intent types
(status, help, swarm, voice, chat fallback) plus error handling
- Add 17 tests for websocket/handler.py covering broadcast to
multiple clients, dead connection cleanup, history trimming,
connect/disconnect, and all convenience broadcast methods
- Add 4 tests for the new GET /swarm/live page route
Total new tests: 37
2026-02-21 13:45:24 -05:00
|
|
|
assert result.exit_code == 0
|
|
|
|
|
assert "127.0.0.1" in result.output
|
|
|
|
|
|
|
|
|
|
def test_start_shows_endpoints(self):
|
feat: swarm E2E, MCP tools, timmy-serve L402, tests, notifications
Major Features:
- Auto-spawn persona agents (Echo, Forge, Seer) on app startup
- WebSocket broadcasts for real-time swarm UI updates
- MCP tool integration: web search, file I/O, shell, Python execution
- New /tools dashboard page showing agent capabilities
- Real timmy-serve start with L402 payment gating middleware
- Browser push notifications for briefings and task events
Tests:
- test_docker_agent.py: 9 tests for Docker agent runner
- test_swarm_integration_full.py: 18 E2E lifecycle tests
- Fixed all pytest warnings (436 tests, 0 warnings)
Improvements:
- Fixed coroutine warnings in coordinator broadcasts
- Fixed ResourceWarning for unclosed process pipes
- Added pytest-asyncio config to pyproject.toml
- Test isolation with proper event loop cleanup
2026-02-22 19:01:04 -05:00
|
|
|
result = runner.invoke(app, ["start", "--dry-run"])
|
test: close coverage gaps for timmy_serve CLI, voice_enhanced, WebSocket, and swarm live page
- Add 8 tests for timmy_serve/cli.py (start, invoice, status commands)
covering default args, custom args, and output validation
- Add 8 tests for voice_enhanced route covering all intent types
(status, help, swarm, voice, chat fallback) plus error handling
- Add 17 tests for websocket/handler.py covering broadcast to
multiple clients, dead connection cleanup, history trimming,
connect/disconnect, and all convenience broadcast methods
- Add 4 tests for the new GET /swarm/live page route
Total new tests: 37
2026-02-21 13:45:24 -05:00
|
|
|
assert "/serve/chat" in result.output
|
|
|
|
|
assert "/serve/invoice" in result.output
|
|
|
|
|
assert "/serve/status" in result.output
|
|
|
|
|
|
feat: swarm E2E, MCP tools, timmy-serve L402, tests, notifications
Major Features:
- Auto-spawn persona agents (Echo, Forge, Seer) on app startup
- WebSocket broadcasts for real-time swarm UI updates
- MCP tool integration: web search, file I/O, shell, Python execution
- New /tools dashboard page showing agent capabilities
- Real timmy-serve start with L402 payment gating middleware
- Browser push notifications for briefings and task events
Tests:
- test_docker_agent.py: 9 tests for Docker agent runner
- test_swarm_integration_full.py: 18 E2E lifecycle tests
- Fixed all pytest warnings (436 tests, 0 warnings)
Improvements:
- Fixed coroutine warnings in coordinator broadcasts
- Fixed ResourceWarning for unclosed process pipes
- Added pytest-asyncio config to pyproject.toml
- Test isolation with proper event loop cleanup
2026-02-22 19:01:04 -05:00
|
|
|
def test_start_custom_price(self):
|
|
|
|
|
result = runner.invoke(app, ["start", "--price", "50", "--dry-run"])
|
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
assert "50 sats" in result.output
|
|
|
|
|
|
test: close coverage gaps for timmy_serve CLI, voice_enhanced, WebSocket, and swarm live page
- Add 8 tests for timmy_serve/cli.py (start, invoice, status commands)
covering default args, custom args, and output validation
- Add 8 tests for voice_enhanced route covering all intent types
(status, help, swarm, voice, chat fallback) plus error handling
- Add 17 tests for websocket/handler.py covering broadcast to
multiple clients, dead connection cleanup, history trimming,
connect/disconnect, and all convenience broadcast methods
- Add 4 tests for the new GET /swarm/live page route
Total new tests: 37
2026-02-21 13:45:24 -05:00
|
|
|
|
|
|
|
|
class TestInvoiceCommand:
|
|
|
|
|
def test_invoice_default_amount(self):
|
|
|
|
|
result = runner.invoke(app, ["invoice"])
|
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
assert "100 sats" in result.output
|
|
|
|
|
assert "API access" in result.output
|
|
|
|
|
|
|
|
|
|
def test_invoice_custom_amount(self):
|
|
|
|
|
result = runner.invoke(app, ["invoice", "--amount", "500"])
|
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
assert "500 sats" in result.output
|
|
|
|
|
|
|
|
|
|
def test_invoice_custom_memo(self):
|
|
|
|
|
result = runner.invoke(app, ["invoice", "--memo", "Test payment"])
|
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
assert "Test payment" in result.output
|
|
|
|
|
|
|
|
|
|
def test_invoice_shows_payment_hash(self):
|
|
|
|
|
result = runner.invoke(app, ["invoice"])
|
|
|
|
|
assert "Payment hash:" in result.output
|
|
|
|
|
assert "Pay request:" in result.output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestStatusCommand:
|
|
|
|
|
def test_status_runs_successfully(self):
|
|
|
|
|
result = runner.invoke(app, ["status"])
|
|
|
|
|
assert result.exit_code == 0
|
|
|
|
|
assert "Timmy Serve" in result.output
|
|
|
|
|
assert "Total invoices:" in result.output
|
|
|
|
|
assert "Settled:" in result.output
|
|
|
|
|
assert "Total earned:" in result.output
|
|
|
|
|
assert "sats" in result.output
|