# Conflicts: # gateway/config.py # gateway/config_loader.py # gateway/readiness.py # hermes_cli/managed_scope.py # hermes_cli/plugin_python_deps.py # hermes_cli/plugins_cmd.py # hermes_cli/update_cmd_maint.py # plugin-catalog/hindsight.yaml # plugins/plugin_loader.py # providers/__init__.py # scripts/run_tests.sh # tests/gateway/test_control_socket_windows_live.py # tests/gateway/test_gateway_streaming_nested_config.py # tests/hermes_cli/test_doctor.py # tests/hermes_cli/test_plan_reconciliation_windows_live.py # tests/hermes_cli/test_update_apply_shallow_count.py # tests/hermes_cli/test_update_concurrent_quarantine.py # tests/hermes_cli/test_update_shim_self_lock.py # tests/hermes_cli/test_verify_console_scripts.py # tests/tools/test_lazy_deps.py # tests/tui_gateway/test_subprocess_encoding.py # tools/lazy_deps.py
60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
"""Tests for pet slash-command config helpers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
def test_pets_cli_quoted_false_disables_and_toggle_enables(tmp_path, monkeypatch):
|
|
"""Quoted `display.pet.enabled: "false"` must read as disabled.
|
|
|
|
bool('false') is True — before the is_truthy_value fix, _has_active_pet
|
|
reported an active pet and /pet toggle DISABLED instead of enabling.
|
|
"""
|
|
import hermes_yaml as yaml
|
|
|
|
from hermes_cli.pets import _has_active_pet, toggle_pet_display
|
|
|
|
home = tmp_path / ".hermes"
|
|
home.mkdir()
|
|
monkeypatch.setenv("HERMES_HOME", str(home))
|
|
(home / "config.yaml").write_text(
|
|
yaml.safe_dump(
|
|
{"display": {"pet": {"enabled": "false", "slug": "", "scale": 0.33}}}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
assert _has_active_pet() is False
|
|
# Toggle must take the ENABLE branch (reaching the "no pets installed"
|
|
# error), not the disable branch (which would return err=None).
|
|
enabled, name, err = toggle_pet_display()
|
|
assert err is not None and "no pets installed" in err
|
|
assert enabled is False
|
|
assert name is None
|
|
|
|
|
|
@pytest.fixture
|
|
def empty_home(tmp_path, monkeypatch):
|
|
home = tmp_path / ".hermes"
|
|
home.mkdir()
|
|
monkeypatch.setenv("HERMES_HOME", str(home))
|
|
return home
|
|
|
|
|
|
def test_set_pet_scale_writes_clamped_value(empty_home):
|
|
from agent.pet.constants import MAX_SCALE, MIN_SCALE
|
|
from hermes_cli.pets import _pet_config, set_pet_scale
|
|
|
|
applied, err = set_pet_scale("0.5")
|
|
assert err is None
|
|
assert applied == 0.5
|
|
assert _pet_config()["scale"] == 0.5
|
|
|
|
# Out-of-range values clamp to the bounds rather than erroring.
|
|
assert set_pet_scale(99) == (MAX_SCALE, None)
|
|
assert set_pet_scale(0) == (MIN_SCALE, None)
|
|
|
|
|