CI/CD Optimization: Guard Rails, Pre-commit Checks, and Test Fixes (#90)
* CI/CD Optimization: Guard Rails, Black Linting, and Pre-commit Hooks
- Fixed all test collection errors (Selenium imports, fixture paths, syntax)
- Implemented pre-commit hooks with Black formatting and isort
- Created comprehensive Makefile with test targets (unit, integration, functional, e2e)
- Added pytest.ini with marker definitions for test categorization
- Established guard rails to prevent future collection errors
- Wrapped optional dependencies (Selenium, MoviePy) in try-except blocks
- Added conftest_markers for automatic test categorization
This ensures a smooth development stream with:
- Fast feedback loops (pre-commit checks before push)
- Consistent code formatting (Black)
- Reliable CI/CD (no collection errors, proper test isolation)
- Clear test organization (unit, integration, functional, E2E)
* Fix CI/CD test failures:
- Export templates from dashboard.app
- Fix model name assertion in test_agent.py
- Fix platform-agnostic path resolution in test_path_resolution.py
- Skip Docker tests in test_docker_deployment.py if docker not available
- Fix test_model_fallback_chain logic in test_ollama_integration.py
* Add preventative pre-commit checks and Docker test skipif decorators:
- Create pre_commit_checks.py script for common CI failures
- Add skipif decorators to Docker tests
- Improve test robustness for CI environments
2026-02-28 11:36:50 -05:00
|
|
|
"""Pytest configuration and fixtures for the test suite."""
|
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
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import sqlite3
|
2026-02-19 19:05:01 +00:00
|
|
|
import sys
|
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
|
|
import pytest
|
CI/CD Optimization: Guard Rails, Pre-commit Checks, and Test Fixes (#90)
* CI/CD Optimization: Guard Rails, Black Linting, and Pre-commit Hooks
- Fixed all test collection errors (Selenium imports, fixture paths, syntax)
- Implemented pre-commit hooks with Black formatting and isort
- Created comprehensive Makefile with test targets (unit, integration, functional, e2e)
- Added pytest.ini with marker definitions for test categorization
- Established guard rails to prevent future collection errors
- Wrapped optional dependencies (Selenium, MoviePy) in try-except blocks
- Added conftest_markers for automatic test categorization
This ensures a smooth development stream with:
- Fast feedback loops (pre-commit checks before push)
- Consistent code formatting (Black)
- Reliable CI/CD (no collection errors, proper test isolation)
- Clear test organization (unit, integration, functional, E2E)
* Fix CI/CD test failures:
- Export templates from dashboard.app
- Fix model name assertion in test_agent.py
- Fix platform-agnostic path resolution in test_path_resolution.py
- Skip Docker tests in test_docker_deployment.py if docker not available
- Fix test_model_fallback_chain logic in test_ollama_integration.py
* Add preventative pre-commit checks and Docker test skipif decorators:
- Create pre_commit_checks.py script for common CI failures
- Add skipif decorators to Docker tests
- Improve test robustness for CI environments
2026-02-28 11:36:50 -05:00
|
|
|
|
|
|
|
|
# Import pytest marker configuration
|
|
|
|
|
try:
|
|
|
|
|
from . import conftest_markers # noqa: F401
|
|
|
|
|
except ImportError:
|
|
|
|
|
import conftest_markers # noqa: F401
|
2026-02-19 19:05:01 +00:00
|
|
|
|
2026-03-09 21:54:04 -04:00
|
|
|
# ── Stub heavy optional dependencies so unit tests run without them ────────────
|
|
|
|
|
# Only stub truly optional packages that may not be installed.
|
|
|
|
|
# agno is a core dependency (always installed) — do NOT stub it, or its
|
|
|
|
|
# internal import chains break under xdist parallel workers.
|
2026-02-19 19:05:01 +00:00
|
|
|
for _mod in [
|
2026-02-21 16:53:16 +00:00
|
|
|
"airllm",
|
2026-03-09 21:54:04 -04:00
|
|
|
"mcp",
|
2026-03-12 22:03:45 -04:00
|
|
|
"mcp.client",
|
|
|
|
|
"mcp.client.stdio",
|
2026-03-09 21:54:04 -04:00
|
|
|
"mcp.registry",
|
2026-02-22 17:16:12 +00:00
|
|
|
"telegram",
|
|
|
|
|
"telegram.ext",
|
2026-02-25 01:11:14 +00:00
|
|
|
"discord",
|
|
|
|
|
"discord.ext",
|
|
|
|
|
"discord.ext.commands",
|
|
|
|
|
"pyzbar",
|
|
|
|
|
"pyzbar.pyzbar",
|
2026-03-05 18:56:52 -05:00
|
|
|
"pyttsx3",
|
|
|
|
|
"sentence_transformers",
|
2026-02-19 19:05:01 +00:00
|
|
|
]:
|
|
|
|
|
sys.modules.setdefault(_mod, MagicMock())
|
|
|
|
|
|
2026-03-12 21:40:32 -04:00
|
|
|
# agno.tools.mcp requires the real mcp package; stub the sub-module so
|
|
|
|
|
# patch("agno.tools.mcp.MCPTools") resolves without installing mcp.
|
|
|
|
|
if "agno.tools.mcp" not in sys.modules:
|
|
|
|
|
_agno_mcp_stub = MagicMock()
|
|
|
|
|
sys.modules["agno.tools.mcp"] = _agno_mcp_stub
|
|
|
|
|
|
2026-03-09 21:54:04 -04:00
|
|
|
# mcp.registry needs a tool_registry with get_handler (used by timmy.agents.base)
|
|
|
|
|
_mcp_reg = sys.modules.get("mcp.registry")
|
|
|
|
|
if _mcp_reg is not None and not hasattr(_mcp_reg, "tool_registry"):
|
|
|
|
|
_mock_tool_reg = MagicMock()
|
|
|
|
|
_mock_tool_reg.get_handler.return_value = None
|
|
|
|
|
_mcp_reg.tool_registry = _mock_tool_reg
|
|
|
|
|
|
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
|
|
|
# ── Test mode setup ──────────────────────────────────────────────────────────
|
|
|
|
|
os.environ["TIMMY_TEST_MODE"] = "1"
|
2026-03-04 17:15:46 -05:00
|
|
|
os.environ["TIMMY_DISABLE_CSRF"] = "1"
|
|
|
|
|
os.environ["TIMMY_SKIP_EMBEDDINGS"] = "1"
|
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
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
|
2026-02-20 14:00:16 +00:00
|
|
|
@pytest.fixture(autouse=True)
|
2026-03-14 16:09:26 -04:00
|
|
|
def reset_message_log(tmp_path):
|
|
|
|
|
"""Redirect chat DB to temp dir and clear before/after every test."""
|
|
|
|
|
import dashboard.store as _store_mod
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-14 16:09:26 -04:00
|
|
|
original_db_path = _store_mod.DB_PATH
|
|
|
|
|
tmp_chat_db = tmp_path / "chat.db"
|
|
|
|
|
_store_mod.DB_PATH = tmp_chat_db
|
|
|
|
|
|
|
|
|
|
# Close existing singleton connection and point it at tmp DB
|
|
|
|
|
_store_mod.message_log.close()
|
|
|
|
|
_store_mod.message_log._db_path = tmp_chat_db
|
|
|
|
|
_store_mod.message_log._conn = None
|
|
|
|
|
|
|
|
|
|
_store_mod.message_log.clear()
|
2026-02-20 14:00:16 +00:00
|
|
|
yield
|
2026-03-14 16:09:26 -04:00
|
|
|
_store_mod.message_log.clear()
|
|
|
|
|
_store_mod.message_log.close()
|
|
|
|
|
|
|
|
|
|
_store_mod.DB_PATH = original_db_path
|
|
|
|
|
_store_mod.message_log._db_path = original_db_path
|
|
|
|
|
_store_mod.message_log._conn = None
|
2026-02-20 14:00:16 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
@pytest.fixture(autouse=True)
|
2026-02-28 19:27:48 -05:00
|
|
|
def clean_database(tmp_path):
|
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
|
|
|
"""Clean up database tables between tests for isolation.
|
2026-02-28 19:27:48 -05:00
|
|
|
|
2026-03-02 09:58:07 -05:00
|
|
|
Redirects every module-level DB_PATH to the per-test temp directory.
|
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
|
|
|
"""
|
2026-02-28 19:27:48 -05:00
|
|
|
tmp_swarm_db = tmp_path / "swarm.db"
|
|
|
|
|
tmp_spark_db = tmp_path / "spark.db"
|
|
|
|
|
tmp_self_coding_db = tmp_path / "self_coding.db"
|
2026-03-07 23:21:30 -05:00
|
|
|
tmp_tasks_db = tmp_path / "tasks.db"
|
|
|
|
|
tmp_work_orders_db = tmp_path / "work_orders.db"
|
2026-02-28 19:27:48 -05:00
|
|
|
|
|
|
|
|
_swarm_db_modules = [
|
|
|
|
|
"infrastructure.models.registry",
|
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
|
|
|
]
|
2026-03-12 11:23:18 -04:00
|
|
|
_memory_db_modules = [
|
|
|
|
|
"timmy.memory.unified",
|
|
|
|
|
]
|
2026-02-28 19:27:48 -05:00
|
|
|
_spark_db_modules = [
|
|
|
|
|
"spark.memory",
|
|
|
|
|
"spark.eidos",
|
|
|
|
|
]
|
2026-03-02 13:17:38 -05:00
|
|
|
_self_coding_db_modules = []
|
2026-02-28 19:27:48 -05:00
|
|
|
|
2026-03-12 11:23:18 -04:00
|
|
|
tmp_memory_db = tmp_path / "memory.db"
|
|
|
|
|
|
2026-02-28 19:27:48 -05:00
|
|
|
originals = {}
|
|
|
|
|
for mod_name in _swarm_db_modules:
|
|
|
|
|
try:
|
|
|
|
|
mod = __import__(mod_name, fromlist=["DB_PATH"])
|
|
|
|
|
attr = "DB_PATH"
|
|
|
|
|
originals[(mod_name, attr)] = getattr(mod, attr)
|
|
|
|
|
setattr(mod, attr, tmp_swarm_db)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
2026-03-12 11:23:18 -04:00
|
|
|
for mod_name in _memory_db_modules:
|
|
|
|
|
try:
|
|
|
|
|
mod = __import__(mod_name, fromlist=["DB_PATH"])
|
|
|
|
|
originals[(mod_name, "DB_PATH")] = mod.DB_PATH
|
|
|
|
|
mod.DB_PATH = tmp_memory_db
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# Redirect semantic memory DB path (uses SEMANTIC_DB_PATH, not DB_PATH)
|
|
|
|
|
try:
|
|
|
|
|
import timmy.semantic_memory as _sem_mod
|
|
|
|
|
|
|
|
|
|
originals[("timmy.semantic_memory", "SEMANTIC_DB_PATH")] = _sem_mod.SEMANTIC_DB_PATH
|
|
|
|
|
_sem_mod.SEMANTIC_DB_PATH = tmp_memory_db
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
2026-02-28 19:27:48 -05:00
|
|
|
for mod_name in _spark_db_modules:
|
|
|
|
|
try:
|
|
|
|
|
mod = __import__(mod_name, fromlist=["DB_PATH"])
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
originals[(mod_name, "DB_PATH")] = mod.DB_PATH
|
|
|
|
|
mod.DB_PATH = tmp_spark_db
|
2026-02-28 19:27:48 -05:00
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
for mod_name in _self_coding_db_modules:
|
|
|
|
|
try:
|
|
|
|
|
mod = __import__(mod_name, fromlist=["DEFAULT_DB_PATH"])
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
originals[(mod_name, "DEFAULT_DB_PATH")] = mod.DEFAULT_DB_PATH
|
|
|
|
|
mod.DEFAULT_DB_PATH = tmp_self_coding_db
|
2026-02-28 19:27:48 -05:00
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
2026-03-11 20:33:59 -04:00
|
|
|
# Redirect task queue and work orders DBs to temp dir.
|
|
|
|
|
# IMPORTANT: swarm.task_queue.models also has a DB_PATH that writes to
|
|
|
|
|
# tasks.db — it MUST be patched too, or error_capture.capture_error()
|
|
|
|
|
# will write test data to the production database.
|
2026-03-07 23:21:30 -05:00
|
|
|
for mod_name, tmp_db in [
|
|
|
|
|
("dashboard.routes.tasks", tmp_tasks_db),
|
|
|
|
|
("dashboard.routes.work_orders", tmp_work_orders_db),
|
2026-03-11 20:33:59 -04:00
|
|
|
("swarm.task_queue.models", tmp_tasks_db),
|
2026-03-07 23:21:30 -05:00
|
|
|
]:
|
|
|
|
|
try:
|
|
|
|
|
mod = __import__(mod_name, fromlist=["DB_PATH"])
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
originals[(mod_name, "DB_PATH")] = mod.DB_PATH
|
|
|
|
|
mod.DB_PATH = tmp_db
|
2026-03-07 23:21:30 -05:00
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
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
|
|
|
yield
|
2026-02-28 19:27:48 -05:00
|
|
|
|
|
|
|
|
for (mod_name, attr), original in originals.items():
|
|
|
|
|
try:
|
|
|
|
|
mod = __import__(mod_name, fromlist=[attr])
|
|
|
|
|
setattr(mod, attr, original)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
|
def cleanup_event_loops():
|
|
|
|
|
"""Clean up any leftover event loops after each test."""
|
|
|
|
|
import asyncio
|
|
|
|
|
import warnings
|
2026-03-08 12:50:44 -04:00
|
|
|
|
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
|
|
|
yield
|
|
|
|
|
try:
|
|
|
|
|
try:
|
|
|
|
|
loop = asyncio.get_running_loop()
|
|
|
|
|
return
|
|
|
|
|
except RuntimeError:
|
|
|
|
|
pass
|
|
|
|
|
with warnings.catch_warnings():
|
|
|
|
|
warnings.simplefilter("ignore", DeprecationWarning)
|
|
|
|
|
loop = asyncio.get_event_loop_policy().get_event_loop()
|
|
|
|
|
if loop and not loop.is_closed():
|
|
|
|
|
loop.close()
|
|
|
|
|
except RuntimeError:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
@pytest.fixture
|
|
|
|
|
def client():
|
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
|
|
|
"""FastAPI test client with fresh app instance."""
|
2026-03-05 18:07:59 -05:00
|
|
|
from fastapi.testclient import TestClient
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
from dashboard.app import app
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
with TestClient(app) as c:
|
|
|
|
|
yield c
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def db_connection():
|
2026-03-02 09:58:07 -05:00
|
|
|
"""Provide a fresh in-memory SQLite connection for tests."""
|
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
|
|
|
conn = sqlite3.connect(":memory:")
|
|
|
|
|
conn.row_factory = sqlite3.Row
|
2026-03-08 16:07:02 -04:00
|
|
|
conn.executescript("""
|
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
|
|
|
CREATE TABLE IF NOT EXISTS agents (
|
|
|
|
|
id TEXT PRIMARY KEY,
|
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
|
status TEXT NOT NULL DEFAULT 'idle',
|
|
|
|
|
capabilities TEXT DEFAULT '',
|
|
|
|
|
registered_at TEXT NOT NULL,
|
|
|
|
|
last_seen TEXT NOT NULL
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE IF NOT EXISTS tasks (
|
|
|
|
|
id TEXT PRIMARY KEY,
|
|
|
|
|
description TEXT NOT NULL,
|
|
|
|
|
status TEXT NOT NULL DEFAULT 'pending',
|
|
|
|
|
assigned_agent TEXT,
|
|
|
|
|
result TEXT,
|
|
|
|
|
created_at TEXT NOT NULL,
|
|
|
|
|
completed_at TEXT
|
|
|
|
|
);
|
2026-03-08 16:07:02 -04:00
|
|
|
""")
|
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
|
|
|
conn.commit()
|
|
|
|
|
yield conn
|
|
|
|
|
conn.close()
|
2026-02-28 11:07:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def mock_ollama_client():
|
|
|
|
|
"""Provide a mock Ollama client for unit tests."""
|
|
|
|
|
client = MagicMock()
|
|
|
|
|
client.generate = MagicMock(return_value={"response": "Test response"})
|
|
|
|
|
client.chat = MagicMock(return_value={"message": {"content": "Test chat response"}})
|
|
|
|
|
client.list = MagicMock(return_value={"models": [{"name": "llama3.2"}]})
|
|
|
|
|
return client
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def mock_timmy_agent():
|
|
|
|
|
"""Provide a mock Timmy agent for testing."""
|
|
|
|
|
agent = MagicMock()
|
|
|
|
|
agent.name = "Timmy"
|
|
|
|
|
agent.run = MagicMock(return_value="Test response from Timmy")
|
|
|
|
|
agent.chat = MagicMock(return_value="Test chat response")
|
|
|
|
|
return agent
|