forked from Rockachopa/Timmy-time-dashboard
fix: address audit low-hanging fruit — docs accuracy, auction timing, stubs, tests
- Docs: "No Cloud" → "No Cloud AI" (frontend uses CDN for Bootstrap/HTMX/fonts) - Docs: "600+" → "640+" tests, "20+" → "58" endpoints (actual counts) - Docs: LND described as "scaffolded" not "gRPC-ready"; remove "agents earn sats" - Fix auction timing: coordinator sleep(0) → sleep(AUCTION_DURATION_SECONDS) - agent_core: implement remember() with dedup/eviction, communicate() via swarm comms - Tests: add CLI tests for chat, think, and backend/model-size forwarding (647 passing) https://claude.ai/code/session_01SZTwAkTg6v4ybv8g9NLxqN
This commit is contained in:
@@ -27,3 +27,45 @@ def test_status_does_not_use_inline_string():
|
||||
|
||||
call_args = mock_timmy.print_response.call_args
|
||||
assert call_args[0][0] != "Brief status report — one sentence."
|
||||
|
||||
|
||||
def test_chat_sends_message_to_agent():
|
||||
"""chat command must pass the user message to the agent with streaming."""
|
||||
mock_timmy = MagicMock()
|
||||
|
||||
with patch("timmy.cli.create_timmy", return_value=mock_timmy):
|
||||
runner.invoke(app, ["chat", "Hello Timmy"])
|
||||
|
||||
mock_timmy.print_response.assert_called_once_with("Hello Timmy", stream=True)
|
||||
|
||||
|
||||
def test_think_sends_topic_to_agent():
|
||||
"""think command must pass the topic wrapped in a prompt with streaming."""
|
||||
mock_timmy = MagicMock()
|
||||
|
||||
with patch("timmy.cli.create_timmy", return_value=mock_timmy):
|
||||
runner.invoke(app, ["think", "Bitcoin self-custody"])
|
||||
|
||||
mock_timmy.print_response.assert_called_once_with(
|
||||
"Think carefully about: Bitcoin self-custody", stream=True
|
||||
)
|
||||
|
||||
|
||||
def test_chat_passes_backend_option():
|
||||
"""chat --backend airllm must forward the backend to create_timmy."""
|
||||
mock_timmy = MagicMock()
|
||||
|
||||
with patch("timmy.cli.create_timmy", return_value=mock_timmy) as mock_create:
|
||||
runner.invoke(app, ["chat", "test", "--backend", "airllm"])
|
||||
|
||||
mock_create.assert_called_once_with(backend="airllm", model_size=None)
|
||||
|
||||
|
||||
def test_think_passes_model_size_option():
|
||||
"""think --model-size 70b must forward the model size to create_timmy."""
|
||||
mock_timmy = MagicMock()
|
||||
|
||||
with patch("timmy.cli.create_timmy", return_value=mock_timmy) as mock_create:
|
||||
runner.invoke(app, ["think", "topic", "--model-size", "70b"])
|
||||
|
||||
mock_create.assert_called_once_with(backend=None, model_size="70b")
|
||||
|
||||
@@ -162,8 +162,8 @@ async def test_coordinator_run_auction_no_bids():
|
||||
coord = SwarmCoordinator()
|
||||
task = coord.post_task("No bids task")
|
||||
|
||||
# Patch sleep to avoid 15-second wait
|
||||
with patch("swarm.bidder.asyncio.sleep", new_callable=AsyncMock):
|
||||
# Patch sleep to avoid 15-second wait in tests
|
||||
with patch("swarm.coordinator.asyncio.sleep", new_callable=AsyncMock):
|
||||
winner = await coord.run_auction_and_assign(task.id)
|
||||
|
||||
assert winner is None
|
||||
|
||||
@@ -8,7 +8,7 @@ These tests verify that:
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -16,6 +16,13 @@ from swarm.coordinator import SwarmCoordinator
|
||||
from swarm.tasks import TaskStatus
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _fast_auction():
|
||||
"""Skip the 15-second auction wait in tests."""
|
||||
with patch("swarm.coordinator.AUCTION_DURATION_SECONDS", 0):
|
||||
yield
|
||||
|
||||
|
||||
class TestSwarmInProcessAgents:
|
||||
"""Test the in-process agent spawning and bidding flow."""
|
||||
|
||||
|
||||
@@ -8,6 +8,13 @@ import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _fast_auction():
|
||||
"""Skip the 15-second auction wait in tests."""
|
||||
with patch("swarm.coordinator.AUCTION_DURATION_SECONDS", 0):
|
||||
yield
|
||||
|
||||
|
||||
class TestFullSwarmLifecycle:
|
||||
"""Integration tests for end-to-end swarm task lifecycle."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user