test: Implement comprehensive workspace isolation to protect user projects

- Add isolate_workspace autouse fixture in conftest.py.
- Monkeypatch SLOP_CONFIG and preset paths to point to a temporary test directory.
- Update test_history_management.py to use dynamic paths.get_config_path().
- Prevents tests from accidentally reading or modifying the active project.toml or config.toml.
This commit is contained in:
ed
2026-06-02 01:27:32 -04:00
parent 3528d6eb03
commit b3b9baf91f
2 changed files with 28 additions and 4 deletions
+3 -4
View File
@@ -28,11 +28,10 @@ def test_aggregate_includes_segregated_history() -> None:
def test_mcp_blacklist() -> None:
"""Tests that the MCP client correctly blacklists files"""
from src import mcp_client
from src.models import CONFIG_PATH
# CONFIG_PATH is usually something like 'config.toml'
assert mcp_client._is_allowed(Path("src/gui_2.py")) is True
from src import paths
# config.toml should be blacklisted for reading by the AI
assert mcp_client._is_allowed(Path(CONFIG_PATH)) is False
assert mcp_client._is_allowed(Path("src/gui_2.py")) is True
assert mcp_client._is_allowed(paths.get_config_path()) is False
def test_aggregate_blacklist() -> None:
"""Tests that aggregate correctly excludes blacklisted files"""