def test_invalid_message_index(mongo_chat_store: MongoChatStore):
    """Test behavior when trying to delete a message with invalid index."""
    key = "test_invalid_index"
    messages = [ChatMessage(role="user", content="Only message")]
    mongo_chat_store.set_messages(key=key, messages=messages)

    # Try to delete message with out-of-range index
    deleted = mongo_chat_store.delete_message(key=key, idx=5)

    # Verify None is returned
    assert deleted is None

    # Verify original message still exists
    remaining = mongo_chat_store.get_messages(key=key)
    assert len(remaining) == 1
    assert remaining[0].content == "Only message"
Test behavior when trying to delete a message with invalid index.
llama-index-integrations/storage/chat_store/llama-index-storage-chat-store-mongo/tests/test_chat_store_mongo_chat_store.py