Beispiel #1
0
 def test_warn_fallback_to_fit(self, ctx, test_jpg, source_url_path):
     with pytest.warns(UserWarning, match=r"mode requires both"):
         make_image_thumbnail(
             ctx, test_jpg, source_url_path, width=80, mode=ThumbnailMode.CROP
         )
     assert len(ctx.sub_artifacts) == 1
Beispiel #2
0
 def test_no_width_or_height(self, ctx, test_jpg, source_url_path):
     with pytest.raises(ValueError, match=r"Must specify at least one"):
         make_image_thumbnail(ctx, test_jpg, source_url_path)
     assert len(ctx.sub_artifacts) == 0
Beispiel #3
0
 def test_svg(self, ctx, svg_image, source_url_path):
     rv = make_image_thumbnail(ctx, svg_image, source_url_path, 40, 60)
     assert rv.width == 40
     assert rv.height == 60
     assert rv.url_path == source_url_path
     assert len(ctx.sub_artifacts) == 0
Beispiel #4
0
 def test_implicit_upscale(self, ctx, test_jpg, source_url_path):
     with pytest.warns(UserWarning, match=r"image is being scaled up"):
         rv = make_image_thumbnail(ctx, test_jpg, source_url_path, 512)
     assert (rv.width, rv.height) == (512, 683)
     assert rv.url_path == "*****@*****.**"
     assert len(ctx.sub_artifacts) == 1
Beispiel #5
0
 def test_unknown_image_format(self, ctx, project, source_url_path):
     bad_img = os.path.join(project.tree, "content/contents.lr")
     with pytest.raises(RuntimeError, match=r"unknown image"):
         make_image_thumbnail(ctx, bad_img, source_url_path, width=80)
     assert len(ctx.sub_artifacts) == 0