Files
povtornyy-ekzamen-faq-bot-c…/tests/test_main.py
T

32 lines
1.1 KiB
Python

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()