test_add_documents() — langchain Function Reference
Architecture documentation for the test_add_documents() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f2ed83af_452c_0c52_d680_e3af9d4884e7["test_add_documents()"] dd52cc1a_cb37_0117_3b1e_0889a7228307["VectorStoreIntegrationTests"] f2ed83af_452c_0c52_d680_e3af9d4884e7 -->|defined in| dd52cc1a_cb37_0117_3b1e_0889a7228307 style f2ed83af_452c_0c52_d680_e3af9d4884e7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/standard-tests/langchain_tests/integration_tests/vectorstores.py lines 152–184
def test_add_documents(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 `similarity_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_sync:
pytest.skip("Sync tests not supported.")
original_documents = [
Document(page_content="foo", metadata={"id": 1}),
Document(page_content="bar", metadata={"id": 2}),
]
ids = vectorstore.add_documents(original_documents)
documents = vectorstore.similarity_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() do?
test_add_documents() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py.
Where is test_add_documents() defined?
test_add_documents() is defined in libs/standard-tests/langchain_tests/integration_tests/vectorstores.py at line 152.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free