From 38db6199b8d6697f39503cb44ddcd4bf5fd36c20 Mon Sep 17 00:00:00 2001 From: Ed Date: Tue, 26 May 2026 16:36:53 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20clean=20up=20test=5Fissue1894=5Fprovid?= =?UTF-8?q?er=5Foverlap=20=E2=80=94=20remove=20vestigial=20noqa,=20add=20d?= =?UTF-8?q?ocstrings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_issue1894_provider_overlap.py | 41 +++++++++++++++--------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/test_issue1894_provider_overlap.py b/tests/test_issue1894_provider_overlap.py index 7dcc225b..7f09e95c 100644 --- a/tests/test_issue1894_provider_overlap.py +++ b/tests/test_issue1894_provider_overlap.py @@ -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:: syntax must not be swallowed by the new guard. + """Case 3 — explicit custom provider selection still works. + + The @custom:: 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