def METHOD_NAME(
    filename,
    tmpdir_factory,
    settings,
    django_capture_on_commit_callbacks,
    expected_bytes,
):
    settings.task_eager_propagates = (True,)
    settings.task_always_eager = (True,)
    input_directory = tmpdir_factory.mktemp("temp")
    temp_file = Path(input_directory / filename)
    shutil.copy(RESOURCE_PATH / filename, temp_file)
    with django_capture_on_commit_callbacks() as callbacks:
        imported_images = import_images(input_directory=input_directory)
    assert len(callbacks) == 1
    assert imported_images.consumed_files == {temp_file}
    assert len(imported_images.new_images) == 1
    new_image = imported_images.new_images.pop()
    image_files = ImageFile.objects.filter(image=new_image)
    assert len(image_files) == 1
    image_file = image_files[0]
    assert image_file.post_processed is False
    callbacks[0]()
    all_image_files = ImageFile.objects.filter(image=new_image)
    if filename == "valid_tiff.tif":
        assert len(all_image_files) == 2
        dzi = all_image_files.get(image_type=ImageType.DZI)
        assert protected_s3_storage.exists(str(dzi.file))
        assert protected_s3_storage.exists(
            str(dzi.file).replace(".dzi", "_files/0/0_0.jpeg")
        )
    else:
        assert len(all_image_files) == 1
    image_file.refresh_from_db()
    assert image_file.post_processed is True
    # Newly created images should not be marked as post processed
    assert ImageFile.objects.filter(post_processed=True).count() == 1
    # Task should be idempotent, but all related
    # files are now marked as post processed
    post_process_image(image_pk=new_image.pk)
    all_image_files = ImageFile.objects.filter(image=new_image)
    if filename == "valid_tiff.tif":
        assert len(all_image_files) == 2
        assert ImageFile.objects.count() == 2
        assert ImageFile.objects.filter(post_processed=True).count() == 2
    else:
        assert len(all_image_files) == 1
        assert ImageFile.objects.count() == 1
        assert ImageFile.objects.filter(post_processed=True).count() == 1
    assert (
        sum(file.size_in_storage for file in ImageFile.objects.all())
        == expected_bytes
    )