"""Pytest fixtures for Pathfinder MCP tests."""
from pathlib import Path
import pytest
from pathfinder_mcp.artifacts import ArtifactWriter
from pathfinder_mcp.context import ContextMonitor
from pathfinder_mcp.session import SessionManager
from pathfinder_mcp.state import Phase, PhaseState
@pytest.fixture
def temp_session_dir(tmp_path: Path) -> Path:
"""Create a temporary session directory."""
return tmp_path / "sessions"
@pytest.fixture
def session_manager(temp_session_dir: Path) -> SessionManager:
"""Create a SessionManager with temporary directory."""
return SessionManager(base_dir=temp_session_dir)
@pytest.fixture
def artifact_writer(session_manager: SessionManager) -> ArtifactWriter:
"""Create an ArtifactWriter with the test session manager."""
return ArtifactWriter(session_manager)
@pytest.fixture
def context_monitor() -> ContextMonitor:
"""Create a fresh ContextMonitor."""
return ContextMonitor(max_tokens=128_000)
@pytest.fixture
def active_sessions() -> dict[str, PhaseState]:
"""Create an empty sessions dict."""
return {}
@pytest.fixture
def sample_session_id() -> str:
"""Return a sample session ID."""
return "test_session_001"
@pytest.fixture
def research_state(sample_session_id: str) -> PhaseState:
"""Create a PhaseState in RESEARCH phase."""
return PhaseState(session_id=sample_session_id, current_phase=Phase.RESEARCH)
@pytest.fixture
def plan_state(sample_session_id: str) -> PhaseState:
"""Create a PhaseState in PLAN phase."""
return PhaseState(session_id=sample_session_id, current_phase=Phase.PLAN)
@pytest.fixture
def implement_state(sample_session_id: str) -> PhaseState:
"""Create a PhaseState in IMPLEMENT phase."""
return PhaseState(session_id=sample_session_id, current_phase=Phase.IMPLEMENT)
@pytest.fixture
def sample_research_content() -> str:
"""Return sample research.md content."""
return """# Research: Test Task
## Task Description
Test Task
## Findings
- Finding 1: Important discovery
- Finding 2: Another key point
- Finding 3: Technical detail
## Notes
Additional research notes here.
"""
@pytest.fixture
def sample_plan_content() -> str:
"""Return sample plan.md content"""
return """---
name: Test Implementation Plan
overview: A test plan for unit testing
todos:
- id: task-1
content: "Setup project structure"
status: pending
- id: task-2
content: "Implement core logic"
status: pending
dependencies:
- task-1
---
# Test Implementation Plan
## Architecture Overview
This is a test architecture for unit testing purposes.
## Core Components
```
test-project/
├── src/
│ └── main.py
└── tests/
└── test_main.py
```
## Phase 1: Setup
### 1.1 Tasks
- [ ] Create project structure
- [ ] Initialize dependencies
## Phase 2: Implementation
### 2.1 Tasks
- [ ] Implement main logic
- [ ] Add error handling
## Implementation Details
Technical specifications go here.
## Success Criteria Checklist
- [ ] All tests pass
- [ ] Documentation complete
"""