mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-22 11:00:37 +00:00
community[patch]: Test InMemoryVectorStore with RWAPI test suite (#23603)
Add standard test suite to InMemoryVectorStore implementation.
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from langchain_core.documents import Document
|
||||
from langchain_standard_tests.integration_tests.vectorstores import (
|
||||
AsyncReadWriteTestSuite,
|
||||
ReadWriteTestSuite,
|
||||
)
|
||||
|
||||
from langchain_community.vectorstores.inmemory import InMemoryVectorStore
|
||||
from tests.integration_tests.vectorstores.fake_embeddings import (
|
||||
@@ -8,6 +13,18 @@ from tests.integration_tests.vectorstores.fake_embeddings import (
|
||||
)
|
||||
|
||||
|
||||
class TestInMemoryReadWriteTestSuite(ReadWriteTestSuite):
|
||||
@pytest.fixture
|
||||
def vectorstore(self) -> InMemoryVectorStore:
|
||||
return InMemoryVectorStore(embedding=self.get_embeddings())
|
||||
|
||||
|
||||
class TestAsyncInMemoryReadWriteTestSuite(AsyncReadWriteTestSuite):
|
||||
@pytest.fixture
|
||||
async def vectorstore(self) -> InMemoryVectorStore:
|
||||
return InMemoryVectorStore(embedding=self.get_embeddings())
|
||||
|
||||
|
||||
async def test_inmemory() -> None:
|
||||
"""Test end to end construction and search."""
|
||||
store = await InMemoryVectorStore.afrom_texts(
|
||||
|
Reference in New Issue
Block a user