stuff that was not comitted.
This commit is contained in:
@@ -1,25 +1,17 @@
|
||||
import os
|
||||
import pytest
|
||||
import tomllib
|
||||
import json
|
||||
import tomli_w
|
||||
from pathlib import Path
|
||||
from src import paths
|
||||
from src import project_manager
|
||||
|
||||
def test_get_conductor_dir_default():
|
||||
paths.reset_resolved()
|
||||
# Should return default "conductor" relative to root
|
||||
# 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_no_toml(tmp_path):
|
||||
paths.reset_resolved()
|
||||
project_root = tmp_path / "my_project"
|
||||
project_root.mkdir()
|
||||
|
||||
# Should default to project_root / "conductor" if no manual_slop.toml
|
||||
res = paths.get_conductor_dir(project_path=str(project_root))
|
||||
assert res == project_root / "conductor"
|
||||
|
||||
def test_get_conductor_dir_project_specific_with_toml(tmp_path):
|
||||
paths.reset_resolved()
|
||||
project_root = tmp_path / "my_project"
|
||||
@@ -38,18 +30,59 @@ def test_get_conductor_dir_project_specific_with_toml(tmp_path):
|
||||
res = paths.get_conductor_dir(project_path=str(project_root))
|
||||
assert res == project_root / "custom_tracks"
|
||||
|
||||
def test_get_tracks_dir_project_specific(tmp_path):
|
||||
def test_get_all_tracks_project_specific(tmp_path):
|
||||
paths.reset_resolved()
|
||||
project_root = tmp_path / "my_project"
|
||||
project_root.mkdir()
|
||||
|
||||
res = paths.get_tracks_dir(project_path=str(project_root))
|
||||
assert res == project_root / "conductor" / "tracks"
|
||||
# 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_track_state_dir_project_specific(tmp_path):
|
||||
def test_get_all_tracks_global_fallback(tmp_path):
|
||||
paths.reset_resolved()
|
||||
project_root = tmp_path / "my_project"
|
||||
project_root.mkdir()
|
||||
|
||||
res = paths.get_track_state_dir("track-123", project_path=str(project_root))
|
||||
assert res == project_root / "conductor" / "tracks" / "track-123"
|
||||
# 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"]
|
||||
|
||||
Reference in New Issue
Block a user