tests: added tests (#250)

This commit is contained in:
cachho
2023-07-16 02:28:51 +02:00
committed by GitHub
parent d12aeec1ff
commit 3f71050c47
9 changed files with 388 additions and 29 deletions

View File

@@ -0,0 +1,39 @@
import os
import unittest
from unittest.mock import patch
from embedchain import App
from embedchain.config import InitConfig
class TestChromaDbHostsLoglevel(unittest.TestCase):
os.environ["OPENAI_API_KEY"] = "test_key"
@patch("chromadb.api.models.Collection.Collection.add")
@patch("chromadb.api.models.Collection.Collection.get")
@patch("embedchain.embedchain.EmbedChain.retrieve_from_database")
@patch("embedchain.embedchain.EmbedChain.get_answer_from_llm")
@patch("embedchain.embedchain.EmbedChain.get_llm_model_answer")
def test_whole_app(
self,
_mock_get,
_mock_add,
_mock_ec_retrieve_from_database,
_mock_get_answer_from_llm,
mock_ec_get_llm_model_answer,
):
"""
Test if the `App` instance is initialized without a config that does not contain default hosts and ports.
"""
config = InitConfig(log_level="DEBUG")
app = App(config)
knowledge = "lorem ipsum dolor sit amet, consectetur adipiscing"
app.add_local("text", knowledge)
app.query("What text did I give you?")
app.chat("What text did I give you?")
self.assertEqual(mock_ec_get_llm_model_answer.call_args[1]["documents"], [knowledge])