test_upstash_vector.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. from core.rag.datasource.vdb.upstash.upstash_vector import UpstashVector, UpstashVectorConfig
  2. from core.rag.models.document import Document
  3. from tests.integration_tests.vdb.__mock.upstashvectordb import setup_upstashvector_mock
  4. from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text
  5. class UpstashVectorTest(AbstractVectorTest):
  6. def __init__(self):
  7. super().__init__()
  8. self.vector = UpstashVector(
  9. collection_name="test_collection",
  10. config=UpstashVectorConfig(
  11. url="your-server-url",
  12. token="your-access-token",
  13. ),
  14. )
  15. def get_ids_by_metadata_field(self):
  16. ids = self.vector.get_ids_by_metadata_field(key="document_id", value=self.example_doc_id)
  17. assert len(ids) != 0
  18. def search_by_full_text(self):
  19. hits_by_full_text: list[Document] = self.vector.search_by_full_text(query=get_example_text())
  20. assert len(hits_by_full_text) == 0
  21. def test_upstash_vector(setup_upstashvector_mock):
  22. UpstashVectorTest().run_all_tests()