def test_create_thumbnails(product_with_image, settings): sizeset = settings.VERSATILEIMAGEFIELD_RENDITION_KEY_SETS["products"] product_image = product_with_image.images.first() # There's no way to list images created by versatile prewarmer # So we delete all created thumbnails/crops and count them log_deleted_images = io.StringIO() with redirect_stdout(log_deleted_images): product_image.image.delete_all_created_images() log_deleted_images = log_deleted_images.getvalue() # Image didn't have any thumbnails/crops created, so there's no log assert not log_deleted_images create_thumbnails(product_image.pk, ProductImage, "products") log_deleted_images = io.StringIO() with redirect_stdout(log_deleted_images): product_image.image.delete_all_created_images() log_deleted_images = log_deleted_images.getvalue() for image_name, method_size in sizeset: method, size = method_size.split("__") if method == "crop": assert product_image.image.crop[size].name in log_deleted_images elif method == "thumbnail": assert ( product_image.image.thumbnail[size].name in log_deleted_images ) # noqa
def test_create_thumbnails(product_with_image, settings): sizeset = settings.VERSATILEIMAGEFIELD_RENDITION_KEY_SETS["products"] product_image = product_with_image.images.first() # There's no way to list images created by versatile prewarmer # So we delete all created thumbnails/crops and count them log_deleted_images = io.StringIO() with redirect_stdout(log_deleted_images): product_image.image.delete_all_created_images() log_deleted_images = log_deleted_images.getvalue() # Image didn't have any thumbnails/crops created, so there's no log assert not log_deleted_images create_thumbnails(product_image.pk, ProductImage, "products") log_deleted_images = io.StringIO() with redirect_stdout(log_deleted_images): product_image.image.delete_all_created_images() log_deleted_images = log_deleted_images.getvalue() for image_name, method_size in sizeset: method, size = method_size.split("__") if method == "crop": assert product_image.image.crop[size].name in log_deleted_images elif method == "thumbnail": assert ( product_image.image.thumbnail[size].name in log_deleted_images ) # noqa