60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
import os
|
|
import pytest
|
|
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 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"
|
|
|
|
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"
|