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
51 lines
2.3 KiB
Python
51 lines
2.3 KiB
Python
"""Tests for `hermes memory setup [provider]` routing.
|
|
|
|
The `memory setup` subcommand accepts an optional positional ``provider`` so a
|
|
fresh install can configure a specific provider directly (e.g.
|
|
``hermes memory setup honcho``) without the interactive picker — which matters
|
|
because the per-provider ``hermes <provider>`` subcommand is only registered
|
|
once that provider is active.
|
|
"""
|
|
|
|
from types import SimpleNamespace
|
|
from unittest.mock import patch
|
|
|
|
from hermes_cli import memory_setup
|
|
|
|
|
|
class TestMemorySetupProviderRouting:
|
|
def test_setup_with_provider_arg_skips_picker(self):
|
|
"""`memory setup honcho` routes straight to cmd_setup_provider."""
|
|
args = SimpleNamespace(memory_command="setup", provider="honcho")
|
|
with patch.object(memory_setup, "cmd_setup_provider") as direct, \
|
|
patch.object(memory_setup, "cmd_setup") as picker:
|
|
memory_setup.memory_command(args)
|
|
direct.assert_called_once_with("honcho")
|
|
picker.assert_not_called()
|
|
|
|
def test_setup_without_provider_runs_picker(self):
|
|
"""`memory setup` (no provider) runs the interactive picker."""
|
|
args = SimpleNamespace(memory_command="setup", provider=None)
|
|
with patch.object(memory_setup, "cmd_setup_provider") as direct, \
|
|
patch.object(memory_setup, "cmd_setup") as picker:
|
|
memory_setup.memory_command(args)
|
|
picker.assert_called_once_with(args)
|
|
direct.assert_not_called()
|
|
|
|
def test_setup_with_missing_provider_attr_runs_picker(self):
|
|
"""A SimpleNamespace lacking `provider` must not crash — fall back to picker."""
|
|
args = SimpleNamespace(memory_command="setup")
|
|
with patch.object(memory_setup, "cmd_setup_provider") as direct, \
|
|
patch.object(memory_setup, "cmd_setup") as picker:
|
|
memory_setup.memory_command(args)
|
|
picker.assert_called_once_with(args)
|
|
direct.assert_not_called()
|
|
|
|
def test_unknown_provider_reports_and_returns_early(self, capsys):
|
|
"""An unknown provider name surfaces a helpful message and returns
|
|
before any config load/save (the not-found guard precedes those imports)."""
|
|
memory_setup.cmd_setup_provider("notaprovider")
|
|
out = capsys.readouterr().out
|
|
assert "not found" in out
|
|
assert "hermes memory setup" in out
|