def test_infer_image_mimetype_from_base64():
    """Test inferring image mimetype from base64-encoded data."""
    # Create a minimal valid PNG in base64
    base64_png = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="

    result = infer_image_mimetype_from_base64(base64_png)
    assert result == "image/png"

    # Valid, meaningless base64
    result = infer_image_mimetype_from_base64(EXP_BASE64)
    assert result is None
Test inferring image mimetype from base64-encoded data.
llama-index-core/tests/multi_modal_llms/test_generic_utils.py