Files
Chromy/tests/test_embed.py
T

31 lines
801 B
Python
Raw Normal View History

2026-04-23 22:00:45 +02:00
from __future__ import annotations
import unittest
2026-04-29 12:44:28 +02:00
from unittest.mock import patch
from chromy.embedding import embed
2026-04-23 22:00:45 +02:00
class EmbedTest(unittest.TestCase):
2026-04-29 12:44:28 +02:00
def test_embed_returns_empty_list_for_empty_chunks(self) -> None:
self.assertEqual(embed([]), [])
def test_embed_pairs_text_with_list_embeddings(self) -> None:
with patch(
"chromy.embedding.service.DefaultEmbeddingFunction",
2026-04-29 12:44:28 +02:00
return_value=lambda chunks: ((1.0, 2.0), (3.0, 4.0)),
):
result = embed(["first", "second"])
self.assertEqual(
result,
[
{"text": "first", "embedding": [1.0, 2.0]},
{"text": "second", "embedding": [3.0, 4.0]},
],
)
2026-04-23 22:00:45 +02:00
if __name__ == "__main__":
unittest.main()