test_is_data_content_block() — langchain Function Reference
Architecture documentation for the test_is_data_content_block() function in test_messages.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD e9265e3e_c403_e3d0_a196_dac482662d9a["test_is_data_content_block()"] 3f9e7dd9_29c9_13fc_d3d8_a14d452f0d26["test_messages.py"] e9265e3e_c403_e3d0_a196_dac482662d9a -->|defined in| 3f9e7dd9_29c9_13fc_d3d8_a14d452f0d26 style e9265e3e_c403_e3d0_a196_dac482662d9a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/test_messages.py lines 1110–1209
def test_is_data_content_block() -> None:
# Test all DataContentBlock types with various data fields
# Image blocks
assert is_data_content_block({"type": "image", "url": "https://..."})
assert is_data_content_block(
{
"type": "image",
"base64": "<base64 data>",
"mime_type": "image/jpeg",
}
)
# Video blocks
assert is_data_content_block({"type": "video", "url": "https://video.mp4"})
assert is_data_content_block(
{
"type": "video",
"base64": "<base64 video>",
"mime_type": "video/mp4",
}
)
assert is_data_content_block({"type": "video", "file_id": "vid_123"})
# Audio blocks
assert is_data_content_block({"type": "audio", "url": "https://audio.mp3"})
assert is_data_content_block(
{
"type": "audio",
"base64": "<base64 audio>",
"mime_type": "audio/mp3",
}
)
assert is_data_content_block({"type": "audio", "file_id": "aud_123"})
# Plain text blocks
assert is_data_content_block({"type": "text-plain", "text": "document content"})
assert is_data_content_block({"type": "text-plain", "url": "https://doc.txt"})
assert is_data_content_block({"type": "text-plain", "file_id": "txt_123"})
# File blocks
assert is_data_content_block({"type": "file", "url": "https://file.pdf"})
assert is_data_content_block(
{
"type": "file",
"base64": "<base64 file>",
"mime_type": "application/pdf",
}
)
assert is_data_content_block({"type": "file", "file_id": "file_123"})
# Blocks with additional metadata (should still be valid)
assert is_data_content_block(
{
"type": "image",
"base64": "<base64 data>",
"mime_type": "image/jpeg",
"cache_control": {"type": "ephemeral"},
}
)
assert is_data_content_block(
{
"type": "image",
"base64": "<base64 data>",
"mime_type": "image/jpeg",
"metadata": {"cache_control": {"type": "ephemeral"}},
}
)
assert is_data_content_block(
{
"type": "image",
"base64": "<base64 data>",
"mime_type": "image/jpeg",
"extras": "hi",
}
)
# Invalid cases - wrong type
assert not is_data_content_block({"type": "text", "text": "foo"})
assert not is_data_content_block(
{
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_is_data_content_block() do?
test_is_data_content_block() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_messages.py.
Where is test_is_data_content_block() defined?
test_is_data_content_block() is defined in libs/core/tests/unit_tests/test_messages.py at line 1110.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free