test_muse_working_dir.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
1 day ago
| 1 | """Unit tests for ``vcs.muse.working_dir`` (§K6.5.1).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from adapters.config import load_config |
| 10 | from adapters.errors import ConfigError |
| 11 | from adapters.factory import create_adapter |
| 12 | from cli.docs_paths import validate_muse_working_dir |
| 13 | from tests.support import PILOT, make_runner, ok |
| 14 | |
| 15 | |
| 16 | def test_working_dir_escape_raises(tmp_path: Path) -> None: |
| 17 | with pytest.raises(ConfigError): |
| 18 | validate_muse_working_dir(tmp_path, "../outside") |
| 19 | |
| 20 | |
| 21 | def test_working_dir_absolute_raises(tmp_path: Path) -> None: |
| 22 | with pytest.raises(ConfigError): |
| 23 | validate_muse_working_dir(tmp_path, "/tmp/elsewhere") |
| 24 | |
| 25 | |
| 26 | def test_working_dir_config_parse_rejects_dotdot(tmp_path: Path) -> None: |
| 27 | text = (PILOT / "config-musehub.yaml").read_text(encoding="utf-8") |
| 28 | text = text.replace("working_dir: musehub", "working_dir: ../escape") |
| 29 | cfg = tmp_path / "bad.yaml" |
| 30 | cfg.write_text(text, encoding="utf-8") |
| 31 | with pytest.raises(ConfigError): |
| 32 | load_config(cfg) |
| 33 | |
| 34 | |
| 35 | def test_musehub_adapter_uses_working_dir(tmp_path: Path) -> None: |
| 36 | (tmp_path / "musehub").mkdir() |
| 37 | config = load_config(PILOT / "config-musehub.yaml") |
| 38 | muse_cwd = (tmp_path / "musehub").resolve() |
| 39 | runner = make_runner( |
| 40 | { |
| 41 | f"muse -C {muse_cwd} branch --show-current": ok("main"), |
| 42 | f"muse -C {muse_cwd} status --porcelain": ok(""), |
| 43 | } |
| 44 | ) |
| 45 | adapter = create_adapter(config, tmp_path, runner=runner) |
| 46 | result = adapter.status() |
| 47 | assert not isinstance(result, Exception) |
| 48 | assert result.branch == "main" |
| 49 | assert any("musehub" in command for command, _cwd in runner.calls) |
File History
2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
1 day ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439
feat: K1-P1 complete — agent provenance, build-verification…
Sonnet 4.6
patch
52 days ago