From 9bb5842530f0844d7b254119e43363bdeccb84a1 Mon Sep 17 00:00:00 2001 From: Ed Date: Tue, 26 May 2026 16:54:34 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20address=20audit=20findings=20=E2=80=94?= =?UTF-8?q?=20module=20docstring=20+=20consistent=20section=20separators?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_issue1894_provider_overlap.py | 45 +++++++++--------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/tests/test_issue1894_provider_overlap.py b/tests/test_issue1894_provider_overlap.py index 7f09e95c..847d2dfe 100644 --- a/tests/test_issue1894_provider_overlap.py +++ b/tests/test_issue1894_provider_overlap.py @@ -1,21 +1,22 @@ # Copyright 2025 the Hermes WebUI contributors # SPDX-License-Identifier: MIT -# Regression tests for GitHub issue #1894. -# -# Symptom: when the WebUI's configured provider (e.g. `opencode-go`) and a -# `custom_providers[]` entry both expose the same bare model id (e.g. -# `deepseek-v4-pro`), the resolver was routing to `custom:` instead of -# the configured `opencode-go` endpoint. -# -# Root cause: `resolve_model_provider()` in `api/config.py` guarded the custom- -# provider skip only when `model_id == model.default`. If `model.default` -# was a different model (e.g. `glm-5.1`), the overlap was not detected and -# `deepseek-v4-pro` was matched against `custom_providers[]` first, routing -# the WebUI to the wrong endpoint. -# -# Fix: widen the guard so an explicit non-custom provider wins for any model -# it owns in `_PROVIDER_MODELS[config_provider]`. +"""Regression tests for GitHub issue #1894. + +Symptom: when the WebUI's configured provider (e.g. ``opencode-go``) and a +``custom_providers[]`` entry both expose the same bare model id (e.g. +``deepseek-v4-pro``), the resolver was routing to ``custom:`` instead of +the configured ``opencode-go`` endpoint. + +Root cause: ``resolve_model_provider()`` in ``api/config.py`` guarded the +custom-provider skip only when ``model_id == model.default``. If +``model.default`` was a different model (e.g. ``glm-5.1``), the overlap was +not detected and ``deepseek-v4-pro`` was matched against +``custom_providers[]`` first, routing the WebUI to the wrong endpoint. + +Fix: widen the guard so an explicit non-custom provider wins for any model +it owns in ``_PROVIDER_MODELS[config_provider]``. +""" from api.config import resolve_model_provider, model_with_provider_context @@ -101,10 +102,6 @@ def test_selected_opencode_go_wins_direct_resolve(): _restore_config(cfg_mod, old_model, old_custom) -# --------------------------------------------------------------------------- -# Case 2 — custom-only model: custom provider routing must stay intact -# --------------------------------------------------------------------------- - def test_custom_only_model_still_routes_to_custom_provider(): """Case 2 — custom-only model routing must stay intact. @@ -130,10 +127,6 @@ def test_custom_only_model_still_routes_to_custom_provider(): _restore_config(cfg_mod, old_model, old_custom) -# --------------------------------------------------------------------------- -# Case 3 — explicit custom provider selection still works -# --------------------------------------------------------------------------- - def test_explicit_custom_provider_selection_intact(): """Case 3 — explicit custom provider selection still works. @@ -144,10 +137,6 @@ def test_explicit_custom_provider_selection_intact(): assert model == 'deepseek-v4-pro' -# --------------------------------------------------------------------------- -# Case 4 — existing suffix syntax is preserved -# --------------------------------------------------------------------------- - def test_openrouter_suffix_still_works(): """Case 4 — existing suffix syntax is preserved. @@ -165,4 +154,4 @@ def test_openrouter_suffix_still_works(): assert provider == 'openrouter' assert model == 'tencent/hy3-preview:free' finally: - _restore_config(cfg_mod, old_model, old_custom) \ No newline at end of file + _restore_config(cfg_mod, old_model, old_custom)