#!/bin/bash # Vultr DNS MCP Test Fix Installer # This script applies all necessary fixes to the test suite set -e echo "๐Ÿ”ง Vultr DNS MCP Test Suite Fixer" echo "==================================" # Check if we're in the right directory if [ ! -f "pyproject.toml" ] || [ ! -d "tests" ]; then echo "โŒ Error: Please run this script from the vultr-dns-mcp repository root" echo " Expected files: pyproject.toml, tests/ directory" exit 1 fi echo "โœ… Found vultr-dns-mcp repository structure" # Create backups echo "๐Ÿ“ฆ Creating backups..." backup_dir="test_backups_$(date +%Y%m%d_%H%M%S)" mkdir -p "$backup_dir" if [ -f "tests/conftest.py" ]; then cp "tests/conftest.py" "$backup_dir/conftest.py.backup" echo " Backed up conftest.py" fi if [ -f "tests/test_mcp_server.py" ]; then cp "tests/test_mcp_server.py" "$backup_dir/test_mcp_server.py.backup" echo " Backed up test_mcp_server.py" fi cp "pyproject.toml" "$backup_dir/pyproject.toml.backup" echo " Backed up pyproject.toml" # Check if fix files are available fix_dir="/home/rpm/claude/vultr-dns-mcp-fix" if [ ! -d "$fix_dir" ]; then echo "โŒ Error: Fix files not found at $fix_dir" echo " Please ensure the fix files are available" exit 1 fi echo "โœ… Found fix files" # Apply fixes echo "" echo "๐Ÿ”ง Applying fixes..." if [ -f "$fix_dir/fixed_conftest.py" ]; then cp "$fix_dir/fixed_conftest.py" "tests/conftest.py" echo " โœ… Updated tests/conftest.py" else echo " โš ๏ธ Warning: fixed_conftest.py not found" fi if [ -f "$fix_dir/fixed_test_mcp_server.py" ]; then cp "$fix_dir/fixed_test_mcp_server.py" "tests/test_mcp_server.py" echo " โœ… Updated tests/test_mcp_server.py" else echo " โš ๏ธ Warning: fixed_test_mcp_server.py not found" fi # Update pyproject.toml (add missing pytest config) echo "" echo "๐Ÿ”ง Updating pyproject.toml..." # Check if pytest config exists if ! grep -q "tool.pytest.ini_options" pyproject.toml; then echo "" echo "# Added by test fixer" >> pyproject.toml echo "[tool.pytest.ini_options]" >> pyproject.toml echo 'asyncio_mode = "auto"' >> pyproject.toml echo 'addopts = ["--strict-markers", "--verbose"]' >> pyproject.toml echo 'markers = [' >> pyproject.toml echo ' "unit: Unit tests",' >> pyproject.toml echo ' "integration: Integration tests",' >> pyproject.toml echo ' "mcp: MCP server tests",' >> pyproject.toml echo ' "slow: Slow tests"' >> pyproject.toml echo ']' >> pyproject.toml echo " โœ… Added pytest configuration" else echo " โœ… pytest configuration already exists" fi # Install dependencies echo "" echo "๐Ÿ“ฆ Installing dependencies..." if command -v pip &> /dev/null; then pip install -e .[dev] || { echo " โš ๏ธ Dev install failed, trying basic dependencies..." pip install pytest pytest-asyncio pytest-cov fastmcp httpx pydantic click } echo " โœ… Dependencies installed" else echo " โŒ Error: pip not found" exit 1 fi # Run tests to verify echo "" echo "๐Ÿงช Testing the fixes..." echo "==================================" # Test basic import if python -c "from vultr_dns_mcp.server import create_mcp_server; print('โœ… Import test passed')" 2>/dev/null; then echo "โœ… Basic imports working" else echo "โŒ Import test failed - please check installation" fi # Run a simple test if pytest tests/test_package_validation.py -v -x; then echo "โœ… Package validation tests passed" else echo "โš ๏ธ Package validation tests had issues" fi # Run MCP tests echo "" echo "๐Ÿš€ Running MCP server tests..." if pytest tests/test_mcp_server.py -v -x; then echo "" echo "๐ŸŽ‰ SUCCESS! All MCP tests are now passing!" else echo "" echo "โš ๏ธ Some MCP tests still failing - check output above" fi echo "" echo "==================================" echo "โœ… Fix application complete!" echo "" echo "๐Ÿ“Š Summary:" echo " - Backup created in: $backup_dir/" echo " - Fixed files applied to tests/" echo " - Dependencies installed" echo " - Tests executed" echo "" echo "๐Ÿš€ Next steps:" echo " 1. Run: pytest tests/ -v (all tests)" echo " 2. Run: pytest tests/ -m mcp -v (MCP tests only)" echo " 3. Run: pytest tests/ --cov=vultr_dns_mcp (with coverage)" echo "" echo "๐Ÿ’ก If issues persist:" echo " - Check the logs above for specific errors" echo " - Restore from backup: cp $backup_dir/* tests/" echo " - Review: cat FINAL_SOLUTION.md" echo "" echo "๐ŸŽฏ Test suite fix complete!"