mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Production fixes: - voice_mode.py: add is_recording property to AudioRecorder (parity with TermuxAudioRecorder) - cronjob_tools.py: add sms example to deliver description Test fixes: - test_real_interrupt_subagent: add missing _execution_thread_id (fixes 19 cascading failures from leaked _build_system_prompt patch) - test_anthropic_error_handling: add _FakeMessages, override _interruptible_streaming_api_call (6 fixes) - test_ctx_halving_fix: add missing request_overrides attribute (4 fixes) - test_context_token_tracking: set _disable_streaming=True for non-streaming test path (4 fixes) - test_dict_tool_call_args: set _disable_streaming=True (1 fix) - test_provider_parity: add model='gpt-4o' for AIGateway tests to meet 64K minimum context (4 fixes) - test_session_race_guard: add user_id to SessionSource (5 fixes) - test_restart_drain/helpers: add user_id to SessionSource (2 fixes) - test_telegram_photo_interrupts: add user_id to SessionSource - test_interrupt: target thread_id for per-thread interrupt system (2 fixes) - test_zombie_process_cleanup: rewrite with object.__new__ for refactored GatewayRunner.stop() (1 fix) - test_browser_camofox_state: update config version 15->17 (1 fix) - test_trajectory_compressor_async: widen lookback window 10->20 for line-shifted AsyncOpenAI (1 fix) - test_voice_mode: fixed by production is_recording addition (5 fixes) - test_voice_cli_integration: add _attached_images to CLI stub (2 fixes) - test_hermes_logging: explicit propagation/level reset for cross-test pollution defense (1 fix) - test_run_agent: add base_url for OpenRouter detection tests (2 fixes) Deleted: - test_inline_think_blocks_reasoning_only_accepted: tested unimplemented inline <think> handling
67 lines
2.6 KiB
Python
67 lines
2.6 KiB
Python
"""Tests for Hermes-managed Camofox state helpers."""
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
|
|
def _load_module():
|
|
from tools import browser_camofox_state as state
|
|
return state
|
|
|
|
|
|
class TestCamofoxStatePaths:
|
|
def test_paths_are_profile_scoped(self, tmp_path):
|
|
state = _load_module()
|
|
with patch.object(state, "get_hermes_home", return_value=tmp_path):
|
|
assert state.get_camofox_state_dir() == tmp_path / "browser_auth" / "camofox"
|
|
|
|
|
|
class TestCamofoxIdentity:
|
|
def test_identity_is_deterministic(self, tmp_path):
|
|
state = _load_module()
|
|
with patch.object(state, "get_hermes_home", return_value=tmp_path):
|
|
first = state.get_camofox_identity("task-1")
|
|
second = state.get_camofox_identity("task-1")
|
|
assert first == second
|
|
|
|
def test_identity_differs_by_task(self, tmp_path):
|
|
state = _load_module()
|
|
with patch.object(state, "get_hermes_home", return_value=tmp_path):
|
|
a = state.get_camofox_identity("task-a")
|
|
b = state.get_camofox_identity("task-b")
|
|
# Same user (same profile), different session keys
|
|
assert a["user_id"] == b["user_id"]
|
|
assert a["session_key"] != b["session_key"]
|
|
|
|
def test_identity_differs_by_profile(self, tmp_path):
|
|
state = _load_module()
|
|
with patch.object(state, "get_hermes_home", return_value=tmp_path / "profile-a"):
|
|
a = state.get_camofox_identity("task-1")
|
|
with patch.object(state, "get_hermes_home", return_value=tmp_path / "profile-b"):
|
|
b = state.get_camofox_identity("task-1")
|
|
assert a["user_id"] != b["user_id"]
|
|
|
|
def test_default_task_id(self, tmp_path):
|
|
state = _load_module()
|
|
with patch.object(state, "get_hermes_home", return_value=tmp_path):
|
|
identity = state.get_camofox_identity()
|
|
assert "user_id" in identity
|
|
assert "session_key" in identity
|
|
assert identity["user_id"].startswith("hermes_")
|
|
assert identity["session_key"].startswith("task_")
|
|
|
|
|
|
class TestCamofoxConfigDefaults:
|
|
def test_default_config_includes_managed_persistence_toggle(self):
|
|
from hermes_cli.config import DEFAULT_CONFIG
|
|
|
|
browser_cfg = DEFAULT_CONFIG["browser"]
|
|
assert browser_cfg["camofox"]["managed_persistence"] is False
|
|
|
|
def test_config_version_matches_current_schema(self):
|
|
from hermes_cli.config import DEFAULT_CONFIG
|
|
|
|
# The current schema version is tracked globally; unrelated default
|
|
# options may bump it after browser defaults are added.
|
|
assert DEFAULT_CONFIG["_config_version"] == 17
|