auto trim TOC, rewrite test to use actual MPC calls
This commit is contained in:
1 parent
6156a76a91
commit
aaa9b83949
8 files changed
+488
-171
No files matched your search
+24
-1
@@ -1,23 +1,36 @@
|
||||
"""Shared fixtures for pdf-mcp tests."""
|
||||
|
||||
import asyncio
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from pdf_mcp.server import mcp
|
||||
|
||||
ASSETS = Path(__file__).parent.parent / "assets"
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
"""Generate test PDFs before the test session if they don't exist."""
|
||||
expected = ["basic.pdf", "diagrams.pdf", "nested_toc.pdf", "search_targets.pdf"]
|
||||
expected = ["basic.pdf", "diagrams.pdf", "nested_toc.pdf", "search_targets.pdf", "large_toc.pdf", "mega_toc.pdf"]
|
||||
if not all((ASSETS / f).exists() for f in expected):
|
||||
subprocess.check_call(
|
||||
[sys.executable, str(ASSETS / "generate.py")],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def call_tool():
|
||||
"""Call an MCP tool by name, going through the real FastMCP call path."""
|
||||
def _call(tool_name: str, **kwargs):
|
||||
tools = mcp._tool_manager.list_tools()
|
||||
tool = next(t for t in tools if t.name == tool_name)
|
||||
return asyncio.run(tool.run(kwargs))
|
||||
return _call
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def basic_pdf() -> str:
|
||||
return str(ASSETS / "basic.pdf")
|
||||
@@ -36,3 +49,13 @@ def nested_toc_pdf() -> str:
|
||||
@pytest.fixture
|
||||
def search_pdf() -> str:
|
||||
return str(ASSETS / "search_targets.pdf")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def large_toc_pdf() -> str:
|
||||
return str(ASSETS / "large_toc.pdf")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mega_toc_pdf() -> str:
|
||||
return str(ASSETS / "mega_toc.pdf")
|
||||
Reference in new issue
Block a user