enhanced-mcp-tools/tests/test_basic.py
Ryan Malloy 1d199a943d 🛡️ SACRED TRUST: Complete safety framework implementation & validation
 COMPREHENSIVE SAFETY FRAMEWORK:
• Package-level safety notices with SACRED TRUST language
• Server-level LLM safety protocols with specific refusal scenarios
• Class-level safety reminders for AI assistants
• Tool-level destructive operation warnings (🔴 DESTRUCTIVE markers)
• Visual safety system: 🔴🛡️🚨 markers throughout codebase
• Emergency logging infrastructure with proper escalation
• Default-safe operations (dry_run=True for destructive tools)

🔒 DESTRUCTIVE OPERATION PROTECTIONS:
• bulk_rename: LLM safety instructions + dry_run default
• search_and_replace_batch: Comprehensive safety warnings
• All destructive tools require preview before execution
• Clear REFUSE scenarios for AI assistants

📚 COMPREHENSIVE DOCUMENTATION:
• SACRED_TRUST_SAFETY.md: Complete safety philosophy & implementation guide
• IMPLEMENTATION_COMPLETE.md: Project completion status
• EMERGENCY_LOGGING_COMPLETE.md: Logging infrastructure details
• UV_BUILD_GUIDE.md: Modern Python project setup
• Multiple implementation guides and status docs

🔧 PROJECT MODERNIZATION:
• Migrated from setup.py/requirements.txt to pyproject.toml + uv
• Updated dependency management with uv.lock
• Enhanced test suite with comprehensive coverage
• Added examples and demo scripts

 VALIDATION COMPLETE: All SACRED_TRUST_SAFETY.md requirements implemented
🎯 Sacred Trust Status: PROTECTED
🚨 User Safety: PARAMOUNT
🔐 System Integrity: PRESERVED

The human trusts AI assistants to be guardians of their system and data.
This framework ensures that trust is honored through comprehensive safety measures.
2025-06-23 11:58:48 -06:00

64 lines
1.8 KiB
Python

"""
Basic tests for the MCP server tools.
Run with: pytest tests/test_basic.py
"""
import os
import tempfile
from pathlib import Path
import pytest
# Import the implementations from enhanced_mcp
from enhanced_mcp.diff_patch import DiffPatchOperations
from enhanced_mcp.file_operations import EnhancedFileOperations
from enhanced_mcp.git_integration import GitIntegration
from enhanced_mcp.workflow_tools import AdvancedSearchAnalysis
class TestFileOperations:
"""Test file operation tools"""
@pytest.mark.asyncio
async def test_file_backup_simple(self):
"""Test simple file backup"""
with tempfile.TemporaryDirectory() as tmp_dir:
# Create test file
test_file = Path(tmp_dir) / "test.txt"
test_file.write_text("Test content")
backup_dir = Path(tmp_dir) / "backups"
# Perform backup
file_tools = EnhancedFileOperations()
backups = await file_tools.file_backup(
[str(test_file)], backup_directory=str(backup_dir)
)
# Verify backup created
assert len(backups) == 1
assert os.path.exists(backups[0])
# Verify content preserved
with open(backups[0]) as f:
assert f.read() == "Test content"
class TestSearchAnalysis:
"""Test search and analysis tools"""
@pytest.mark.asyncio
async def test_project_stats_resource(self):
"""Test project statistics resource"""
# Use the current project directory
search_tools = AdvancedSearchAnalysis()
stats = await search_tools.analyze_codebase(".", ["loc"])
# Verify basic structure
assert "directory" in stats
assert stats["directory"] == "."
if __name__ == "__main__":
pytest.main([__file__, "-v"])