This directory contains the unit and integration tests for the CLI Agent Orchestrator.
Install the required packages using pip:
pip install pytest pytest-cov pytest-asyncioOr install all development dependencies:
pip install -e ".[dev]"Before running tests, install the package in editable mode:
cd cli-agent-orchestrator
pip install -e .pytest test/pytest test/ -vpytest test/ --cov=src --cov-report=term-missingpytest test/providers/test_kiro_cli_unit.py -vpytest test/providers/test_kiro_cli_unit.py::TestKiroCliProvider -vpytest test/providers/test_kiro_cli_unit.py::TestKiroCliProvider::test_init -vIntegration tests require actual CLI tools to be installed. To skip them:
pytest test/ -v --ignore=test/providers/test_kiro_cli_integration.pytest/
├── README.md # This file
├── api/ # API endpoint tests
│ ├── test_inbox_messages.py
│ └── test_terminals.py
├── cli/ # CLI command tests
│ ├── test_main.py
│ └── commands/
│ ├── test_flow.py
│ ├── test_init.py
│ ├── test_install.py
│ ├── test_launch.py
│ └── test_shutdown.py
├── clients/ # Client tests
│ ├── test_database.py
│ └── test_tmux_send_keys.py
├── e2e/ # End-to-end tests (require running CAO server)
│ ├── conftest.py
│ ├── test_assign.py
│ ├── test_handoff.py
│ ├── test_send_message.py
│ └── test_supervisor_orchestration.py
├── mcp_server/ # MCP server tests
│ ├── test_handoff.py
│ ├── test_models.py
│ └── test_utils.py
├── models/ # Model tests
│ └── test_session.py
├── providers/ # Provider tests
│ ├── test_base_provider.py
│ ├── test_claude_code_unit.py
│ ├── test_codex_provider_unit.py
│ ├── test_antigravity_cli_unit.py
│ ├── test_kimi_cli_unit.py
│ ├── test_copilot_cli_unit.py
│ ├── test_kiro_cli_unit.py
│ ├── test_provider_manager_unit.py
│ └── test_cursor_cli_unit.py
├── services/ # Service tests
│ ├── test_cleanup_service.py
│ ├── test_flow_service.py
│ ├── test_inbox_service.py
│ ├── test_session_service.py
│ └── test_terminal_service_full.py
└── utils/ # Utility tests
├── test_agent_profiles.py
├── test_logging.py
├── test_template.py
└── test_terminal.py
The project aims for >90% test coverage for core modules.
Modules at 100% Coverage:
cli/commands/- All CLI commands (flow, init, install, launch, shutdown)constants.py- Configuration constantsmcp_server/models.py,mcp_server/utils.py- MCP models and utilitiesmodels/- All Pydantic modelsproviders/- All provider implementations (claude_code, codex, antigravity_cli, kiro_cli, kimi_cli, copilot_cli, opencode_cli, cursor_cli)services/inbox_service.py,services/session_service.py- Core servicesutils/- All utility modules (agent_profiles, logging, template, terminal)
Modules at 90%+ Coverage:
cli/main.py(93%) - Main CLI entry pointproviders/manager.py(96%) - Provider managerservices/terminal_service.py(95%) - Terminal service
Some files have limited test coverage due to their nature:
| Module | Coverage | Justification |
|---|---|---|
| mcp_server/server.py | 0% | Requires MCP protocol runtime environment. The MCP server runs as a separate process and communicates via the MCP protocol. Testing requires mocking the entire MCP communication layer, which is better handled by integration tests with actual MCP clients. |
| clients/tmux.py | ~30% | Requires real tmux sessions for full coverage. Core send_keys behavior (literal mode, chunking) is unit-tested via test_tmux_send_keys.py. Operations like session creation and history capture are better covered by integration tests. |
| api/main.py | 44% | FastAPI endpoints require async testing setup with TestClient and running event loops. Endpoints interact with the database, tmux sessions, and providers simultaneously. Better tested via end-to-end integration tests. |
| services/cleanup_service.py | 20% | Background cleanup service that runs in a separate thread, monitoring and cleaning up stale sessions. Requires running processes and real session state to test cleanup logic. |
| services/flow_service.py | 25% | Flow orchestration service that manages complex multi-step agent interactions. Requires complex runtime state including active sessions, message queues, and provider instances. |
| clients/database.py | 80% | Database operations with some edge cases (transaction rollbacks, concurrent access) difficult to test without full database integration. Core CRUD operations are tested. |
| providers/base.py | 81% | Abstract base class with abstract methods that must be implemented by subclasses. The abstract methods themselves cannot be tested directly. All concrete implementations are at 100%. |
- Unit tests:
test_<module_name>.pyortest_<module_name>_unit.py - Integration tests:
test_<module_name>_integration.py
class TestClassName:
"""Tests for ClassName."""
def test_method_name(self):
"""Test specific method or behavior."""
passMost unit tests use mocks to isolate the code under test:
from unittest.mock import MagicMock, patch
@patch("cli_agent_orchestrator.providers.kiro_cli.TmuxClient")
def test_with_mock(self, mock_tmux):
mock_tmux_instance = MagicMock()
mock_tmux.return_value = mock_tmux_instance
# ... test codeIf you see ModuleNotFoundError: No module named 'cli_agent_orchestrator':
pip install -e .pip install pytest-covIntegration tests require the provider CLI tool to be installed and authenticated. These tests are expected to fail if the CLI is not available. Skip them with (Kiro CLI example):
pytest test/ --ignore=test/providers/test_kiro_cli_integration.py