Files
hermes-agent/tests/hermes_cli/test_profile_memory_config.py
kshitijk4poor cd5375ac8b fix(profile): an unparseable config never fails the post-clone memory notice
`_load_config_dict` replaced main's `profiles._load_yaml_dict` (any
Exception -> None) but caught only YAMLError/OSError/UnicodeError. The
YAML constructors raise a bare ValueError for values such as
`2024-02-30` or `!!int abc`, so a clone of such a profile printed a
traceback from `hermes profile create` after the profile was already
made. Catch ValueError (which also covers UnicodeDecodeError).
ConfigBackendUnavailable still propagates: it is a SystemExit.
2026-10-25 18:54:09 -07:00

31 lines
1.1 KiB
Python

"""cloned_memory_provider: a best-effort post-clone notice that never fails ``hermes profile create``."""
import pytest
from hermes_cli.profile_memory_config import cloned_memory_provider
@pytest.mark.parametrize("body", [
"memory:\n provider: honcho\nwhen: 2024-02-30\n", # YAML constructor raises a bare ValueError
"memory: [unclosed\n", # YAMLError
b"memory:\n provider: \xff\n", # UnicodeDecodeError
])
def test_unreadable_config_means_no_notice(tmp_path, body):
(tmp_path / "honcho").mkdir()
path = tmp_path / "config.yaml"
if isinstance(body, bytes):
path.write_bytes(body)
else:
path.write_text(body, encoding="utf-8")
assert cloned_memory_provider(tmp_path) is None
def test_missing_config_means_no_notice(tmp_path):
assert cloned_memory_provider(tmp_path) is None
def test_configured_provider_with_copied_state_is_named(tmp_path):
(tmp_path / "honcho").mkdir()
(tmp_path / "config.yaml").write_text("memory:\n provider: honcho\n", encoding="utf-8")
assert cloned_memory_provider(tmp_path) == "honcho"