chore: clean up test_issue1894_provider_overlap — remove vestigial noqa, add docstrings

This commit is contained in:
Ed
2026-05-26 16:36:53 +02:00
parent e46072c699
commit 38db6199b8
+26 -15
View File
@@ -1,8 +1,6 @@
# Copyright 2025 the Hermes WebUI contributors
# SPDX-License-Identifier: MIT
# noqa: N801
# Regression tests for GitHub issue #1894.
#
# Symptom: when the WebUI's configured provider (e.g. `opencode-go`) and a
@@ -44,15 +42,14 @@ def _restore_config(cfg_module, old_model, old_custom):
cfg_module.cfg['custom_providers'] = old_custom
# ---------------------------------------------------------------------------
# Case 1 — overlap: selected non-custom provider should win
# ---------------------------------------------------------------------------
def test_selected_opencode_go_wins_over_custom_provider_overlap():
# opencode-go and a custom DeepSeek-compatible endpoint both serve
# deepseek-v4-pro. With opencode-go configured as the active provider,
# selection of deepseek-v4-pro must route to opencode-go, not to the
# custom endpoint.
"""Case 1 — overlap: selected non-custom provider should win.
OpenCode Go and a custom DeepSeek-compatible endpoint both serve
deepseek-v4-pro. With opencode-go configured as the active provider,
selection of deepseek-v4-pro must route to opencode-go, not to the
custom endpoint.
"""
import api.config as cfg_mod
old_model, old_custom = _apply_config_overrides(cfg_mod, {
'base_url': 'https://opencode.ai/zen/go/v1',
@@ -80,8 +77,11 @@ def test_selected_opencode_go_wins_over_custom_provider_overlap():
def test_selected_opencode_go_wins_direct_resolve():
# Same scenario but bypassing model_with_provider_context to test the
# resolver path directly with a bare model id.
"""Case 1 variant — same overlap scenario via direct resolve path.
Bypasses model_with_provider_context to test the resolver path directly
with a bare model id.
"""
import api.config as cfg_mod
old_model, old_custom = _apply_config_overrides(cfg_mod, {
'base_url': 'https://opencode.ai/zen/go/v1',
@@ -106,8 +106,11 @@ def test_selected_opencode_go_wins_direct_resolve():
# ---------------------------------------------------------------------------
def test_custom_only_model_still_routes_to_custom_provider():
# A model that exists only in a custom provider must still be routed
# correctly when no explicit provider prefix is given.
"""Case 2 — custom-only model routing must stay intact.
A model that exists only in a custom provider must still be routed
correctly when no explicit provider prefix is given.
"""
import api.config as cfg_mod
old_model, old_custom = _apply_config_overrides(cfg_mod, {
'base_url': 'https://opencode.ai/zen/go/v1',
@@ -132,7 +135,10 @@ def test_custom_only_model_still_routes_to_custom_provider():
# ---------------------------------------------------------------------------
def test_explicit_custom_provider_selection_intact():
# @custom:<name>:<model> syntax must not be swallowed by the new guard.
"""Case 3 — explicit custom provider selection still works.
The @custom:<name>:<model> syntax must not be swallowed by the new guard.
"""
model, provider, base_url = resolve_model_provider('@custom:ds2api:deepseek-v4-pro')
assert provider == 'custom:ds2api', f'Expected provider=custom:ds2api, got {provider!r}'
assert model == 'deepseek-v4-pro'
@@ -143,6 +149,11 @@ def test_explicit_custom_provider_selection_intact():
# ---------------------------------------------------------------------------
def test_openrouter_suffix_still_works():
"""Case 4 — existing suffix syntax is preserved.
Ensures the openrouter suffix syntax (e.g. model_name:free) still routes
correctly through model_with_provider_context.
"""
import api.config as cfg_mod
old_model, old_custom = _apply_config_overrides(cfg_mod, {
'provider': 'anthropic', # non-openrouter so prefix is needed