mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 19:32:45 +03:00
a070a5be33
main's ratchet caps every >2000-line facade at its main value; the PR grew seven. - config.py: `hermes config show` rendering -> hermes_cli/config_show.py (reads config names via the module at call time so hermes_cli.config.<name> patch seams hold). - backup.py: the cron prompt-field safety net -> hermes_cli/backup_cron_prompts.py; also drops a dead duplicate _PROTECTED_CONFIG_PATHS left by an earlier merge (the later definition won). restore_config_model_settings_* stay in backup: they are on the frozen old-updater surface. - profiles.py: Honcho host migration on rename -> hermes_cli/profiles_honcho.py. - plugins.py: resolve_plugin_command_result -> plugins_dispatch.py (re-exported from plugins, the public import path for cli/tui_gateway/plugins). - main.py: --query-file reader -> hermes_cli/main_query_file.py. - kanban_db.py: worker-context section renderers (_ctx_* + caps) -> hermes_cli/kanban_db_context.py; build_worker_context stays in kanban_db. - config_defaults.py: drop the blank line the gateway block gained. Patch-target retargets (moved symbols only): test_plugins.py (asyncio / await timeout now in plugins_dispatch), test_managed_scope_surfacing.py (show_config import), test_backup.py (restore_cron_prompt_fields_if_degraded import). (cherry picked from commit 4079d422e0c2283c500c16885e959f5c170eb6cf)
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
"""Surfacing tests — managed scope shown in `config show` and `hermes doctor`."""
|
|
import pytest
|
|
from hermes_cli import doctor_config
|
|
|
|
|
|
@pytest.fixture
|
|
def homes(tmp_path, monkeypatch):
|
|
home = tmp_path / "home"
|
|
home.mkdir()
|
|
managed = tmp_path / "managed"
|
|
managed.mkdir()
|
|
monkeypatch.setenv("HERMES_HOME", str(home))
|
|
monkeypatch.setenv("HERMES_MANAGED_DIR", str(managed))
|
|
(home / "config.yaml").write_text("model:\n default: user/model\n", encoding="utf-8")
|
|
(managed / "config.yaml").write_text(
|
|
"model:\n default: managed/model\n", encoding="utf-8"
|
|
)
|
|
import hermes_cli.config as cfg
|
|
from hermes_cli import managed_scope
|
|
|
|
cfg._LOAD_CONFIG_CACHE.clear()
|
|
cfg._RAW_CONFIG_CACHE.clear()
|
|
managed_scope.invalidate_managed_cache()
|
|
return home, managed
|
|
|
|
|
|
|
|
|
|
def test_config_show_no_managed_scope_silent(tmp_path, monkeypatch, capsys):
|
|
"""With no managed scope, the managed header must not appear."""
|
|
home = tmp_path / "home"
|
|
home.mkdir()
|
|
monkeypatch.setenv("HERMES_HOME", str(home))
|
|
monkeypatch.setenv("HERMES_MANAGED_DIR", str(tmp_path / "nope"))
|
|
(home / "config.yaml").write_text("model:\n default: user/model\n", encoding="utf-8")
|
|
import hermes_cli.config as cfg
|
|
from hermes_cli import managed_scope
|
|
|
|
cfg._LOAD_CONFIG_CACHE.clear()
|
|
cfg._RAW_CONFIG_CACHE.clear()
|
|
managed_scope.invalidate_managed_cache()
|
|
from hermes_cli.config_show import show_config
|
|
|
|
show_config()
|
|
out = capsys.readouterr().out.lower()
|
|
assert "managed by your administrator" not in out
|
|
|
|
|
|
|
|
|
|
def test_doctor_silent_with_no_managed_scope(tmp_path, monkeypatch, capsys):
|
|
monkeypatch.setenv("HERMES_MANAGED_DIR", str(tmp_path / "nope"))
|
|
from hermes_cli import managed_scope, doctor
|
|
|
|
managed_scope.invalidate_managed_cache()
|
|
doctor_config.managed_scope_check()
|
|
assert capsys.readouterr().out.strip() == ""
|