diff --git a/backend/tests/test_env_paths.py b/backend/tests/test_env_paths.py index 372c29957..2eb4529c0 100644 --- a/backend/tests/test_env_paths.py +++ b/backend/tests/test_env_paths.py @@ -2,7 +2,12 @@ import pytest -from core.env_paths import expand_operator_path, operator_home +from core.env_paths import ( + ENV_FILE_PATHS, + expand_operator_path, + operator_env_file_paths, + operator_home, +) def test_operator_home_resolves_home_override(monkeypatch, tmp_path: Path) -> None: @@ -32,3 +37,26 @@ def test_expand_operator_path_rejects_home_escape(monkeypatch, tmp_path: Path) - with pytest.raises(ValueError, match="escapes"): expand_operator_path("~/../outside.env") + + +def test_operator_env_file_paths_default(monkeypatch, tmp_path: Path) -> None: + home = tmp_path / "home" + home.mkdir() + monkeypatch.setenv("HOME", str(home)) + + paths = operator_env_file_paths() + + assert paths == tuple(str(expand_operator_path(path)) for path in ENV_FILE_PATHS) + assert str(home.resolve() / ".env") in paths + + +def test_operator_env_file_paths_custom(monkeypatch, tmp_path: Path) -> None: + home = tmp_path / "home" + home.mkdir() + monkeypatch.setenv("HOME", str(home)) + + assert operator_env_file_paths(("~/.env.custom", "local.env", "~")) == ( + str(home.resolve() / ".env.custom"), + "local.env", + str(home.resolve()), + )