From 77eef27cad9b0e5b0551d5a8ea9485779ee7dc18 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Thu, 9 Jul 2026 19:52:03 +0900 Subject: 停止ボタンの不具合修正(停止ボタンを押すと送信できなくなるバグを修正) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LLMがメッセージ生成途上で画面スクロールしにくい問題を修正 チャットメッセージバルーンをコピペ対応 トークン消費量をリングゲージで可視化(表示タイミングに不具合あり) --- tests/test_models.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'tests/test_models.py') diff --git a/tests/test_models.py b/tests/test_models.py index 8cc2738..177b86b 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -2,6 +2,8 @@ from __future__ import annotations +from unittest.mock import patch + from starlette.testclient import TestClient from ollama_web.app import create_app @@ -14,6 +16,17 @@ def _login_client(client: TestClient) -> str: return str(login.headers["x-csrf-token"]) +class _FakeClient: + def __init__(self, capabilities: list[str] | None = None) -> None: + self._capabilities = capabilities or [] + + def show(self, _model: str) -> dict[str, list[str]]: + return {"capabilities": self._capabilities} + + def list(self) -> dict[str, list[dict[str, str]]]: + return {"models": []} + + def test_model_capabilities_route_supports_slash_in_model_name() -> None: """HuggingFace-style model names contain slashes and must reach the API. @@ -21,11 +34,12 @@ def test_model_capabilities_route_supports_slash_in_model_name() -> None: so the route uses the ``path`` converter. Encoding ``%2F`` must decode to the full model name, not split the URL into multiple segments. """ - with TestClient(create_app()) as client: - csrf = _login_client(client) + slash_model = "hf.co/hotdogs/gemma-4-E4B-it-ultra-uncensored-heretic-GGUF:Q5_K_M" + encoded = slash_model.replace("/", "%2F").replace(":", "%3A") + fake = _FakeClient(["completion", "vision", "tools", "thinking"]) - slash_model = "hf.co/hotdogs/gemma-4-E4B-it-ultra-uncensored-heretic-GGUF:Q5_K_M" - encoded = slash_model.replace("/", "%2F").replace(":", "%3A") + with patch("ollama_web.llm.get_client", return_value=fake), TestClient(create_app()) as client: + csrf = _login_client(client) response = client.get( f"/api/models/{encoded}/capabilities", headers={"X-CSRF-Token": csrf}, @@ -41,9 +55,10 @@ def test_model_capabilities_route_supports_slash_in_model_name() -> None: def test_model_capabilities_route_still_works_without_slashes() -> None: """Model names without slashes (e.g. cloud aliases) must keep working.""" - with TestClient(create_app()) as client: - csrf = _login_client(client) + fake = _FakeClient(["completion"]) + with patch("ollama_web.llm.get_client", return_value=fake), TestClient(create_app()) as client: + csrf = _login_client(client) response = client.get( "/api/models/glm-5.2%3Acloud/capabilities", headers={"X-CSRF-Token": csrf}, @@ -51,4 +66,4 @@ def test_model_capabilities_route_still_works_without_slashes() -> None: assert response.status_code == 200 payload = response.json() assert "capabilities" in payload - assert "completion" in [c.lower() for c in payload["capabilities"]] + assert "completion" in [c.lower() for c in payload["capabilities"]] \ No newline at end of file -- cgit v1.2.3