test: набор pytest-тестов под site/ (unit + интеграционные + безопасность)

This commit is contained in:
“Naeel”
2026-08-26 16:47:30 +03:00
parent 9a8ae0a5a3
commit 8f8fabf959
13 changed files with 796 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
"""Unit-тесты services/llm_client.py."""
from services.llm_client import FakeLLMClient, HttpxLLMClient
class TestFakeLLMClient:
def test_exact_match(self):
c = FakeLLMClient({"hello": "world"})
assert c.complete("hello") == "world"
def test_partial_match(self):
c = FakeLLMClient({"needle": "found"})
assert c.complete("a needle in haystack") == "found"
def test_default_fallback(self):
c = FakeLLMClient({"default": "fallback"})
assert c.complete("whatever") == "fallback"
def test_calls_recorded(self):
c = FakeLLMClient()
c.complete("x")
c.complete("y")
assert c.calls == ["x", "y"]
def test_add(self):
c = FakeLLMClient()
c.add("k", "v")
assert c.complete("k") == "v"
class TestHttpxLLMClient:
def test_init_defaults(self):
c = HttpxLLMClient(url="http://x", key="k")
assert c.model == "gpt-oss-120b"
assert c.timeout == 120
assert c.max_tokens == 8000
def test_init_custom(self):
c = HttpxLLMClient(url="http://x", key="k", model="m", timeout=10)
assert c.model == "m"
assert c.timeout == 10