test_incremental_delete_with_same_source() — langchain Function Reference
Architecture documentation for the test_incremental_delete_with_same_source() function in test_indexing.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD cf9ce9fe_a6b1_d258_77ea_aa5e58783454["test_incremental_delete_with_same_source()"] a9fb4c74_0865_0941_ade3_563a79762cee["test_indexing.py"] cf9ce9fe_a6b1_d258_77ea_aa5e58783454 -->|defined in| a9fb4c74_0865_0941_ade3_563a79762cee style cf9ce9fe_a6b1_d258_77ea_aa5e58783454 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/indexing/test_indexing.py lines 1485–1564
def test_incremental_delete_with_same_source(
record_manager: InMemoryRecordManager, vector_store: InMemoryVectorStore
) -> None:
"""Test indexing with incremental deletion strategy."""
loader = ToyLoader(
documents=[
Document(
page_content="This is a test document.",
metadata={"source": "1"},
),
Document(
page_content="This is another document.",
metadata={"source": "1"},
),
]
)
with patch.object(
record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
):
assert index(
loader,
record_manager,
vector_store,
cleanup="incremental",
source_id_key="source",
key_encoder="sha256",
) == {
"num_added": 2,
"num_deleted": 0,
"num_skipped": 0,
"num_updated": 0,
}
doc_texts = {
# Ignoring type since doc should be in the store and not a None
vector_store.get_by_ids([uid])[0].page_content
for uid in vector_store.store
}
assert doc_texts == {"This is another document.", "This is a test document."}
# Delete 1 document and unchange 1 document
loader = ToyLoader(
documents=[
Document(
page_content="This is another document.", # <-- Same as original
metadata={"source": "1"},
),
]
)
with patch.object(
record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
):
assert index(
loader,
record_manager,
vector_store,
cleanup="incremental",
source_id_key="source",
key_encoder="sha256",
) == {
"num_added": 0,
"num_deleted": 1,
"num_skipped": 1,
"num_updated": 0,
}
doc_texts = {
# Ignoring type since doc should be in the store and not a None
vector_store.get_by_ids([uid])[0].page_content
for uid in vector_store.store
}
assert doc_texts == {
"This is another document.",
}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_incremental_delete_with_same_source() do?
test_incremental_delete_with_same_source() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/indexing/test_indexing.py.
Where is test_incremental_delete_with_same_source() defined?
test_incremental_delete_with_same_source() is defined in libs/core/tests/unit_tests/indexing/test_indexing.py at line 1485.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free