def test_get_messages(mongo_chat_store: MongoChatStore):
    """Test retrieving messages from a chat session."""
    # Create a chat with messages
    key = "test_get_messages"
    messages = [
        ChatMessage(role="user", content="Hello, MongoDB!"),
        ChatMessage(role="assistant", content="Hello, user! How can I help you?"),
        ChatMessage(role="user", content="I need information about databases."),
    ]
    mongo_chat_store.set_messages(key=key, messages=messages)

    # Retrieve the messages
    retrieved_messages = mongo_chat_store.get_messages(key=key)

    # Verify the messages were retrieved correctly
    assert len(retrieved_messages) == 3
    assert retrieved_messages[0].role == "user"
    assert retrieved_messages[0].content == "Hello, MongoDB!"
    assert retrieved_messages[1].role == "assistant"
    assert retrieved_messages[1].content == "Hello, user! How can I help you?"
    assert retrieved_messages[2].role == "user"
    assert retrieved_messages[2].content == "I need information about databases."
Test retrieving messages from a chat session.
llama-index-integrations/storage/chat_store/llama-index-storage-chat-store-mongo/tests/test_chat_store_mongo_chat_store.py