Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion backend/tests/test_env_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()),
)
Loading