summaryrefslogtreecommitdiff
path: root/tests/test_models.py
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-07-09 19:52:03 +0900
committertanaka takashi <isazaka@gmail.com>2026-07-09 19:52:03 +0900
commit77eef27cad9b0e5b0551d5a8ea9485779ee7dc18 (patch)
tree31adca93be2c5bb7f8b43613df2fd438a897de25 /tests/test_models.py
parentb4f3c99a7d458d32517077ef77b0e5676020b9a2 (diff)
停止ボタンの不具合修正(停止ボタンを押すと送信できなくなるバグを修正)
LLMがメッセージ生成途上で画面スクロールしにくい問題を修正 チャットメッセージバルーンをコピペ対応 トークン消費量をリングゲージで可視化(表示タイミングに不具合あり)
Diffstat (limited to 'tests/test_models.py')
-rw-r--r--tests/test_models.py29
1 files changed, 22 insertions, 7 deletions
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