The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tests): stub the auth function doctor actually calls + restore dropped parametrize cases
Teknium50d4d25ca224
diff --git a/tests/hermes_cli/test_doctor.py b/tests/hermes_cli/test_doctor.pyindex 1897e8d5e27..c0d7316fd7d 100644--- a/tests/hermes_cli/test_doctor.py+++ b/tests/hermes_cli/test_doctor.py@@ -411,114 +411,6 @@ def test_run_doctor_accepts_stable_key_when_provider_name_differs(assert "model.provider 'custom:local-127.0.0.1:11434' is unknown" not in out-def test_run_doctor_accepts_vendor_slugs_for_named_custom_provider(monkeypatch, tmp_path):- home = tmp_path / ".hermes"- home.mkdir(parents=True, exist_ok=True)- (home / "config.yaml").write_text(- "model:\n"- " provider: custom:hpc-ai\n"- " default: deepseek/deepseek-v4-flash\n"- "custom_providers:\n"- " - name: hpc-ai\n"- " base_url: https://hpc-ai.example/v1\n"- " api_key: test-key\n",- encoding="utf-8",- )-- monkeypatch.setattr(doctor_mod, "HERMES_HOME", home)- monkeypatch.setattr(doctor_mod, "PROJECT_ROOT", tmp_path / "project")- monkeypatch.setattr(doctor_mod, "_DHH", str(home))- (tmp_path / "project").mkdir(exist_ok=True)-- fake_model_tools = types.SimpleNamespace(- check_tool_availability=lambda *a, **kw: ([], []),- TOOLSET_REQUIREMENTS={},- )- monkeypatch.setitem(sys.modules, "model_tools", fake_model_tools)-- try:- from hermes_cli import auth as _auth_mod- monkeypatch.setattr(_auth_mod, "get_nous_auth_status_local", lambda: {})- monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})- monkeypatch.setattr(_auth_mod, "get_xai_oauth_auth_status", lambda: {})- except Exception:- pass-- buf = io.StringIO()- with contextlib.redirect_stdout(buf):- doctor_mod.run_doctor(Namespace(fix=False))-- out = buf.getvalue()- assert "model.provider 'custom:hpc-ai' is not a recognised provider" not in out- assert "model.provider 'custom:hpc-ai' is unknown" not in out- assert (- "model.default 'deepseek/deepseek-v4-flash' uses a vendor/model slug but provider is "- "'custom:hpc-ai'"- not in out- )- assert "Either set model.provider to 'openrouter', or drop the vendor prefix." not in out-----def _run_doctor_with_managed_agent_browser(monkeypatch, tmp_path, runnable):- """Set up run_doctor with node present, agent-browser only in the- Hermes-managed node bin (~/.hermes/node/bin), not on PATH or in- PROJECT_ROOT/node_modules. Returns the captured stdout."""- home = tmp_path / ".hermes"- (home / "node" / "bin").mkdir(parents=True, exist_ok=True)- (home / "config.yaml").write_text("memory: {}\n", encoding="utf-8")- managed_ab = home / "node" / "bin" / "agent-browser"- managed_ab.write_text("#!/bin/sh\n", encoding="utf-8")- managed_ab.chmod(0o755)- project = tmp_path / "project"- project.mkdir(exist_ok=True) # no node_modules/agent-browser here-- monkeypatch.delenv("TERMUX_VERSION", raising=False)- monkeypatch.delenv("PREFIX", raising=False)- monkeypatch.setattr(doctor_mod, "HERMES_HOME", home)- monkeypatch.setattr(doctor_mod, "PROJECT_ROOT", project)- monkeypatch.setattr(doctor_mod, "_DHH", str(home))-- # node on PATH, agent-browser is NOT on PATH (only in the managed bin).- # The managed-dir rung resolves via shutil.which(..., path=<dir>) so- # Windows picks the .cmd shim — mirror that shape here.- def _fake_which(cmd, path=None):- if path is not None:- if cmd == "agent-browser" and str(managed_ab.parent) == str(path):- return str(managed_ab)- return None- return "/usr/bin/node" if cmd in {"node", "npm"} else None-- monkeypatch.setattr(doctor_mod.shutil, "which", _fake_which)- # agent_browser_runnable is imported into doctor's namespace- monkeypatch.setattr(- doctor_mod,- "agent_browser_runnable",- lambda path: runnable and str(path) == str(managed_ab),- )-- fake_model_tools = types.SimpleNamespace(- check_tool_availability=lambda *a, **kw: ([], []),- TOOLSET_REQUIREMENTS={},- )- monkeypatch.setitem(sys.modules, "model_tools", fake_model_tools)-- try:- from hermes_cli import auth as _auth_mod- monkeypatch.setattr(_auth_mod, "get_nous_auth_status", lambda: {})- monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})- monkeypatch.setattr(_auth_mod, "get_xai_oauth_auth_status", lambda: {})- except Exception:- pass-- buf = io.StringIO()- with contextlib.redirect_stdout(buf):- doctor_mod.run_doctor(Namespace(fix=False))- return buf.getvalue()---def test_run_doctor_accepts_bare_custom_provider(monkeypatch, tmp_path):home = tmp_path / ".hermes"home.mkdir(parents=True, exist_ok=True)@@ -543,7 +435,7 @@ def test_run_doctor_accepts_bare_custom_provider(monkeypatch, tmp_path):try:from hermes_cli import auth as _auth_mod- monkeypatch.setattr(_auth_mod, "get_nous_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_nous_auth_status_local", lambda: {})monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})monkeypatch.setattr(_auth_mod, "get_xai_oauth_auth_status", lambda: {})except Exception:@@ -583,10 +475,10 @@ def test_run_doctor_flags_missing_credentials_for_active_openrouter_provider(montry:from hermes_cli import auth as _auth_mod- monkeypatch.setattr(_auth_mod, "get_nous_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_nous_auth_status_local", lambda: {})monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})- monkeypatch.setattr(_auth_mod, "get_gemini_oauth_auth_status", lambda: {})monkeypatch.setattr(_auth_mod, "get_minimax_oauth_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_gemini_oauth_auth_status", lambda: {})except Exception:pass@@ -606,6 +498,8 @@ def test_run_doctor_flags_missing_credentials_for_active_openrouter_provider(mon("opencode-zen", "anthropic/claude-sonnet-4.6"),("kilocode", "anthropic/claude-sonnet-4.6"),("kimi-coding", "kimi-k2"),+ ("nvidia", "qwen/qwen3.5-122b-a10b"),+ ("moa", "anthropic/claude-sonnet-4.6"),],)def test_run_doctor_accepts_hermes_provider_ids_that_catalog_aliases(@@ -633,7 +527,7 @@ def test_run_doctor_accepts_hermes_provider_ids_that_catalog_aliases(try:from hermes_cli import auth as _auth_mod- monkeypatch.setattr(_auth_mod, "get_nous_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_nous_auth_status_local", lambda: {})monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})monkeypatch.setattr(_auth_mod, "get_xai_oauth_auth_status", lambda: {})except Exception:@@ -646,13 +540,61 @@ def test_run_doctor_accepts_hermes_provider_ids_that_catalog_aliases(out = buf.getvalue()assert f"model.provider '{provider}' is not a recognised provider" not in outassert f"model.provider '{provider}' is unknown" not in out- if provider in {"ai-gateway", "opencode-zen", "kilocode"}:+ if provider in {"ai-gateway", "opencode-zen", "kilocode", "nvidia"}:assert (f"model.default '{default_model}' uses a vendor/model slug but provider is '{provider}'"not in out)+def test_run_doctor_accepts_vendor_slugs_for_named_custom_provider(monkeypatch, tmp_path):+ home = tmp_path / ".hermes"+ home.mkdir(parents=True, exist_ok=True)+ (home / "config.yaml").write_text(+ "model:\n"+ " provider: custom:hpc-ai\n"+ " default: deepseek/deepseek-v4-flash\n"+ "custom_providers:\n"+ " - name: hpc-ai\n"+ " base_url: https://hpc-ai.example/v1\n"+ " api_key: test-key\n",+ encoding="utf-8",+ )++ monkeypatch.setattr(doctor_mod, "HERMES_HOME", home)+ monkeypatch.setattr(doctor_mod, "PROJECT_ROOT", tmp_path / "project")+ monkeypatch.setattr(doctor_mod, "_DHH", str(home))+ (tmp_path / "project").mkdir(exist_ok=True)++ fake_model_tools = types.SimpleNamespace(+ check_tool_availability=lambda *a, **kw: ([], []),+ TOOLSET_REQUIREMENTS={},+ )+ monkeypatch.setitem(sys.modules, "model_tools", fake_model_tools)++ try:+ from hermes_cli import auth as _auth_mod+ monkeypatch.setattr(_auth_mod, "get_nous_auth_status_local", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_xai_oauth_auth_status", lambda: {})+ except Exception:+ pass++ buf = io.StringIO()+ with contextlib.redirect_stdout(buf):+ doctor_mod.run_doctor(Namespace(fix=False))++ out = buf.getvalue()+ assert "model.provider 'custom:hpc-ai' is not a recognised provider" not in out+ assert "model.provider 'custom:hpc-ai' is unknown" not in out+ assert (+ "model.default 'deepseek/deepseek-v4-flash' uses a vendor/model slug but provider is "+ "'custom:hpc-ai'"+ not in out+ )+ assert "Either set model.provider to 'openrouter', or drop the vendor prefix." not in out++def test_run_doctor_accepts_kimi_coding_cn_provider(monkeypatch, tmp_path):@@ -679,7 +621,7 @@ def test_run_doctor_accepts_kimi_coding_cn_provider(monkeypatch, tmp_path):try:from hermes_cli import auth as _auth_mod- monkeypatch.setattr(_auth_mod, "get_nous_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_nous_auth_status_local", lambda: {})monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})monkeypatch.setattr(_auth_mod, "get_auth_status", lambda provider: {"logged_in": True})monkeypatch.setattr(_auth_mod, "get_xai_oauth_auth_status", lambda: {})@@ -719,7 +661,7 @@ def test_run_doctor_termux_does_not_mark_browser_available_without_agent_browsertry:from hermes_cli import auth as _auth_mod- monkeypatch.setattr(_auth_mod, "get_nous_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_nous_auth_status_local", lambda: {})monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})monkeypatch.setattr(_auth_mod, "get_xai_oauth_auth_status", lambda: {})except Exception:@@ -738,6 +680,63 @@ def test_run_doctor_termux_does_not_mark_browser_available_without_agent_browserassert "npm install -g agent-browser && agent-browser install" in out+def _run_doctor_with_managed_agent_browser(monkeypatch, tmp_path, runnable):+ """Set up run_doctor with node present, agent-browser only in the+ Hermes-managed node bin (~/.hermes/node/bin), not on PATH or in+ PROJECT_ROOT/node_modules. Returns the captured stdout."""+ home = tmp_path / ".hermes"+ (home / "node" / "bin").mkdir(parents=True, exist_ok=True)+ (home / "config.yaml").write_text("memory: {}\n", encoding="utf-8")+ managed_ab = home / "node" / "bin" / "agent-browser"+ managed_ab.write_text("#!/bin/sh\n", encoding="utf-8")+ managed_ab.chmod(0o755)+ project = tmp_path / "project"+ project.mkdir(exist_ok=True) # no node_modules/agent-browser here++ monkeypatch.delenv("TERMUX_VERSION", raising=False)+ monkeypatch.delenv("PREFIX", raising=False)+ monkeypatch.setattr(doctor_mod, "HERMES_HOME", home)+ monkeypatch.setattr(doctor_mod, "PROJECT_ROOT", project)+ monkeypatch.setattr(doctor_mod, "_DHH", str(home))++ # node on PATH, agent-browser is NOT on PATH (only in the managed bin).+ # The managed-dir rung resolves via shutil.which(..., path=<dir>) so+ # Windows picks the .cmd shim — mirror that shape here.+ def _fake_which(cmd, path=None):+ if path is not None:+ if cmd == "agent-browser" and str(managed_ab.parent) == str(path):+ return str(managed_ab)+ return None+ return "/usr/bin/node" if cmd in {"node", "npm"} else None++ monkeypatch.setattr(doctor_mod.shutil, "which", _fake_which)+ # agent_browser_runnable is imported into doctor's namespace+ monkeypatch.setattr(+ doctor_mod,+ "agent_browser_runnable",+ lambda path: runnable and str(path) == str(managed_ab),+ )++ fake_model_tools = types.SimpleNamespace(+ check_tool_availability=lambda *a, **kw: ([], []),+ TOOLSET_REQUIREMENTS={},+ )+ monkeypatch.setitem(sys.modules, "model_tools", fake_model_tools)++ try:+ from hermes_cli import auth as _auth_mod+ monkeypatch.setattr(_auth_mod, "get_nous_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_codex_auth_status", lambda: {})+ monkeypatch.setattr(_auth_mod, "get_xai_oauth_auth_status", lambda: {})+ except Exception:+ pass++ buf = io.StringIO()+ with contextlib.redirect_stdout(buf):+ doctor_mod.run_doctor(Namespace(fix=False))+ return buf.getvalue()++def test_run_doctor_kimi_cn_env_is_detected_and_probe_is_null_safe(monkeypatch, tmp_path):home = tmp_path / ".hermes"home.mkdir(parents=True, exist_ok=True)