more adjustments

This commit is contained in:
2026-03-12 19:08:51 -04:00
parent 19e7c94c2e
commit 1f8bb58219
14 changed files with 272 additions and 213 deletions

View File

@@ -7,82 +7,53 @@ from src import paths
from src import project_manager
def test_get_conductor_dir_default():
paths.reset_resolved()
# Should return absolute path to "conductor" in project root
expected = Path(__file__).resolve().parent.parent / "conductor"
assert paths.get_conductor_dir() == expected
paths.reset_resolved()
# Should return absolute path to "conductor" in project root
expected = Path(__file__).resolve().parent.parent / "conductor"
assert paths.get_conductor_dir() == expected
def test_get_conductor_dir_project_specific_with_toml(tmp_path):
paths.reset_resolved()
project_root = tmp_path / "my_project"
project_root.mkdir()
# Create manual_slop.toml with custom conductor dir
toml_path = project_root / "manual_slop.toml"
config = {
"conductor": {
"dir": "custom_tracks"
}
}
with open(toml_path, "wb") as f:
f.write(tomli_w.dumps(config).encode())
res = paths.get_conductor_dir(project_path=str(project_root))
assert res == project_root / "custom_tracks"
paths.reset_resolved()
project_root = tmp_path / "my_project"
project_root.mkdir()
# Create manual_slop.toml with custom conductor dir
toml_path = project_root / "manual_slop.toml"
config = {
"conductor": {
"dir": "custom_tracks"
}
}
with open(toml_path, "wb") as f:
f.write(tomli_w.dumps(config).encode())
res = paths.get_conductor_dir(project_path=str(project_root))
assert res == project_root / "custom_tracks"
def test_get_all_tracks_project_specific(tmp_path):
paths.reset_resolved()
project_root = tmp_path / "my_project"
project_root.mkdir()
# Custom conductor dir
custom_dir = project_root / "my_conductor"
custom_dir.mkdir()
tracks_dir = custom_dir / "tracks"
tracks_dir.mkdir()
# Create a dummy track
track_dir = tracks_dir / "test_track_20260312"
track_dir.mkdir()
with open(track_dir / "metadata.json", "w") as f:
json.dump({"id": "test_track", "title": "Test Track"}, f)
# Setup manual_slop.toml
toml_path = project_root / "manual_slop.toml"
config = {"conductor": {"dir": "my_conductor"}}
with open(toml_path, "wb") as f:
f.write(tomli_w.dumps(config).encode())
# project_manager.get_all_tracks(base_dir) should now find it
tracks = project_manager.get_all_tracks(str(project_root))
assert len(tracks) == 1
assert tracks[0]["title"] == "Test Track"
def test_get_all_tracks_global_fallback(tmp_path):
paths.reset_resolved()
# Create a directory without manual_slop.toml
empty_dir = tmp_path / "empty_project"
empty_dir.mkdir()
# Setup a fake global conductor
global_conductor = tmp_path / "global_conductor"
global_conductor.mkdir()
global_tracks = global_conductor / "tracks"
global_tracks.mkdir()
track_dir = global_tracks / "global_track"
track_dir.mkdir()
with open(track_dir / "metadata.json", "w") as f:
json.dump({"id": "global_track", "title": "Global Track"}, f)
# Override global conductor dir via env var
os.environ["SLOP_CONDUCTOR_DIR"] = str(global_conductor)
try:
paths.reset_resolved()
# Pass project_path pointing to a dir without TOML
tracks = project_manager.get_all_tracks(str(empty_dir))
# paths.get_conductor_dir(str(empty_dir)) should fall back to global
assert any(t["id"] == "global_track" for t in tracks)
finally:
del os.environ["SLOP_CONDUCTOR_DIR"]
paths.reset_resolved()
project_root = tmp_path / "my_project"
project_root.mkdir()
# Custom conductor dir
custom_dir = project_root / "my_conductor"
custom_dir.mkdir()
tracks_dir = custom_dir / "tracks"
tracks_dir.mkdir()
# Create a dummy track
track_dir = tracks_dir / "test_track_20260312"
track_dir.mkdir()
with open(track_dir / "metadata.json", "w") as f:
json.dump({"id": "test_track", "title": "Test Track"}, f)
# Setup manual_slop.toml
toml_path = project_root / "manual_slop.toml"
config = {"conductor": {"dir": "my_conductor"}}
with open(toml_path, "wb") as f:
f.write(tomli_w.dumps(config).encode())
# project_manager.get_all_tracks(base_dir) should now find it
tracks = project_manager.get_all_tracks(str(project_root))
assert len(tracks) == 1
assert tracks[0]["title"] == "Test Track"