Home / Function/ test_upsert_no_ids() — langchain Function Reference

test_upsert_no_ids() — langchain Function Reference

Architecture documentation for the test_upsert_no_ids() function in indexer.py from the langchain codebase.

Function python LangChainCore Runnables calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  bcc0bfb4_2e20_58e4_72b0_77bd6a490074["test_upsert_no_ids()"]
  67ebaa9c_263d_69d9_3a75_de0b0ac61588["DocumentIndexerTestSuite"]
  bcc0bfb4_2e20_58e4_72b0_77bd6a490074 -->|defined in| 67ebaa9c_263d_69d9_3a75_de0b0ac61588
  1c682b8d_f3ba_c714_2da6_bae1c8f5ec48["test_upsert_no_ids()"]
  1c682b8d_f3ba_c714_2da6_bae1c8f5ec48 -->|calls| bcc0bfb4_2e20_58e4_72b0_77bd6a490074
  1c682b8d_f3ba_c714_2da6_bae1c8f5ec48["test_upsert_no_ids()"]
  bcc0bfb4_2e20_58e4_72b0_77bd6a490074 -->|calls| 1c682b8d_f3ba_c714_2da6_bae1c8f5ec48
  style bcc0bfb4_2e20_58e4_72b0_77bd6a490074 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/integration_tests/indexer.py lines 36–65

    def test_upsert_no_ids(self, index: DocumentIndex) -> None:
        """Upsert works with documents that do not have IDs.

        At the moment, the ID field in documents is optional.
        """
        documents = [
            Document(page_content="foo", metadata={"id": 1}),
            Document(page_content="bar", metadata={"id": 2}),
        ]
        response = index.upsert(documents)
        ids = sorted(response["succeeded"])

        # Ordering is not guaranteed, need to test carefully
        documents = index.get(ids)
        sorted_documents = sorted(documents, key=lambda x: x.id or "")

        if sorted_documents[0].page_content == "bar":
            assert sorted_documents[0] == Document(
                page_content="bar", metadata={"id": 2}, id=ids[0]
            )
            assert sorted_documents[1] == Document(
                page_content="foo", metadata={"id": 1}, id=ids[1]
            )
        else:
            assert sorted_documents[0] == Document(
                page_content="foo", metadata={"id": 1}, id=ids[0]
            )
            assert sorted_documents[1] == Document(
                page_content="bar", metadata={"id": 2}, id=ids[1]
            )

Domain

Subdomains

Frequently Asked Questions

What does test_upsert_no_ids() do?
test_upsert_no_ids() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/indexer.py.
Where is test_upsert_no_ids() defined?
test_upsert_no_ids() is defined in libs/standard-tests/langchain_tests/integration_tests/indexer.py at line 36.
What does test_upsert_no_ids() call?
test_upsert_no_ids() calls 1 function(s): test_upsert_no_ids.
What calls test_upsert_no_ids()?
test_upsert_no_ids() is called by 1 function(s): test_upsert_no_ids.

Analyze Your Own Codebase

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

Try Supermodel Free