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
+25
View File
@@ -0,0 +1,25 @@
"""Unit-тесты services/llm.py — call_llm с FakeLLMClient."""
from services.llm import call_llm
from services.llm_client import FakeLLMClient
def _build(cur, txt):
return (f"prompt:{txt}", "pid-1")
class TestCallLLM:
def test_plain_json(self):
llm = FakeLLMClient({"default": '{"mode":"partial","ops":[]}'})
res, pid = call_llm([], "текст", _build, llm_client=llm)
assert pid == "pid-1"
assert res == {"mode": "partial", "ops": []}
def test_markdown_json(self):
llm = FakeLLMClient({"default": '```json\n{"mode":"full_replace","ops":[]}\n```'})
res, _ = call_llm([], "текст", _build, llm_client=llm)
assert res["mode"] == "full_replace"
def test_markdown_generic(self):
llm = FakeLLMClient({"default": '```\n{"a":1}\n```'})
res, _ = call_llm([], "текст", _build, llm_client=llm)
assert res == {"a": 1}