"""E2E tests for get_checklist MCP tool.
Scenarios from E2E Test Plan Section 5.3:
- Scenario 5.3.1: Get Checklist with Valid Name (P0)
- Scenario 5.3.2: Get Checklist with Invalid Name (P0)
"""
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from sso_mcp_server.checklists.service import ChecklistService
if TYPE_CHECKING:
pass
@pytest.mark.e2e
@pytest.mark.smoke
@pytest.mark.checklist
class TestGetChecklistE2E:
"""E2E tests for get_checklist tool."""
def test_get_checklist_valid_name_returns_content(
self,
e2e_checklist_dir: Path,
) -> None:
"""Scenario 5.3.1: Get checklist with valid name.
Given server is authenticated and ready
And checklist file "coding.md" exists with YAML frontmatter
When client sends MCP request to get_checklist with name="coding"
Then server returns response with name, description, and content
"""
# Arrange
service = ChecklistService(e2e_checklist_dir)
# Act
result = service.get_checklist("coding")
# Assert
assert result is not None, "Checklist should be found"
assert result["name"] == "Coding Standards"
assert result["description"] == "Quality checklist for code implementation"
assert "# Coding Standards Checklist" in result["content"]
assert "Variables use descriptive names" in result["content"]
def test_get_checklist_case_insensitive(
self,
e2e_checklist_dir: Path,
) -> None:
"""Test that checklist lookup is case-insensitive.
Given checklist file "coding.md" exists
When client requests checklist with name="CODING"
Then server returns the coding checklist
"""
# Arrange
service = ChecklistService(e2e_checklist_dir)
# Act - request with different case
result = service.get_checklist("CODING")
# Assert
assert result is not None, "Case-insensitive matching should work"
assert "Coding" in result["name"]
def test_get_checklist_invalid_name_returns_none(
self,
e2e_checklist_dir: Path,
) -> None:
"""Scenario 5.3.2: Get checklist with invalid name.
Given server is authenticated and ready
And no checklist named "nonexistent" exists
When client sends MCP request to get_checklist with name="nonexistent"
Then server returns None (checklist not found)
"""
# Arrange
service = ChecklistService(e2e_checklist_dir)
# Act
result = service.get_checklist("nonexistent")
# Assert
assert result is None, "Non-existent checklist should return None"
def test_get_checklist_returns_full_content(
self,
e2e_checklist_dir: Path,
) -> None:
"""Test that get_checklist returns complete markdown content.
Given checklist file exists with multiple sections
When client requests the checklist
Then response contains the full content without frontmatter
"""
# Arrange
service = ChecklistService(e2e_checklist_dir)
# Act
result = service.get_checklist("architecture")
# Assert
assert result is not None
assert result["name"] == "Architecture Review"
assert "# Architecture Review Checklist" in result["content"]
assert "Single responsibility principle" in result["content"]
# Frontmatter should NOT be in content
assert "---" not in result["content"]
def test_get_checklist_multiple_checklists_accessible(
self,
e2e_checklist_dir: Path,
) -> None:
"""Test that multiple checklists can be accessed independently.
Given multiple checklist files exist
When client requests different checklists
Then each returns correct content
"""
# Arrange
service = ChecklistService(e2e_checklist_dir)
# Act
coding = service.get_checklist("coding")
architecture = service.get_checklist("architecture")
detailed = service.get_checklist("detailed-design")
# Assert
assert coding is not None
assert architecture is not None
assert detailed is not None
assert coding["name"] != architecture["name"]
assert architecture["name"] != detailed["name"]