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