Include the schedule data date (last_recalc_date from XER) in the get_project_summary tool response. This shows when the schedule was last calculated in P6. Changes: - Add last_recalc_date column to projects table schema - Parse last_recalc_date in PROJECT table handler - Include last_recalc_date in db loader - Return data_date field in get_project_summary query - Update contract test to verify data_date presence
90 lines
3.0 KiB
Python
90 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 "data_date" 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"
|