"""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}