Home / Function/ test_default_add_documents() — langchain Function Reference

test_default_add_documents() — langchain Function Reference

Architecture documentation for the test_default_add_documents() function in test_vectorstore.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  20274bd5_8a61_81d4_f167_31256add9630["test_default_add_documents()"]
  547b9326_0fd1_ea2c_f15c_82026f35f74c["test_vectorstore.py"]
  20274bd5_8a61_81d4_f167_31256add9630 -->|defined in| 547b9326_0fd1_ea2c_f15c_82026f35f74c
  2f8ff0fc_e8aa_b0a3_2e0d_89782118c0c7["add_documents()"]
  20274bd5_8a61_81d4_f167_31256add9630 -->|calls| 2f8ff0fc_e8aa_b0a3_2e0d_89782118c0c7
  cb881d61_c433_1fa7_9b56_681f781555e5["get_by_ids()"]
  20274bd5_8a61_81d4_f167_31256add9630 -->|calls| cb881d61_c433_1fa7_9b56_681f781555e5
  style 20274bd5_8a61_81d4_f167_31256add9630 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/vectorstores/test_vectorstore.py lines 123–148

def test_default_add_documents(vs_class: type[VectorStore]) -> None:
    """Test default implementation of add_documents.

    Test that we can implement the upsert method of the CustomVectorStore
    class without violating the Liskov Substitution Principle.
    """
    store = vs_class()

    # Check upsert with id
    assert store.add_documents([Document(id="1", page_content="hello")]) == ["1"]

    assert store.get_by_ids(["1"]) == [Document(id="1", page_content="hello")]

    # Check upsert without id
    ids = store.add_documents([Document(page_content="world")])
    assert len(ids) == 1
    assert store.get_by_ids(ids) == [Document(id=ids[0], page_content="world")]

    # Check that add_documents works
    assert store.add_documents([Document(id="5", page_content="baz")]) == ["5"]

    # Test add documents with id specified in both document and ids
    original_document = Document(id="7", page_content="baz")
    assert store.add_documents([original_document], ids=["6"]) == ["6"]
    assert original_document.id == "7"  # original document should not be modified
    assert store.get_by_ids(["6"]) == [Document(id="6", page_content="baz")]

Domain

Subdomains

Frequently Asked Questions

What does test_default_add_documents() do?
test_default_add_documents() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/vectorstores/test_vectorstore.py.
Where is test_default_add_documents() defined?
test_default_add_documents() is defined in libs/core/tests/unit_tests/vectorstores/test_vectorstore.py at line 123.
What does test_default_add_documents() call?
test_default_add_documents() calls 2 function(s): add_documents, get_by_ids.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free