From a74276749160b137872fbe4ad8c49679494e7a05 Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Fri, 20 Dec 2024 16:55:55 -0500 Subject: [PATCH] Fix test --- llama-index-core/tests/schema/test_schema.py | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/llama-index-core/tests/schema/test_schema.py b/llama-index-core/tests/schema/test_schema.py index 1c8792ad495dc..c7e1f8af37f55 100644 --- a/llama-index-core/tests/schema/test_schema.py +++ b/llama-index-core/tests/schema/test_schema.py @@ -188,6 +188,34 @@ def test_document_legacy_roundtrip(): assert dest.text == "this is a test" +def test_document_exclude_text(): + doc = Document(id_="test_id", text="this is a test") + model_dump = doc.model_dump(exclude={"text"}) + assert "text" not in model_dump + assert doc.model_dump(exclude={"text"}) == { + "id_": "test_id", + "embedding": None, + "metadata": {}, + "excluded_embed_metadata_keys": [], + "excluded_llm_metadata_keys": [], + "relationships": {}, + "metadata_template": "{key}: {value}", + "metadata_separator": "\n", + "text_resource": { + "embeddings": None, + "text": "this is a test", + "mimetype": None, + "path": None, + "url": None, + }, + "image_resource": None, + "audio_resource": None, + "video_resource": None, + "text_template": "{metadata_str}\n\n{content}", + "class_name": "Document", + } + + def test_image_document_empty(): doc = ImageDocument(id_="test") assert doc.id_ == "test"