# VectorStoreIntegrationTests

> **Class** in `langchain_tests`

📖 [View in docs](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests)

Base class for vector store integration tests.

Implementers should subclass this test suite and provide a fixture
that returns an empty vector store for each test.

The fixture should use the `get_embeddings` method to get a pre-defined
embeddings model that should be used for this test suite.

Here is a template:

```python
from typing import Generator

import pytest
from langchain_core.vectorstores import VectorStore
from langchain_parrot_link.vectorstores import ParrotVectorStore
from langchain_tests.integration_tests.vectorstores import VectorStoreIntegrationTests

class TestParrotVectorStore(VectorStoreIntegrationTests):
    @pytest.fixture()
    def vectorstore(self) -> Generator[VectorStore, None, None]:  # type: ignore
        """Get an empty vectorstore."""
        store = ParrotVectorStore(self.get_embeddings())
        # note: store should be EMPTY at this point
        # if you need to delete data, you may do so here
        try:
            yield store
        finally:
            # cleanup operations, or deleting data
            pass
```

In the fixture, before the `yield` we instantiate an empty vector store. In the
`finally` block, we call whatever logic is necessary to bring the vector store
to a clean state.

```python
from typing import Generator

import pytest
from langchain_core.vectorstores import VectorStore
from langchain_tests.integration_tests.vectorstores import VectorStoreIntegrationTests

from langchain_chroma import Chroma

class TestChromaStandard(VectorStoreIntegrationTests):
    @pytest.fixture()
    def vectorstore(self) -> Generator[VectorStore, None, None]:  # type: ignore
        """Get an empty VectorStore for unit tests."""
        store = Chroma(embedding_function=self.get_embeddings())
        try:
            yield store
        finally:
            store.delete_collection()
            pass
```

Note that by default we enable both sync and async tests. To disable either,
override the `has_sync` or `has_async` properties to `False` in the
subclass. For example:

```python
class TestParrotVectorStore(VectorStoreIntegrationTests):
    @pytest.fixture()
    def vectorstore(self) -> Generator[VectorStore, None, None]:  # type: ignore
        ...

    @property
    def has_async(self) -> bool:
        return False
```

!!! note
    API references for individual test methods include troubleshooting tips.

## Signature

```python
VectorStoreIntegrationTests()
```

## Extends

- `BaseStandardTests`

## Properties

- `has_sync`
- `has_async`
- `has_get_by_ids`

## Methods

- [`vectorstore()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/vectorstore)
- [`get_embeddings()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/get_embeddings)
- [`test_vectorstore_is_empty()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_vectorstore_is_empty)
- [`test_add_documents()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents)
- [`test_vectorstore_still_empty()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_vectorstore_still_empty)
- [`test_deleting_documents()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_deleting_documents)
- [`test_deleting_bulk_documents()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_deleting_bulk_documents)
- [`test_delete_missing_content()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_delete_missing_content)
- [`test_add_documents_with_ids_is_idempotent()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_with_ids_is_idempotent)
- [`test_add_documents_by_id_with_mutation()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_by_id_with_mutation)
- [`test_get_by_ids()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_get_by_ids)
- [`test_get_by_ids_missing()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_get_by_ids_missing)
- [`test_add_documents_documents()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_documents)
- [`test_add_documents_with_existing_ids()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_with_existing_ids)
- [`test_vectorstore_is_empty_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_vectorstore_is_empty_async)
- [`test_add_documents_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_async)
- [`test_vectorstore_still_empty_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_vectorstore_still_empty_async)
- [`test_deleting_documents_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_deleting_documents_async)
- [`test_deleting_bulk_documents_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_deleting_bulk_documents_async)
- [`test_delete_missing_content_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_delete_missing_content_async)
- [`test_add_documents_with_ids_is_idempotent_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_with_ids_is_idempotent_async)
- [`test_add_documents_by_id_with_mutation_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_by_id_with_mutation_async)
- [`test_get_by_ids_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_get_by_ids_async)
- [`test_get_by_ids_missing_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_get_by_ids_missing_async)
- [`test_add_documents_documents_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_documents_async)
- [`test_add_documents_with_existing_ids_async()`](https://reference.langchain.com/python/langchain-tests/integration_tests/vectorstores/VectorStoreIntegrationTests/test_add_documents_with_existing_ids_async)

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/f0c5a28fa05adcda89aebcb449d897245ab21fa4/libs/standard-tests/langchain_tests/integration_tests/vectorstores.py#L21)