Fix all tests: 297/297 passing, 0 skipped, 0 failed
CHANGES: 1. **Fixed 9 PDF Scraper Test Failures:** - Added .get() safety for missing page keys (headings, text, code_blocks, images) - Supported both 'code_samples' and 'code_blocks' keys for compatibility - Fixed extract_pdf() to raise RuntimeError on failure (tests expect exception) - Added image saving functionality to _generate_reference_file() - Updated all test methods to override skill_dir with temp directory - Fixed categorization to handle pre-categorized test data 2. **Fixed 25 MCP Test Skips:** - Renamed mcp/ directory to skill_seeker_mcp/ to avoid shadowing external mcp package - Updated all imports in tests/test_mcp_server.py - Simplified skill_seeker_mcp/server.py import logic (no more shadowing workarounds) - Updated tests/test_package_structure.py to reference skill_seeker_mcp 3. **Test Results:** - ✅ 297 tests passing (100%) - ✅ 0 tests skipped - ✅ 0 tests failed - All test categories passing: * 23 package structure tests * 18 PDF scraper tests * 67 PDF extractor/advanced tests * 25 MCP server tests * 164 other core tests BREAKING CHANGE: MCP server directory renamed from `mcp/` to `skill_seeker_mcp/` 📦 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -36,8 +36,8 @@ 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
|
||||
mcp_dir = Path(__file__).parent.parent / "mcp"
|
||||
# Add skill_seeker_mcp directory to path to import our server module
|
||||
mcp_dir = Path(__file__).parent.parent / "skill_seeker_mcp"
|
||||
sys.path.insert(0, str(mcp_dir))
|
||||
try:
|
||||
import server as skill_seeker_server
|
||||
|
||||
@@ -66,35 +66,35 @@ class TestCliPackage:
|
||||
|
||||
|
||||
class TestMcpPackage:
|
||||
"""Test mcp package structure and imports."""
|
||||
"""Test skill_seeker_mcp package structure and imports."""
|
||||
|
||||
def test_mcp_package_exists(self):
|
||||
"""Test that mcp package can be imported."""
|
||||
import mcp
|
||||
assert mcp is not None
|
||||
"""Test that skill_seeker_mcp package can be imported."""
|
||||
import skill_seeker_mcp
|
||||
assert skill_seeker_mcp is not None
|
||||
|
||||
def test_mcp_has_version(self):
|
||||
"""Test that mcp package has __version__."""
|
||||
import mcp
|
||||
assert hasattr(mcp, '__version__')
|
||||
assert mcp.__version__ == '1.2.0'
|
||||
"""Test that skill_seeker_mcp package has __version__."""
|
||||
import skill_seeker_mcp
|
||||
assert hasattr(skill_seeker_mcp, '__version__')
|
||||
assert skill_seeker_mcp.__version__ == '1.2.0'
|
||||
|
||||
def test_mcp_has_all(self):
|
||||
"""Test that mcp package has __all__ export list."""
|
||||
import mcp
|
||||
assert hasattr(mcp, '__all__')
|
||||
assert isinstance(mcp.__all__, list)
|
||||
"""Test that skill_seeker_mcp package has __all__ export list."""
|
||||
import skill_seeker_mcp
|
||||
assert hasattr(skill_seeker_mcp, '__all__')
|
||||
assert isinstance(skill_seeker_mcp.__all__, list)
|
||||
|
||||
def test_mcp_tools_package_exists(self):
|
||||
"""Test that mcp.tools subpackage can be imported."""
|
||||
import mcp.tools
|
||||
assert mcp.tools is not None
|
||||
"""Test that skill_seeker_mcp.tools subpackage can be imported."""
|
||||
import skill_seeker_mcp.tools
|
||||
assert skill_seeker_mcp.tools is not None
|
||||
|
||||
def test_mcp_tools_has_version(self):
|
||||
"""Test that mcp.tools has __version__."""
|
||||
import mcp.tools
|
||||
assert hasattr(mcp.tools, '__version__')
|
||||
assert mcp.tools.__version__ == '1.2.0'
|
||||
"""Test that skill_seeker_mcp.tools has __version__."""
|
||||
import skill_seeker_mcp.tools
|
||||
assert hasattr(skill_seeker_mcp.tools, '__version__')
|
||||
assert skill_seeker_mcp.tools.__version__ == '1.2.0'
|
||||
|
||||
|
||||
class TestPackageStructure:
|
||||
@@ -106,14 +106,14 @@ class TestPackageStructure:
|
||||
assert init_file.exists(), "cli/__init__.py not found"
|
||||
|
||||
def test_mcp_init_file_exists(self):
|
||||
"""Test that mcp/__init__.py exists."""
|
||||
init_file = Path(__file__).parent.parent / 'mcp' / '__init__.py'
|
||||
assert init_file.exists(), "mcp/__init__.py not found"
|
||||
"""Test that skill_seeker_mcp/__init__.py exists."""
|
||||
init_file = Path(__file__).parent.parent / 'skill_seeker_mcp' / '__init__.py'
|
||||
assert init_file.exists(), "skill_seeker_mcp/__init__.py not found"
|
||||
|
||||
def test_mcp_tools_init_file_exists(self):
|
||||
"""Test that mcp/tools/__init__.py exists."""
|
||||
init_file = Path(__file__).parent.parent / 'mcp' / 'tools' / '__init__.py'
|
||||
assert init_file.exists(), "mcp/tools/__init__.py not found"
|
||||
"""Test that skill_seeker_mcp/tools/__init__.py exists."""
|
||||
init_file = Path(__file__).parent.parent / 'skill_seeker_mcp' / 'tools' / '__init__.py'
|
||||
assert init_file.exists(), "skill_seeker_mcp/tools/__init__.py not found"
|
||||
|
||||
def test_cli_init_has_docstring(self):
|
||||
"""Test that cli/__init__.py has a module docstring."""
|
||||
@@ -122,10 +122,10 @@ class TestPackageStructure:
|
||||
assert len(cli.__doc__) > 50 # Should have substantial documentation
|
||||
|
||||
def test_mcp_init_has_docstring(self):
|
||||
"""Test that mcp/__init__.py has a module docstring."""
|
||||
import mcp
|
||||
assert mcp.__doc__ is not None
|
||||
assert len(mcp.__doc__) > 50 # Should have substantial documentation
|
||||
"""Test that skill_seeker_mcp/__init__.py has a module docstring."""
|
||||
import skill_seeker_mcp
|
||||
assert skill_seeker_mcp.__doc__ is not None
|
||||
assert len(skill_seeker_mcp.__doc__) > 50 # Should have substantial documentation
|
||||
|
||||
|
||||
class TestImportPatterns:
|
||||
@@ -150,11 +150,11 @@ class TestImportPatterns:
|
||||
def test_package_level_import(self):
|
||||
"""Test importing entire packages."""
|
||||
import cli
|
||||
import mcp
|
||||
import mcp.tools
|
||||
import skill_seeker_mcp
|
||||
import skill_seeker_mcp.tools
|
||||
assert 'cli' in sys.modules
|
||||
assert 'mcp' in sys.modules
|
||||
assert 'mcp.tools' in sys.modules
|
||||
assert 'skill_seeker_mcp' in sys.modules
|
||||
assert 'skill_seeker_mcp.tools' in sys.modules
|
||||
|
||||
|
||||
class TestBackwardsCompatibility:
|
||||
|
||||
@@ -211,6 +211,9 @@ class TestSkillBuilding(unittest.TestCase):
|
||||
}
|
||||
converter = self.PDFToSkillConverter(config)
|
||||
|
||||
# Override skill_dir to use temp directory
|
||||
converter.skill_dir = str(Path(self.temp_dir) / "test_skill")
|
||||
|
||||
# Mock extracted data
|
||||
converter.extracted_data = {
|
||||
"pages": [
|
||||
@@ -247,6 +250,9 @@ class TestSkillBuilding(unittest.TestCase):
|
||||
}
|
||||
converter = self.PDFToSkillConverter(config)
|
||||
|
||||
# Override skill_dir to use temp directory
|
||||
converter.skill_dir = str(Path(self.temp_dir) / "test_skill")
|
||||
|
||||
converter.extracted_data = {
|
||||
"pages": [{"page_number": 1, "text": "Test", "code_blocks": [], "images": []}],
|
||||
"total_pages": 1
|
||||
@@ -271,6 +277,9 @@ class TestSkillBuilding(unittest.TestCase):
|
||||
}
|
||||
converter = self.PDFToSkillConverter(config)
|
||||
|
||||
# Override skill_dir to use temp directory
|
||||
converter.skill_dir = str(Path(self.temp_dir) / "test_skill")
|
||||
|
||||
converter.extracted_data = {
|
||||
"pages": [
|
||||
{"page_number": 1, "text": "Getting started", "code_blocks": [], "images": []},
|
||||
@@ -314,6 +323,9 @@ class TestCodeBlockHandling(unittest.TestCase):
|
||||
}
|
||||
converter = self.PDFToSkillConverter(config)
|
||||
|
||||
# Override skill_dir to use temp directory
|
||||
converter.skill_dir = str(Path(self.temp_dir) / "test_skill")
|
||||
|
||||
# Mock data with code blocks
|
||||
converter.extracted_data = {
|
||||
"pages": [
|
||||
@@ -355,6 +367,9 @@ class TestCodeBlockHandling(unittest.TestCase):
|
||||
}
|
||||
converter = self.PDFToSkillConverter(config)
|
||||
|
||||
# Override skill_dir to use temp directory
|
||||
converter.skill_dir = str(Path(self.temp_dir) / "test_skill")
|
||||
|
||||
# Mock data with varying quality
|
||||
converter.extracted_data = {
|
||||
"pages": [
|
||||
@@ -402,6 +417,9 @@ class TestImageHandling(unittest.TestCase):
|
||||
}
|
||||
converter = self.PDFToSkillConverter(config)
|
||||
|
||||
# Override skill_dir to use temp directory
|
||||
converter.skill_dir = str(Path(self.temp_dir) / "test_skill")
|
||||
|
||||
# Mock image data (1x1 white PNG)
|
||||
mock_image_bytes = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\nIDATx\x9cc\x00\x01\x00\x00\x05\x00\x01\r\n-\xb4\x00\x00\x00\x00IEND\xaeB`\x82'
|
||||
|
||||
@@ -441,6 +459,9 @@ class TestImageHandling(unittest.TestCase):
|
||||
}
|
||||
converter = self.PDFToSkillConverter(config)
|
||||
|
||||
# Override skill_dir to use temp directory
|
||||
converter.skill_dir = str(Path(self.temp_dir) / "test_skill")
|
||||
|
||||
mock_image_bytes = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\nIDATx\x9cc\x00\x01\x00\x00\x05\x00\x01\r\n-\xb4\x00\x00\x00\x00IEND\xaeB`\x82'
|
||||
|
||||
converter.extracted_data = {
|
||||
|
||||
Reference in New Issue
Block a user