Files
EvoScientist/tests/test_mineru_server_paths.py
T
m4 c2743251e9 Initial commit of EvoScientist framework
Self-evolving AI scientist framework built on LangGraph/LangChain with
CLI/TUI core, FastAPI gateway, and Next.js frontend.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
2026-07-13 08:07:45 +08:00

31 lines
1010 B
Python

from pathlib import Path
from EvoScientist.mcp.mineru_server import _resolve_file_path
def test_resolve_file_path_accepts_workspace_relative_path(monkeypatch, tmp_path):
workspace = tmp_path / "workspace"
uploads = workspace / "uploads"
uploads.mkdir(parents=True)
target = uploads / "paper.pdf"
target.write_bytes(b"%PDF-1.7\n")
monkeypatch.chdir(workspace)
assert _resolve_file_path("uploads/paper.pdf") == target.resolve()
assert _resolve_file_path("paper.pdf") == target.resolve()
def test_resolve_file_path_rejects_absolute_path_outside_workspace(monkeypatch, tmp_path):
workspace = tmp_path / "workspace"
outside = tmp_path / "other_user" / "secret.pdf"
workspace.mkdir()
outside.parent.mkdir()
outside.write_bytes(b"%PDF-1.7\n")
monkeypatch.chdir(workspace)
resolved = _resolve_file_path(str(outside))
assert resolved != outside.resolve()
assert resolved == workspace / "__outside_workspace__"
assert not resolved.exists()