async def test_chat_messages_memory_block(memory_with_blocks):
    """Test chat messages memory block integration."""
    # Get the memory block content
    content = await memory_with_blocks._get_memory_blocks_content([])

    # Verify chat messages block content
    assert "chat_messages" in content
    assert len(content["chat_messages"]) == 2
    assert content["chat_messages"][0].role == "user"
    assert content["chat_messages"][0].content == "Historical user message"
    assert content["chat_messages"][1].role == "assistant"
    assert content["chat_messages"][1].content == "Historical assistant response"

    # Format content for insertion
    formatted_blocks, chat_messages = await memory_with_blocks._format_memory_blocks(
        {"chat_messages": content["chat_messages"]}
    )

    # Chat messages should be returned directly
    assert len(chat_messages) == 2
    assert chat_messages[0].role == "user"
    assert chat_messages[0].content == "Historical user message"
    assert chat_messages[1].role == "assistant"
    assert chat_messages[1].content == "Historical assistant response"
Test chat messages memory block integration.
llama-index-core/tests/memory/test_memory_blocks_base.py