more adjustments
This commit is contained in:
@@ -9,25 +9,15 @@ def reset_paths():
|
||||
yield
|
||||
paths.reset_resolved()
|
||||
|
||||
def test_default_paths():
|
||||
def test_default_paths(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("SLOP_CONFIG", str(tmp_path / "non_existent.toml"))
|
||||
root_dir = Path(paths.__file__).resolve().parent.parent
|
||||
assert paths.get_conductor_dir() == root_dir / "conductor"
|
||||
assert paths.get_logs_dir() == root_dir / "logs/sessions"
|
||||
assert paths.get_scripts_dir() == root_dir / "scripts/generated"
|
||||
# config path should now be an absolute path relative to src/paths.py
|
||||
assert paths.get_config_path() == root_dir / "config.toml"
|
||||
assert paths.get_tracks_dir() == root_dir / "conductor/tracks"
|
||||
assert paths.get_archive_dir() == root_dir / "conductor/archive"
|
||||
# config path should be what we set in env
|
||||
assert paths.get_config_path() == tmp_path / "non_existent.toml"
|
||||
|
||||
def test_env_var_overrides(tmp_path, monkeypatch):
|
||||
root_dir = Path(paths.__file__).resolve().parent.parent
|
||||
|
||||
# Relative env var (resolved against root_dir)
|
||||
monkeypatch.setenv("SLOP_CONDUCTOR_DIR", "custom_conductor")
|
||||
assert paths.get_conductor_dir() == (root_dir / "custom_conductor").resolve()
|
||||
|
||||
paths.reset_resolved()
|
||||
|
||||
# Absolute env var
|
||||
abs_logs = (tmp_path / "abs_logs").resolve()
|
||||
monkeypatch.setenv("SLOP_LOGS_DIR", str(abs_logs))
|
||||
@@ -38,14 +28,12 @@ def test_config_overrides(tmp_path, monkeypatch):
|
||||
config_file = tmp_path / "custom_config.toml"
|
||||
content = """
|
||||
[paths]
|
||||
conductor_dir = "cfg_conductor"
|
||||
logs_dir = "cfg_logs"
|
||||
scripts_dir = "cfg_scripts"
|
||||
"""
|
||||
config_file.write_text(content)
|
||||
monkeypatch.setenv("SLOP_CONFIG", str(config_file))
|
||||
|
||||
assert paths.get_conductor_dir() == (root_dir / "cfg_conductor").resolve()
|
||||
assert paths.get_logs_dir() == root_dir / "cfg_logs"
|
||||
assert paths.get_scripts_dir() == root_dir / "cfg_scripts"
|
||||
|
||||
@@ -54,11 +42,20 @@ def test_precedence(tmp_path, monkeypatch):
|
||||
config_file = tmp_path / "custom_config.toml"
|
||||
content = """
|
||||
[paths]
|
||||
conductor_dir = "cfg_conductor"
|
||||
logs_dir = "cfg_logs"
|
||||
"""
|
||||
config_file.write_text(content)
|
||||
monkeypatch.setenv("SLOP_CONFIG", str(config_file))
|
||||
monkeypatch.setenv("SLOP_CONDUCTOR_DIR", "env_conductor")
|
||||
monkeypatch.setenv("SLOP_LOGS_DIR", "env_logs")
|
||||
|
||||
# Env var should take precedence over config
|
||||
assert paths.get_conductor_dir() == (root_dir / "env_conductor").resolve()
|
||||
assert paths.get_logs_dir() == (root_dir / "env_logs").resolve()
|
||||
|
||||
def test_conductor_dir_project_relative(tmp_path):
|
||||
# Should default to tmp_path/conductor
|
||||
project_path = str(tmp_path)
|
||||
base = (tmp_path / 'conductor').resolve()
|
||||
assert paths.get_conductor_dir(project_path) == base
|
||||
assert paths.get_tracks_dir(project_path) == base / "tracks"
|
||||
assert paths.get_archive_dir(project_path) == base / "archive"
|
||||
assert paths.get_track_state_dir("test_track", project_path) == base / "tracks" / "test_track"
|
||||
|
||||
Reference in New Issue
Block a user