WIP: Gemini Code progress on #978

Automated salvage commit — agent session ended (exit 124).
Work in progress, may need continuation.
This commit is contained in:
Alexander Whitestone
2026-03-23 14:10:08 -04:00
parent a445df758b
commit c45f78171b
3 changed files with 804 additions and 673 deletions

1367
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -37,6 +37,7 @@ typer = ">=0.12.0"
rich = ">=13.0.0"
pydantic-settings = ">=2.0.0,<3.0"
mcp = ">=1.0.0"
serpapi = ">=2.0.0"
# Optional extras
redis = { version = ">=5.0.0", optional = true }
celery = { version = ">=5.3.0", extras = ["redis"], optional = true }
@@ -68,7 +69,7 @@ voice = ["pyttsx3", "openai-whisper", "piper-tts", "sounddevice"]
celery = ["celery"]
embeddings = ["sentence-transformers", "numpy"]
git = ["GitPython"]
research = ["requests", "trafilatura", "google-search-results"]
research = ["requests", "trafilatura", "google-search-results", "serpapi"]
dev = ["pytest", "pytest-asyncio", "pytest-cov", "pytest-timeout", "pytest-randomly", "pytest-xdist", "selenium"]
[tool.poetry.group.dev.dependencies]
@@ -81,6 +82,7 @@ pytest-randomly = "^4.0.1"
pytest-xdist = "^3.8.0"
ruff = ">=0.8.0"
mypy = ">=1.0.0"
pytest-httpx = "^0.36.0"
[tool.poetry.scripts]
timmy = "timmy.cli:main"

View File

@@ -0,0 +1,106 @@
"""Tests for the Paperclip integration."""
from __future__ import annotations
import asyncio
from unittest.mock import AsyncMock, patch
import pytest
from timmy.paperclip import (
PaperclipClient,
PaperclipPoller,
PaperclipTask,
ResearchOrchestrator,
)
@pytest.fixture
def mock_settings(monkeypatch):
"""Mock the settings for the Paperclip integration."""
monkeypatch.setattr("timmy.paperclip.settings.paperclip_enabled", True)
monkeypatch.setattr("timmy.paperclip.settings.paperclip_url", "http://localhost:3100")
monkeypatch.setattr("timmy.paperclip.settings.paperclip_api_key", "test-key")
monkeypatch.setattr("timmy.paperclip.settings.paperclip_agent_id", "test-agent")
monkeypatch.setattr("timmy.paperclip.settings.paperclip_company_id", "test-company")
monkeypatch.setattr("timmy.paperclip.settings.paperclip_poll_interval", 1)
monkeypatch.setattr("timmy.paperclip.settings.gitea_url", "http://localhost:3000")
monkeypatch.setattr("timmy.paperclip.settings.gitea_token", "test-token")
monkeypatch.setattr("timmy.paperclip.settings.gitea_repo", "test/repo")
@pytest.mark.asyncio
async def test_paperclip_client_get_tasks(mock_settings, httpx_mock):
"""Test that the Paperclip client can get tasks."""
httpx_mock.add_response(
url="http://localhost:3100/api/tasks?agent_id=test-agent&company_id=test-company&status=queued",
json=[
{
"id": "1",
"kind": "research",
"context": {"issue_number": 123},
}
],
)
client = PaperclipClient()
tasks = await client.get_tasks()
assert len(tasks) == 1
assert tasks[0].id == "1"
assert tasks[0].kind == "research"
assert tasks[0].context == {"issue_number": 123}
@pytest.mark.asyncio
async def test_paperclip_client_update_task_status(mock_settings, httpx_mock):
"""Test that the Paperclip client can update a task's status."""
httpx_mock.add_response(
url="http://localhost:3100/api/tasks/1",
method="PATCH",
)
client = PaperclipClient()
await client.update_task_status("1", "running")
@pytest.mark.asyncio
async def test_research_orchestrator_run(mock_settings, httpx_mock):
"""Test that the ResearchOrchestrator can run a research task."""
httpx_mock.add_response(
url="http://localhost:3000/api/v1/repos/test/repo/issues/123",
json={"title": "Test Issue", "body": "This is a test issue."},
)
httpx_mock.add_response(
url="http://localhost:3000/api/v1/repos/test/repo/issues/123/comments",
method="POST",
)
with patch("timmy.paperclip.triage_research_report", new_callable=AsyncMock) as mock_triage:
mock_triage.return_value = []
orchestrator = ResearchOrchestrator()
result = await orchestrator.run({"issue_number": 123})
assert result == "Research complete for issue #123"
@pytest.mark.asyncio
async def test_paperclip_poller_poll(mock_settings):
"""Test that the Paperclip poller can poll for tasks."""
with patch("timmy.paperclip.PaperclipClient.get_tasks", new_callable=AsyncMock) as mock_get_tasks:
mock_get_tasks.return_value = [
PaperclipTask(
id="1",
kind="research",
context={"issue_number": 123},
)
]
with patch("timmy.paperclip.PaperclipPoller.run_research_task", new_callable=AsyncMock):
poller = PaperclipPoller()
poller.poll_interval = 0.1
task = asyncio.create_task(poller.poll())
await asyncio.sleep(0.2)
task.cancel()
mock_get_tasks.assert_called()