fix: Resolve MCP package shadowing issue and add package structure tests

🐛 Fixes:
- Fix mcp package shadowing by importing external MCP before sys.path modification
- Update mcp/server.py to avoid shadowing installed mcp package
- Update tests/test_mcp_server.py import order

 Tests Added:
- Add tests/test_package_structure.py with 23 comprehensive tests
- Test cli package structure and imports
- Test mcp package structure and imports
- Test backwards compatibility
- All package structure tests passing 

📊 Test Results:
- 205 tests passed 
- 67 tests skipped (PDF features, PyMuPDF not installed)
- 23 new package structure tests added
- Total: 272 tests (excluding test_mcp_server.py which needs more work)

⚠️ Known Issue:
- test_mcp_server.py still has import issues (67 tests)
- Will be fixed in next commit
- Main functionality tests all passing

Impact: Package structure working, 75% of tests passing
This commit is contained in:
yusyus
2025-10-26 00:26:57 +03:00
parent fb0cb99e6b
commit cb0d3e885e
6 changed files with 485 additions and 6 deletions

View File

@@ -14,10 +14,8 @@ import asyncio
from pathlib import Path
from unittest.mock import Mock, patch, AsyncMock, MagicMock
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Import MCP package components (from installed package)
# CRITICAL: Import MCP package BEFORE adding project to path
# to avoid shadowing the installed mcp package with our local mcp/ directory
try:
from mcp.server import Server
from mcp.types import Tool, TextContent
@@ -26,6 +24,9 @@ except ImportError:
MCP_AVAILABLE = False
print("Warning: MCP package not available, skipping MCP tests")
# NOW add parent directory to path for importing our local modules
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Import our local MCP server module
if MCP_AVAILABLE:
# Add mcp directory to path to import our server module