test_add_documents_async() — langchain Function Reference
Architecture documentation for the test_add_documents_async() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 055fc33a_e6e2_1229_5505_42c0bb2fa618["test_add_documents_async()"] 6b7f515d_5b14_acff_3191_2493436e519d["VectorStoreIntegrationTests"] 055fc33a_e6e2_1229_5505_42c0bb2fa618 -->|defined in| 6b7f515d_5b14_acff_3191_2493436e519d style 055fc33a_e6e2_1229_5505_42c0bb2fa618 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/standard-tests/langchain_tests/integration_tests/vectorstores.py lines 500–533
async def test_add_documents_async(self, vectorstore: VectorStore) -> None:
"""Test adding documents into the `VectorStore`.
??? note "Troubleshooting"
If this test fails, check that:
1. We correctly initialize an empty vector store in the `vectorestore`
fixture.
2. Calling `.asimilarity_search` for the top `k` similar documents does
not threshold by score.
3. We do not mutate the original document object when adding it to the
vector store (e.g., by adding an ID).
"""
if not self.has_async:
pytest.skip("Async tests not supported.")
original_documents = [
Document(page_content="foo", metadata={"id": 1}),
Document(page_content="bar", metadata={"id": 2}),
]
ids = await vectorstore.aadd_documents(original_documents)
documents = await vectorstore.asimilarity_search("bar", k=2)
assert documents == [
Document(page_content="bar", metadata={"id": 2}, id=ids[1]),
Document(page_content="foo", metadata={"id": 1}, id=ids[0]),
]
# Verify that the original document object does not get mutated!
# (e.g., an ID is added to the original document object)
assert original_documents == [
Document(page_content="foo", metadata={"id": 1}),
Document(page_content="bar", metadata={"id": 2}),
]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_add_documents_async() do?
test_add_documents_async() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py.
Where is test_add_documents_async() defined?
test_add_documents_async() is defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py at line 500.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free