Files
hermes-agent/tests/hermes_cli/test_deprecated_cwd_warning.py
红尘 d73ff9b0fb
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docker / shell lint / Lint Dockerfile (hadolint) (push) Has been cancelled
Docker / shell lint / Lint docker/ shell scripts (shellcheck) (push) Has been cancelled
Docker Build and Publish / build-amd64 (push) Has been cancelled
Docker Build and Publish / build-arm64 (push) Has been cancelled
Lint (ruff + ty) / ruff + ty diff (push) Has been cancelled
Lint (ruff + ty) / ruff enforcement (blocking) (push) Has been cancelled
Lint (ruff + ty) / Windows footguns (blocking) (push) Has been cancelled
Nix Lockfile Fix / auto-fix-main (push) Has been cancelled
Nix Lockfile Fix / fix (push) Has been cancelled
Nix / nix (macos-latest) (push) Has been cancelled
Nix / nix (ubuntu-latest) (push) Has been cancelled
OSV-Scanner / Scan lockfiles (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Tests / test (1) (push) Has been cancelled
Tests / test (2) (push) Has been cancelled
Tests / test (3) (push) Has been cancelled
Tests / test (4) (push) Has been cancelled
Tests / test (5) (push) Has been cancelled
Tests / test (6) (push) Has been cancelled
Tests / e2e (push) Has been cancelled
uv.lock check / uv lock --check (push) Has been cancelled
Docker Build and Publish / merge (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Tests / save-durations (push) Has been cancelled
Initial import of NousResearch/hermes-agent
2026-05-31 09:36:58 +08:00

63 lines
2.5 KiB
Python

"""Tests for warn_deprecated_cwd_env_vars() migration warning."""
class TestDeprecatedCwdWarning:
"""Warn when MESSAGING_CWD or TERMINAL_CWD is set in .env."""
def test_messaging_cwd_triggers_warning(self, monkeypatch, capsys):
monkeypatch.setenv("MESSAGING_CWD", "/some/path")
monkeypatch.delenv("TERMINAL_CWD", raising=False)
from hermes_cli.config import warn_deprecated_cwd_env_vars
warn_deprecated_cwd_env_vars(config={})
captured = capsys.readouterr()
assert "MESSAGING_CWD" in captured.err
assert "deprecated" in captured.err.lower()
assert "config.yaml" in captured.err
def test_terminal_cwd_triggers_warning_when_config_placeholder(self, monkeypatch, capsys):
monkeypatch.setenv("TERMINAL_CWD", "/project")
monkeypatch.delenv("MESSAGING_CWD", raising=False)
from hermes_cli.config import warn_deprecated_cwd_env_vars
# config has placeholder cwd → TERMINAL_CWD likely from .env
warn_deprecated_cwd_env_vars(config={"terminal": {"cwd": "."}})
captured = capsys.readouterr()
assert "TERMINAL_CWD" in captured.err
assert "deprecated" in captured.err.lower()
def test_no_warning_when_config_has_explicit_cwd(self, monkeypatch, capsys):
monkeypatch.setenv("TERMINAL_CWD", "/project")
monkeypatch.delenv("MESSAGING_CWD", raising=False)
from hermes_cli.config import warn_deprecated_cwd_env_vars
# config has explicit cwd → TERMINAL_CWD could be from config bridge
warn_deprecated_cwd_env_vars(config={"terminal": {"cwd": "/project"}})
captured = capsys.readouterr()
assert "TERMINAL_CWD" not in captured.err
def test_no_warning_when_env_clean(self, monkeypatch, capsys):
monkeypatch.delenv("MESSAGING_CWD", raising=False)
monkeypatch.delenv("TERMINAL_CWD", raising=False)
from hermes_cli.config import warn_deprecated_cwd_env_vars
warn_deprecated_cwd_env_vars(config={})
captured = capsys.readouterr()
assert captured.err == ""
def test_both_deprecated_vars_warn(self, monkeypatch, capsys):
monkeypatch.setenv("MESSAGING_CWD", "/msg/path")
monkeypatch.setenv("TERMINAL_CWD", "/term/path")
from hermes_cli.config import warn_deprecated_cwd_env_vars
warn_deprecated_cwd_env_vars(config={})
captured = capsys.readouterr()
assert "MESSAGING_CWD" in captured.err
assert "TERMINAL_CWD" in captured.err