Doctor-only override so honcho shows as available when configured, even outside a live agent session. Runtime tool gate unchanged. Cherry-picked from PR #962 by PeterFile, rebased onto current main (post-#736 merge) with conflict resolution. Fixes #961 Co-authored-by: PeterFile <PeterFile@users.noreply.github.com>
68 lines
2.4 KiB
Python
68 lines
2.4 KiB
Python
"""Tests for hermes doctor helpers."""
|
|
|
|
from types import SimpleNamespace
|
|
|
|
import hermes_cli.doctor as doctor
|
|
from hermes_cli.doctor import _has_provider_env_config
|
|
|
|
|
|
class TestProviderEnvDetection:
|
|
def test_detects_openai_api_key(self):
|
|
content = "OPENAI_BASE_URL=http://localhost:1234/v1\nOPENAI_API_KEY=sk-test-key\n"
|
|
assert _has_provider_env_config(content)
|
|
|
|
def test_detects_custom_endpoint_without_openrouter_key(self):
|
|
content = "OPENAI_BASE_URL=http://localhost:8080/v1\n"
|
|
assert _has_provider_env_config(content)
|
|
|
|
def test_returns_false_when_no_provider_settings(self):
|
|
content = "TERMINAL_ENV=local\n"
|
|
assert not _has_provider_env_config(content)
|
|
|
|
|
|
class TestDoctorToolAvailabilityOverrides:
|
|
def test_marks_honcho_available_when_configured(self, monkeypatch):
|
|
monkeypatch.setattr(doctor, "_honcho_is_configured_for_doctor", lambda: True)
|
|
|
|
available, unavailable = doctor._apply_doctor_tool_availability_overrides(
|
|
[],
|
|
[{"name": "honcho", "env_vars": [], "tools": ["query_user_context"]}],
|
|
)
|
|
|
|
assert available == ["honcho"]
|
|
assert unavailable == []
|
|
|
|
def test_leaves_honcho_unavailable_when_not_configured(self, monkeypatch):
|
|
monkeypatch.setattr(doctor, "_honcho_is_configured_for_doctor", lambda: False)
|
|
|
|
honcho_entry = {"name": "honcho", "env_vars": [], "tools": ["query_user_context"]}
|
|
available, unavailable = doctor._apply_doctor_tool_availability_overrides(
|
|
[],
|
|
[honcho_entry],
|
|
)
|
|
|
|
assert available == []
|
|
assert unavailable == [honcho_entry]
|
|
|
|
|
|
class TestHonchoDoctorConfigDetection:
|
|
def test_reports_configured_when_enabled_with_api_key(self, monkeypatch):
|
|
fake_config = SimpleNamespace(enabled=True, api_key="honcho-test-key")
|
|
|
|
monkeypatch.setattr(
|
|
"honcho_integration.client.HonchoClientConfig.from_global_config",
|
|
lambda: fake_config,
|
|
)
|
|
|
|
assert doctor._honcho_is_configured_for_doctor()
|
|
|
|
def test_reports_not_configured_without_api_key(self, monkeypatch):
|
|
fake_config = SimpleNamespace(enabled=True, api_key=None)
|
|
|
|
monkeypatch.setattr(
|
|
"honcho_integration.client.HonchoClientConfig.from_global_config",
|
|
lambda: fake_config,
|
|
)
|
|
|
|
assert not doctor._honcho_is_configured_for_doctor()
|