from __future__ import annotations from pathlib import Path from deerflow.config.app_config import AppConfig def test_relative_sandbox_mount_is_resolved_from_config_directory(tmp_path: Path) -> None: knowledge_dir = tmp_path / "knowledge" / "knowledge_base" knowledge_dir.mkdir(parents=True) config_path = tmp_path / "config.yaml" config_path.write_text( """ sandbox: use: deerflow.sandbox.local:LocalSandboxProvider mounts: - host_path: knowledge/knowledge_base container_path: /mnt/knowledge read_only: true """.strip(), encoding="utf-8", ) config = AppConfig.from_file(str(config_path)) assert config.sandbox.mounts[0].host_path == str(knowledge_dir.resolve()) assert Path(config.sandbox.mounts[0].host_path).is_absolute() def test_absolute_sandbox_mount_is_preserved(tmp_path: Path) -> None: absolute_mount = (tmp_path / "shared").resolve() config_data = { "sandbox": { "use": "deerflow.sandbox.local:LocalSandboxProvider", "mounts": [ { "host_path": str(absolute_mount), "container_path": "/mnt/shared", } ], } } AppConfig._resolve_relative_mount_paths(config_data, tmp_path / "elsewhere") assert config_data["sandbox"]["mounts"][0]["host_path"] == str(absolute_mount)