Home / Function/ test_aindex_with_upsert_kwargs() — langchain Function Reference

test_aindex_with_upsert_kwargs() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  3f7f1e1a_c111_7c68_75c4_e27f0e51b425["test_aindex_with_upsert_kwargs()"]
  a9fb4c74_0865_0941_ade3_563a79762cee["test_indexing.py"]
  3f7f1e1a_c111_7c68_75c4_e27f0e51b425 -->|defined in| a9fb4c74_0865_0941_ade3_563a79762cee
  style 3f7f1e1a_c111_7c68_75c4_e27f0e51b425 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/indexing/test_indexing.py lines 2892–2942

async def test_aindex_with_upsert_kwargs(
    arecord_manager: InMemoryRecordManager, upserting_vector_store: InMemoryVectorStore
) -> None:
    """Test async indexing with upsert_kwargs parameter."""
    mock_aadd_documents = AsyncMock()

    with patch.object(upserting_vector_store, "aadd_documents", mock_aadd_documents):
        docs = [
            Document(
                page_content="Async test document 1",
                metadata={"source": "1"},
            ),
            Document(
                page_content="Async test document 2",
                metadata={"source": "2"},
            ),
        ]

        upsert_kwargs = {"vector_field": "embedding"}

        await aindex(
            docs,
            arecord_manager,
            upserting_vector_store,
            upsert_kwargs=upsert_kwargs,
            key_encoder="sha256",
        )

        # Assert that aadd_documents was called with the correct arguments
        mock_aadd_documents.assert_called_once()
        call_args = mock_aadd_documents.call_args
        assert call_args is not None
        args, kwargs = call_args

        # Check that the documents are correct (ignoring ids)
        assert len(args[0]) == 2
        assert all(isinstance(doc, Document) for doc in args[0])
        assert [doc.page_content for doc in args[0]] == [
            "Async test document 1",
            "Async test document 2",
        ]
        assert [doc.metadata for doc in args[0]] == [{"source": "1"}, {"source": "2"}]

        # Check that IDs are present
        assert "ids" in kwargs
        assert isinstance(kwargs["ids"], list)
        assert len(kwargs["ids"]) == 2

        # Check other arguments
        assert kwargs["batch_size"] == 100
        assert kwargs["vector_field"] == "embedding"

Domain

Subdomains

Frequently Asked Questions

What does test_aindex_with_upsert_kwargs() do?
test_aindex_with_upsert_kwargs() 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() defined?
test_aindex_with_upsert_kwargs() is defined in libs/core/tests/unit_tests/indexing/test_indexing.py at line 2892.

Analyze Your Own Codebase

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

Try Supermodel Free