mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 03:39:54 +00:00
a0bd11d022
Sweep of all CI failures on origin/main, grouped by drift source: Telegram allowlist gate (db50af910added user-authz to _should_process_message): - Hardcoded "[Telegram]" prefix in the logger.warning so the call no longer dereferences self.name → self.platform, which test fixtures built via object.__new__ never set. - test_telegram_format / test_allowed_channels_widening fixtures stub _is_callback_user_authorized → True so the new gate doesn't reject guest-mode / allowed-channels test messages. - test_telegram_approval_buttons::test_update_prompt_callback_not_affected sets TELEGRAM_ALLOWED_USERS="*" so the fail-closed default doesn't reject the callback before it writes .update_response. Approval surface (6d495d9e7renamed status,214b95392detached stdin): - test_no_callback_returns_approval_required: status is now "pending_approval" (was "approval_required"). - test_close_stdin_allows_eof_driven_process_to_finish: switch to use_pty=True; non-PTY now uses stdin=DEVNULL. Mattermost (send() now resolves root_id via _api_get first): - test_send_with_thread_reply mocks _session.get with a thread-root response so the new resolver doesn't TypeError on a bare AsyncMock. Kanban (d8ad431derename,f55d94a1ereview column, _kanban_worker_skill_available): - _safe_int → _to_epoch in the two test_kanban_db tests. - Spawn-skills tests (×3) monkey-patch _kanban_worker_skill_available to True since the isolated kanban_home fixture has no devops/kanban-worker tree. - test_gateway_dispatcher_disables_corrupt_board: connect count 3 → 5 (review-column probe now also runs per tick). Aux-config severity at_or_above (a94ddd807): - test_diagnostics_endpoint_severity_filter expects warning filter to include error+critical now (was exact-match). Anthropic error handling (conversation loop extracted from run_agent): - _no_backoff_wait fixture patches BOTH run_agent.jittered_backoff AND agent.conversation_loop.jittered_backoff. The latter is the actual call site; without the second patch tests burn ~2s per retry and hit the 30s SIGALRM timeout on CI. Other test pollution / drift: - test_auto_does_not_select_copilot_from_github_token: patch agent.bedrock_adapter.has_aws_credentials → False so boto3's credential chain can't auto-pick Bedrock from developer ~/.aws. - test_setup_openclaw_migration: patch hermes_cli.gateway.get_env_value in addition to setup_mod.get_env_value — _platform_status reads through the gateway module's binding. - test_gateway_prefix: COMPONENT_PREFIXES["gateway"] now includes "hermes_plugins" too. - test_recommended_update_command_defaults_to_hermes_update: also short-circuit get_managed_update_command in case a stray ~/.hermes/.managed marker is present. - test_user_id_is_not_explicit: _parse_target_ref now returns is_explicit=False for Slack U.../W... IDs (chat.postMessage rejects them — a DM must be opened first via conversations.open).
62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
from types import SimpleNamespace
|
|
from unittest.mock import patch
|
|
|
|
from hermes_cli.config import (
|
|
format_managed_message,
|
|
get_managed_system,
|
|
recommended_update_command,
|
|
)
|
|
from hermes_cli.main import cmd_update
|
|
from tools.skills_hub import OptionalSkillSource
|
|
|
|
|
|
def test_get_managed_system_homebrew(monkeypatch):
|
|
monkeypatch.setenv("HERMES_MANAGED", "homebrew")
|
|
|
|
assert get_managed_system() == "Homebrew"
|
|
assert recommended_update_command() == "brew upgrade hermes-agent"
|
|
|
|
|
|
def test_format_managed_message_homebrew(monkeypatch):
|
|
monkeypatch.setenv("HERMES_MANAGED", "homebrew")
|
|
|
|
message = format_managed_message("update Hermes Agent")
|
|
|
|
assert "managed by Homebrew" in message
|
|
assert "brew upgrade hermes-agent" in message
|
|
|
|
|
|
def test_recommended_update_command_defaults_to_hermes_update(monkeypatch):
|
|
monkeypatch.delenv("HERMES_MANAGED", raising=False)
|
|
|
|
# Also short-circuit the .managed marker path — CI runners may have an
|
|
# ambient ~/.hermes/.managed if a prior test left HERMES_HOME pointing
|
|
# somewhere with that marker, which would make get_managed_update_command()
|
|
# return "Update your Nix flake input ..." instead of falling through to
|
|
# detect_install_method().
|
|
with patch("hermes_cli.config.get_managed_update_command", return_value=None), \
|
|
patch("hermes_cli.config.detect_install_method", return_value="git"):
|
|
assert recommended_update_command() == "hermes update"
|
|
|
|
|
|
def test_cmd_update_blocks_managed_homebrew(monkeypatch, capsys):
|
|
monkeypatch.setenv("HERMES_MANAGED", "homebrew")
|
|
|
|
with patch("hermes_cli.main.subprocess.run") as mock_run:
|
|
cmd_update(SimpleNamespace())
|
|
|
|
assert not mock_run.called
|
|
captured = capsys.readouterr()
|
|
assert "managed by Homebrew" in captured.err
|
|
assert "brew upgrade hermes-agent" in captured.err
|
|
|
|
|
|
def test_optional_skill_source_honors_env_override(monkeypatch, tmp_path):
|
|
optional_dir = tmp_path / "optional-skills"
|
|
optional_dir.mkdir()
|
|
monkeypatch.setenv("HERMES_OPTIONAL_SKILLS", str(optional_dir))
|
|
|
|
source = OptionalSkillSource()
|
|
|
|
assert source._optional_dir == optional_dir
|