Esempio n. 1
0
def test_validator_coercion_PIL(validator: ImageUriValidator):
    # Single pixel black png (http://png-pixel.com/)

    img_path = '_plotly_utils/tests/resources/1x1-black.png'
    with open(img_path, 'rb') as f:
        hex_bytes = base64.b64encode(f.read()).decode('ascii')
        expected_uri = 'data:image/png;base64,' + hex_bytes

    img = Image.open(img_path)
    coerce_val = validator.validate_coerce(img)
    assert coerce_val == expected_uri
Esempio n. 2
0
def test_validator_acceptance(val, validator: ImageUriValidator):
    assert validator.validate_coerce(val) == val