Ejemplo n.º 1
0
def test_base64uri_text():
    b64txt = h.base64uri('blah blah blah\n123 456\nfoo bar baz',
                         mimetype='text/plain')
    assert_equals(
        b64txt,
        'data:text/plain;base64,YmxhaCBibGFoIGJsYWgKMTIzIDQ1Ngpmb28gYmFyIGJheg=='
    )

    b64txt = h.base64uri('blah blah blah\n123 456\nfoo bar baz',
                         mimetype='text/plain',
                         windows_line_endings=True)
    assert_equals(
        b64txt,
        'data:text/plain;base64,YmxhaCBibGFoIGJsYWgNCjEyMyA0NTYNCmZvbyBiYXIgYmF6'
    )
Ejemplo n.º 2
0
def test_base64uri_img():
    img_file = path.join(path.dirname(__file__), 'data', 'user.png')
    with open(img_file) as img_file_handle:
        img = PIL.Image.open(img_file_handle)
        b64img = h.base64uri(img)
        assert b64img.startswith('data:image/png;base64,'), b64img[:100]
        assert len(b64img) > 500
Ejemplo n.º 3
0
def test_base64uri_text():
    b64txt = h.base64uri('blah blah blah 123 456 foo bar baz', mimetype='text/plain')
    assert b64txt.startswith('data:text/plain;base64,'), b64txt