feat: solution for 'Повторный экзамен: FAQ-бот — ChromaDB + один MCP-tool'

This commit is contained in:
2026-07-01 11:01:06 +03:00
parent 2cf8df92ed
commit ddcd1f3423
5 changed files with 202 additions and 126 deletions
+32
View File
@@ -0,0 +1,32 @@
import importlib
import sys
import types
import unittest
import src.main as main
class TestFAQBot(unittest.TestCase):
def test_embeddings_type(self):
self.assertIsInstance(main.embeddings, types.ModuleType.__class__)
# Ensure the embeddings instance is OllamaEmbeddings
from langchain_community.embeddings import OllamaEmbeddings
self.assertIsInstance(main.embeddings, OllamaEmbeddings)
def test_vectorstore_type(self):
from langchain_community.vectorstores.chromadb import Chroma
self.assertIsInstance(main.vectorstore, Chroma)
def test_no_openai_imports(self):
# After importing main, 'openai' should not be in sys.modules
self.assertNotIn("openai", sys.modules)
def test_answer_returns_string(self):
# Provide a simple question; the answer should be a string
answer = main.answer_question("What is the capital of France?")
self.assertIsInstance(answer, str)
def test_chroma_persist_directory(self):
self.assertEqual(main.CHROMA_DIR.name, "chroma_db")
if __name__ == "__main__":
unittest.main()