def test_material_image(): expected_result = """{ "image": { "image": "https://site.com/image.png", "repeat": [ 2, 2 ], "color": { "rgba": [ 200, 100, 30, 255 ] }, "transparent": false } }""" mat = Material(image=ImageMaterial( image=Uri(uri="https://site.com/image.png"), repeat=[2, 2], color=Color.from_list([200, 100, 30]), )) assert repr(mat) == expected_result pol_mat = PolylineMaterial(image=ImageMaterial( image=Uri(uri="https://site.com/image.png"), repeat=[2, 2], color=Color.from_list([200, 100, 30]), )) assert repr(pol_mat) == expected_result
def test_bad_uri_raises_error(): with pytest.raises(ValueError) as excinfo: Uri(uri="a") assert "uri must be a URL or a data URI" in excinfo.exconly()