Home / Function/ test_aindex_with_upsert_kwargs_for_document_indexer() — langchain Function Reference

test_aindex_with_upsert_kwargs_for_document_indexer() — langchain Function Reference

Architecture documentation for the test_aindex_with_upsert_kwargs_for_document_indexer() function in test_indexing.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  4f77554f_c8d0_c5d5_809d_69f617eb074c["test_aindex_with_upsert_kwargs_for_document_indexer()"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978["test_indexing.py"]
  4f77554f_c8d0_c5d5_809d_69f617eb074c -->|defined in| 576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978
  style 4f77554f_c8d0_c5d5_809d_69f617eb074c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/indexing/test_indexing.py lines 2853–2889

async def test_aindex_with_upsert_kwargs_for_document_indexer(
    arecord_manager: InMemoryRecordManager,
    mocker: MockerFixture,
) -> None:
    """Test that kwargs are passed to the upsert method of the document indexer."""
    document_index = InMemoryDocumentIndex()
    upsert_spy = mocker.spy(document_index.__class__, "aupsert")
    docs = [
        Document(
            page_content="This is a test document.",
            metadata={"source": "1"},
        ),
        Document(
            page_content="This is another document.",
            metadata={"source": "2"},
        ),
    ]

    upsert_kwargs = {"vector_field": "embedding"}

    assert await aindex(
        docs,
        arecord_manager,
        document_index,
        cleanup="full",
        upsert_kwargs=upsert_kwargs,
        key_encoder="sha256",
    ) == {
        "num_added": 2,
        "num_deleted": 0,
        "num_skipped": 0,
        "num_updated": 0,
    }

    assert upsert_spy.call_count == 1
    # assert call kwargs were passed as kwargs
    assert upsert_spy.call_args.kwargs == upsert_kwargs

Subdomains

Frequently Asked Questions

What does test_aindex_with_upsert_kwargs_for_document_indexer() do?
test_aindex_with_upsert_kwargs_for_document_indexer() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/indexing/test_indexing.py.
Where is test_aindex_with_upsert_kwargs_for_document_indexer() defined?
test_aindex_with_upsert_kwargs_for_document_indexer() is defined in libs/core/tests/unit_tests/indexing/test_indexing.py at line 2853.

Analyze Your Own Codebase

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

Try Supermodel Free