20 lines
678 B
Python
20 lines
678 B
Python
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from app.embeddings import EmbeddingUnavailable, embed_texts
|
|
|
|
|
|
class EmbeddingTests(unittest.IsolatedAsyncioTestCase):
|
|
async def test_empty_model_setting_reports_disabled_embedding(self) -> None:
|
|
with patch.dict("os.environ", {"KNOWLEDGE_EMBEDDING_MODEL": ""}):
|
|
with self.assertRaises(EmbeddingUnavailable):
|
|
await embed_texts(["sample"])
|
|
|
|
async def test_empty_input_needs_no_embedding_model(self) -> None:
|
|
with patch.dict("os.environ", {"KNOWLEDGE_EMBEDDING_MODEL": ""}):
|
|
self.assertEqual(await embed_texts([]), [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|