"""E2E tests for get_process MCP tool.
Scenarios from E2E Test Plan Section 5.4:
- Scenario 5.4.1: Get Process with Valid Name (P0)
- Scenario 5.4.2: Get Process with Case-Insensitive Matching (P0)
- Scenario 5.4.3: Get Process with Invalid Name (P0)
"""
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from sso_mcp_server.processes.service import ProcessService
if TYPE_CHECKING:
pass
@pytest.mark.e2e
@pytest.mark.smoke
@pytest.mark.process
class TestGetProcessE2E:
"""E2E tests for get_process tool."""
def test_get_process_valid_name_returns_content(
self,
e2e_process_dir: Path,
) -> None:
"""Scenario 5.4.1: Get process with valid name.
Given server is authenticated and ready
And process file "code-review.md" exists with YAML frontmatter
When client sends MCP request to get_process with name="code-review"
Then server returns response with name, description, and content
"""
# Arrange
service = ProcessService(e2e_process_dir)
# Act
result = service.get_process("code-review")
# Assert
assert result is not None, "Process should be found"
assert result["name"] == "Code Review Process"
assert result["description"] == "Standard procedure for reviewing code changes"
assert "# Code Review Process" in result["content"]
assert "PR has description" in result["content"]
def test_get_process_case_insensitive(
self,
e2e_process_dir: Path,
) -> None:
"""Scenario 5.4.2: Get process with case-insensitive matching.
Given process file "code-review.md" exists
When client sends MCP request to get_process with name="CODE-REVIEW"
Then server returns the process content (case-insensitive match)
"""
# Arrange
service = ProcessService(e2e_process_dir)
# Act - request with different case
result = service.get_process("CODE-REVIEW")
# Assert
assert result is not None, "Case-insensitive matching should work"
assert "Code Review" in result["name"]
def test_get_process_mixed_case(
self,
e2e_process_dir: Path,
) -> None:
"""Test mixed case process name matching.
Given process file "deployment.md" exists
When client requests with name="DePlOyMeNt"
Then server returns the deployment process
"""
# Arrange
service = ProcessService(e2e_process_dir)
# Act
result = service.get_process("DePlOyMeNt")
# Assert
assert result is not None
assert "Deployment" in result["name"]
def test_get_process_invalid_name_returns_none(
self,
e2e_process_dir: Path,
) -> None:
"""Scenario 5.4.3: Get process with invalid name.
Given server is authenticated and ready
And no process named "nonexistent" exists
When client sends MCP request to get_process with name="nonexistent"
Then server returns None (process not found)
"""
# Arrange
service = ProcessService(e2e_process_dir)
# Act
result = service.get_process("nonexistent")
# Assert
assert result is None, "Non-existent process should return None"
def test_get_process_returns_full_content(
self,
e2e_process_dir: Path,
) -> None:
"""Test that get_process returns complete markdown content.
Given process file exists with multiple sections
When client requests the process
Then response contains the full content without frontmatter
"""
# Arrange
service = ProcessService(e2e_process_dir)
# Act
result = service.get_process("deployment")
# Assert
assert result is not None
assert result["name"] == "Deployment Process"
assert "# Deployment Process" in result["content"]
assert "Pre-Deployment Checklist" in result["content"]
assert "Post-Deployment" in result["content"]
# Frontmatter should NOT be in content
assert "---" not in result["content"]
def test_get_process_multiple_processes_accessible(
self,
e2e_process_dir: Path,
) -> None:
"""Test that multiple processes can be accessed independently.
Given multiple process files exist
When client requests different processes
Then each returns correct content
"""
# Arrange
service = ProcessService(e2e_process_dir)
# Act
code_review = service.get_process("code-review")
deployment = service.get_process("deployment")
incident = service.get_process("incident-response")
# Assert
assert code_review is not None
assert deployment is not None
assert incident is not None
assert code_review["name"] != deployment["name"]
assert deployment["name"] != incident["name"]