Spaces:
Sleeping

File size: 474 Bytes
474d164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""Unit tests for OCR payload data URI formatting."""

import base64
import pytest


def test_base64_data_uri_formatting():
    """Ensure raw image bytes format into proper RFC 2397 data URIs."""
    dummy_bytes = b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR"
    mime_type = "image/png"
    b64 = base64.b64encode(dummy_bytes).decode("utf-8")
    data_uri = f"data:{mime_type};base64,{b64}"
    
    assert data_uri.startswith("data:image/png;base64,")
    assert b64 in data_uri