test(vision): adapt salvaged config-priority tests to async _handle_vision_analyze
The salvaged tests from #53754 predate _handle_vision_analyze becoming async and the native fast path; await the handler and force the legacy aux path so the model-resolution assertion is actually exercised.
This commit is contained in:
parent
149641485c
commit
0ad4dd60e9
1 changed files with 14 additions and 6 deletions
|
|
@ -261,12 +261,17 @@ class TestHandleVisionAnalyze:
|
|||
# (the centralized call_llm router picks the default)
|
||||
assert model is None
|
||||
|
||||
def test_config_yaml_model_takes_priority_over_env(self):
|
||||
@pytest.mark.asyncio
|
||||
async def test_config_yaml_model_takes_priority_over_env(self):
|
||||
"""config.yaml auxiliary.vision.model should be preferred over env var."""
|
||||
with (
|
||||
patch(
|
||||
"tools.vision_tools.vision_analyze_tool", new_callable=AsyncMock
|
||||
) as mock_tool,
|
||||
patch(
|
||||
"tools.vision_tools._should_use_native_vision_fast_path",
|
||||
return_value=False,
|
||||
),
|
||||
patch(
|
||||
"hermes_cli.config.load_config",
|
||||
return_value={"auxiliary": {"vision": {"model": "qwen3.7-plus"}}},
|
||||
|
|
@ -274,20 +279,24 @@ class TestHandleVisionAnalyze:
|
|||
patch.dict(os.environ, {"AUXILIARY_VISION_MODEL": "env-model"}),
|
||||
):
|
||||
mock_tool.return_value = json.dumps({"result": "ok"})
|
||||
coro = _handle_vision_analyze(
|
||||
await _handle_vision_analyze(
|
||||
{"image_url": "https://example.com/img.png", "question": "test"}
|
||||
)
|
||||
coro.close()
|
||||
call_args = mock_tool.call_args
|
||||
model = call_args[0][2] # third positional arg
|
||||
assert model == "qwen3.7-plus"
|
||||
|
||||
def test_env_var_used_when_config_missing_model(self):
|
||||
@pytest.mark.asyncio
|
||||
async def test_env_var_used_when_config_missing_model(self):
|
||||
"""Env var should be used when config.yaml has no auxiliary.vision.model."""
|
||||
with (
|
||||
patch(
|
||||
"tools.vision_tools.vision_analyze_tool", new_callable=AsyncMock
|
||||
) as mock_tool,
|
||||
patch(
|
||||
"tools.vision_tools._should_use_native_vision_fast_path",
|
||||
return_value=False,
|
||||
),
|
||||
patch(
|
||||
"hermes_cli.config.load_config",
|
||||
return_value={"auxiliary": {"vision": {}}},
|
||||
|
|
@ -295,10 +304,9 @@ class TestHandleVisionAnalyze:
|
|||
patch.dict(os.environ, {"AUXILIARY_VISION_MODEL": "fallback-model"}),
|
||||
):
|
||||
mock_tool.return_value = json.dumps({"result": "ok"})
|
||||
coro = _handle_vision_analyze(
|
||||
await _handle_vision_analyze(
|
||||
{"image_url": "https://example.com/img.png", "question": "test"}
|
||||
)
|
||||
coro.close()
|
||||
call_args = mock_tool.call_args
|
||||
model = call_args[0][2]
|
||||
assert model == "fallback-model"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue