From 1662b7f82a2a810c536445968aa8811fd3cb6458 Mon Sep 17 00:00:00 2001 From: r266-tech Date: Fri, 10 Apr 2026 09:16:16 +0800 Subject: [PATCH] fix(test): correct mock target for fetch_api_models in custom provider tests fetch_api_models is imported locally inside _model_flow_named_custom from hermes_cli.models, not defined as a module-level attribute of hermes_cli.main. Patch the source module so the local import picks up the mock. Also force simple_term_menu ImportError so tests reliably use the input() fallback path regardless of environment. Co-Authored-By: Claude --- tests/hermes_cli/test_custom_provider_model_switch.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/hermes_cli/test_custom_provider_model_switch.py b/tests/hermes_cli/test_custom_provider_model_switch.py index 9c273f84f..d48610a63 100644 --- a/tests/hermes_cli/test_custom_provider_model_switch.py +++ b/tests/hermes_cli/test_custom_provider_model_switch.py @@ -45,7 +45,8 @@ class TestCustomProviderModelSwitch: "model": "model-A", # already saved } - with patch("hermes_cli.main.fetch_api_models", return_value=["model-A", "model-B"]) as mock_fetch, \ + with patch("hermes_cli.models.fetch_api_models", return_value=["model-A", "model-B"]) as mock_fetch, \ + patch.dict("sys.modules", {"simple_term_menu": None}), \ patch("builtins.input", return_value="2"), \ patch("builtins.print"): _model_flow_named_custom({}, provider_info) @@ -65,7 +66,8 @@ class TestCustomProviderModelSwitch: "model": "model-A", } - with patch("hermes_cli.main.fetch_api_models", return_value=["model-A", "model-B"]), \ + with patch("hermes_cli.models.fetch_api_models", return_value=["model-A", "model-B"]), \ + patch.dict("sys.modules", {"simple_term_menu": None}), \ patch("builtins.input", return_value="2"), \ patch("builtins.print"): _model_flow_named_custom({}, provider_info) @@ -88,7 +90,7 @@ class TestCustomProviderModelSwitch: } # fetch returns empty list (probe failed), user presses Enter (empty input) - with patch("hermes_cli.main.fetch_api_models", return_value=[]), \ + with patch("hermes_cli.models.fetch_api_models", return_value=[]), \ patch("builtins.input", return_value=""), \ patch("builtins.print"): _model_flow_named_custom({}, provider_info) @@ -110,7 +112,8 @@ class TestCustomProviderModelSwitch: # no "model" key } - with patch("hermes_cli.main.fetch_api_models", return_value=["model-X"]), \ + with patch("hermes_cli.models.fetch_api_models", return_value=["model-X"]), \ + patch.dict("sys.modules", {"simple_term_menu": None}), \ patch("builtins.input", return_value="1"), \ patch("builtins.print"): _model_flow_named_custom({}, provider_info)