def test_check_for_no_unused_images(caplog, media: Path): caplog.set_level(30, 'EDLM') caplog.clear() ctx = Context() ctx.media_folders = [str(media.absolute()), '.'] ctx.images_used = set() caplog.clear() ctx.images_used = set() for file in list(media.iterdir()): ctx.images_used.add(file.name) check_for_unused_images(ctx) for file in list(media.iterdir()): assert file.name not in caplog.text
def test_check_for_used_images_only_one_media_folder(caplog): caplog.set_level(30, 'EDLM') caplog.clear() ctx = Context() ctx.media_folders = ['.'] ctx.images_used = set() check_for_unused_images(ctx) assert not caplog.text
def test_process_image_http(): ctx = Context() ctx.images_used = set() match = mock() when(match).group('caption').thenReturn('caption') when(match).group('picture').thenReturn('http://something') when(match).group('extras').thenReturn('extras') when(image)._process_image_width(ctx) when(image)._get_image_full_path(ctx).thenReturn('image_current') result = image._process_image(ctx, match) assert result == '![caption](http://something)extras' assert ctx.image_current == 'http://something' verify(image)._process_image_width(ctx) when(image)._get_image_full_path(ctx)