fix: Add TextContent fallback class for test compatibility

- Replace TextContent = None with proper fallback class in all MCP tool modules
- Fixes TypeError when MCP library is not fully initialized in test environment
- Ensures all 700 tests pass (was 699 passing, 1 failing)
- Affected files:
  * packaging_tools.py
  * config_tools.py
  * scraping_tools.py
  * source_tools.py
  * splitting_tools.py

The fallback class maintains the same interface as mcp.types.TextContent,
allowing tests to run successfully even when the MCP library import fails.

Test results:  700 passed, 157 skipped, 2 warnings
This commit is contained in:
yusyus
2025-12-28 21:40:31 +03:00
parent 891ce2dbc6
commit 2ec2840396
5 changed files with 30 additions and 5 deletions

View File

@@ -13,7 +13,12 @@ from typing import Any, List
try:
from mcp.types import TextContent
except ImportError:
TextContent = None
# Graceful degradation: Create a simple fallback class for testing
class TextContent:
"""Fallback TextContent for when MCP is not installed"""
def __init__(self, type: str, text: str):
self.type = type
self.text = text
# Path to CLI tools
CLI_DIR = Path(__file__).parent.parent.parent / "cli"

View File

@@ -18,7 +18,12 @@ from typing import Any, List, Tuple
try:
from mcp.types import TextContent
except ImportError:
TextContent = None # Graceful degradation
# Graceful degradation: Create a simple fallback class for testing
class TextContent:
"""Fallback TextContent for when MCP is not installed"""
def __init__(self, type: str, text: str):
self.type = type
self.text = text
# Path to CLI tools

View File

@@ -19,7 +19,12 @@ from typing import Any, List
try:
from mcp.types import TextContent
except ImportError:
TextContent = None # Graceful degradation for testing
# Graceful degradation: Create a simple fallback class for testing
class TextContent:
"""Fallback TextContent for when MCP is not installed"""
def __init__(self, type: str, text: str):
self.type = type
self.text = text
# Path to CLI tools
CLI_DIR = Path(__file__).parent.parent.parent / "cli"

View File

@@ -20,7 +20,12 @@ try:
from mcp.types import TextContent
MCP_AVAILABLE = True
except ImportError:
TextContent = None
# Graceful degradation: Create a simple fallback class for testing
class TextContent:
"""Fallback TextContent for when MCP is not installed"""
def __init__(self, type: str, text: str):
self.type = type
self.text = text
MCP_AVAILABLE = False
import httpx

View File

@@ -13,7 +13,12 @@ from typing import Any, List
try:
from mcp.types import TextContent
except ImportError:
TextContent = None
# Graceful degradation: Create a simple fallback class for testing
class TextContent:
"""Fallback TextContent for when MCP is not installed"""
def __init__(self, type: str, text: str):
self.type = type
self.text = text
# Path to CLI tools
CLI_DIR = Path(__file__).parent.parent.parent / "cli"