Files
xer-mcp/tests/contract/test_get_project_summary.py
Bill Ballou ccc8296418 feat: implement XER MCP Server with 9 schedule query tools
Implement complete MCP server for parsing Primavera P6 XER files and
exposing schedule data through MCP tools. All 4 user stories complete.

Tools implemented:
- load_xer: Parse XER files into SQLite database
- list_activities: Query activities with pagination and filtering
- get_activity: Get activity details by ID
- list_relationships: Query activity dependencies
- get_predecessors/get_successors: Query activity relationships
- get_project_summary: Project overview with counts
- list_milestones: Query milestone activities
- get_critical_path: Query driving path activities

Features:
- Tab-delimited XER format parsing with pluggable table handlers
- In-memory SQLite database for fast queries
- Pagination with 100-item default limit
- Multi-project file support with project selection
- ISO8601 date formatting
- NO_FILE_LOADED error handling for all query tools

Test coverage: 81 tests (contract, integration, unit)
2026-01-06 21:27:35 -05:00

89 lines
3.0 KiB
Python

"""Contract tests for get_project_summary MCP tool."""
from pathlib import Path
import pytest
from xer_mcp.db import db
@pytest.fixture(autouse=True)
def setup_db():
"""Initialize and clear database for each test."""
db.initialize()
yield
db.clear()
class TestGetProjectSummaryContract:
"""Contract tests verifying get_project_summary tool interface."""
async def test_get_project_summary_returns_basic_info(
self, sample_xer_single_project: Path
) -> None:
"""get_project_summary returns project name, dates, and activity count."""
from xer_mcp.tools.get_project_summary import get_project_summary
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_project_summary()
assert "project_name" in result
assert "plan_start_date" in result
assert "plan_end_date" in result
assert "activity_count" in result
async def test_get_project_summary_returns_correct_values(
self, sample_xer_single_project: Path
) -> None:
"""get_project_summary returns correct project values from loaded XER."""
from xer_mcp.tools.get_project_summary import get_project_summary
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_project_summary()
assert result["project_name"] == "Test Project"
assert result["activity_count"] == 5
async def test_get_project_summary_includes_milestone_count(
self, sample_xer_single_project: Path
) -> None:
"""get_project_summary includes count of milestones."""
from xer_mcp.tools.get_project_summary import get_project_summary
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_project_summary()
assert "milestone_count" in result
assert result["milestone_count"] == 2
async def test_get_project_summary_includes_critical_count(
self, sample_xer_single_project: Path
) -> None:
"""get_project_summary includes count of critical path activities."""
from xer_mcp.tools.get_project_summary import get_project_summary
from xer_mcp.tools.load_xer import load_xer
await load_xer(file_path=str(sample_xer_single_project))
result = await get_project_summary()
assert "critical_activity_count" in result
assert result["critical_activity_count"] == 4
async def test_get_project_summary_no_file_loaded_returns_error(self) -> None:
"""get_project_summary without loaded file returns NO_FILE_LOADED error."""
from xer_mcp.server import set_file_loaded
from xer_mcp.tools.get_project_summary import get_project_summary
set_file_loaded(False)
result = await get_project_summary()
assert "error" in result
assert result["error"]["code"] == "NO_FILE_LOADED"