def test_checker_invalid_order(builder, checker_classes): builder.create_used_image("000-001", "0001.jpg") builder.create_used_image("000-001", "0000.jpg") builder.save_images() builder.save_toc([]) put_transform_contents(builder, "000-001") builder.run_program() check_all_invalid(builder, checker_classes)
def test_checker_valid_reference_override(builder, checker_classes): builder.create_used_image("000-001", "0000.jpg") builder.override_reference_image() builder.save_images() builder.save_toc([]) put_transform_contents(builder, "000-001") builder.run_program() check_all_valid(builder, checker_classes)
def test_subdir_order(builder): builder.create_unused_image("000-002", "0001.jpg") builder.create_used_image("001-002", "0001.jpg") builder.create_used_image("000-002", "0002.jpg") postprocess_builder(builder) adjust_mtime(builder.path().join("input", "001-002", "0001.jpg"), -1000) builder.save_transform_ini("000-002", "[transform]\njustconvert: yes\n") builder.save_transform_ini("001-002", "[transform]\njustconvert: yes\n") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_subdir_order(builder): builder.create_unused_image("000-002", "0001.jpg") builder.create_used_image("001-002", "0001.jpg") builder.create_used_image("000-002", "0002.jpg") postprocess_builder(builder) adjust_mtime(builder.path().join("input", "001-002", "0001.jpg"), -1000) builder.save_transform_ini("000-002", "[transform]\njustconvert: yes\n") builder.save_transform_ini("001-002", "[transform]\njustconvert: yes\n") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_toc(builder): builder.create_used_image("000-010", "0000.jpg") builder.create_used_image("000-010", "0001.jpg") builder.create_used_image("000-010", "0002.jpg") builder.create_used_image("000-010", "0003.jpg") builder.create_used_image("000-010", "0004.jpg") builder.save_images() builder.save_transform_ini("000-010", "[transform]\njustconvert: yes") builder.save_toc([[0, 1, "Page 1"], [1, 2, "Страница 2"], [2, 3, "'Quotes\""], [0, 5, "Page 5"]]) builder.run_program() check_all_valid(builder)
def test_toc(builder): builder.create_used_image("000-010", "0000.jpg") builder.create_used_image("000-010", "0001.jpg") builder.create_used_image("000-010", "0002.jpg") builder.create_used_image("000-010", "0003.jpg") builder.create_used_image("000-010", "0004.jpg") builder.save_images() builder.save_transform_ini("000-010", "[transform]\njustconvert: yes") builder.save_toc([ [0, 1, "Page 1"], [1, 2, "Страница 2"], [2, 3, "'Quotes\""], [0, 5, "Page 5"]]) builder.run_program() check_all_valid(builder)
def test_rotate(builder): (builder.create_used_image("000-003", "0000.jpg").set_validation_rotation(90)) (builder.create_used_image("000-003", "0001.jpg").set_validation_rotation(270)) (builder.create_used_image("000-003", "0002.jpg").add_border( 10, 20, 30, 40, (0, 0, 0)).border_count_to_check(0).set_validation_rotation(90)) (builder.create_used_image("000-003", "0003.jpg").add_border( 10, 20, 30, 40, (0, 0, 0)).border_count_to_check(0).set_validation_rotation(270)) postprocess_builder(builder) builder.save_transform_ini( "000-003", "[transform]\n" + "chop-background: black\n" + "rotate-odd: 270\n" + "rotate-even: 90\n" + "blur: 0\n") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_different_background_color(builder): (builder.create_used_image("000-001", "0000.jpg").add_border( 30, 30, 30, 30, (0, 0, 255)).border_count_to_check(1)) postprocess_builder(builder) builder.save_transform_ini( "000-001", "[transform]\n" + "chop-background: black\n" + "blur: 0") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_checker_invalid_reference_override(builder, checker_classes): (builder.create_used_image("000-001", "0000.jpg") .add_border(20, 20, 20, 20, (0, 0, 0))) (builder.override_reference_image() .add_border(50, 50, 50, 50, (0, 0, 0))) builder.save_images() builder.save_toc([]) put_transform_contents(builder, "000-001") builder.run_program() check_all_invalid(builder, checker_classes)
def test_chop_size(builder): (builder.create_used_image("000-001", "0000.jpg").add_border( 0, 60, 60, 0, (0, 0, 255)).add_border(30, 0, 0, 30, (0, 255, 0)).border_count_to_check(2)) postprocess_builder(builder) builder.save_transform_ini( "000-001", "[transform]\n" + "chop-background: blue\n" + "chop-edge: North West\n" + "chop-size: 20\n" + "blur: 0") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_chop_edge(builder): (builder.create_used_image("000-001", "0000.jpg").add_border( 0, 60, 60, 0, (0, 0, 255)).add_border(30, 0, 0, 30, (0, 255, 0))) (builder.override_reference_image().add_border( 0, 0, 60, 0, (0, 0, 255)).add_border(30, 0, 0, 30, (0, 255, 0))) postprocess_builder(builder) builder.save_transform_ini( "000-001", "[transform]\n" + "chop-background: blue\n" + "chop-edge: North\n" + "chop-size: 35\n" + "blur: 0") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_different_background_color(builder): (builder.create_used_image("000-001", "0000.jpg") .add_border(30, 30, 30, 30, (0, 0, 255)) .border_count_to_check(1)) postprocess_builder(builder) builder.save_transform_ini("000-001", "[transform]\n" + "chop-background: black\n" + "blur: 0") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_rotate(builder): (builder.create_used_image("000-003", "0000.jpg") .set_validation_rotation(90)) (builder.create_used_image("000-003", "0001.jpg") .set_validation_rotation(270)) (builder.create_used_image("000-003", "0002.jpg") .add_border(10, 20, 30, 40, (0, 0, 0)) .border_count_to_check(0) .set_validation_rotation(90)) (builder.create_used_image("000-003", "0003.jpg") .add_border(10, 20, 30, 40, (0, 0, 0)) .border_count_to_check(0) .set_validation_rotation(270)) postprocess_builder(builder) builder.save_transform_ini("000-003", "[transform]\n" + "chop-background: black\n" + "rotate-odd: 270\n" + "rotate-even: 90\n" + "blur: 0\n") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_chop_size(builder): (builder.create_used_image("000-001", "0000.jpg") .add_border(0, 60, 60, 0, (0, 0, 255)) .add_border(30, 0, 0, 30, (0, 255, 0)) .border_count_to_check(2)) postprocess_builder(builder) builder.save_transform_ini("000-001", "[transform]\n" + "chop-background: blue\n" + "chop-edge: North West\n" + "chop-size: 20\n" + "blur: 0") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_image_depends_on_transform(builder): (builder.create_used_image("000-001", "0000.jpg").add_border( 30, 30, 30, 30, (0, 0, 0)).border_count_to_check(0)) postprocess_builder(builder) builder.save_transform_ini("000-001", "[transform]\njustconvert: yes\n") # Image file does not trigger update by itself. adjust_mtime(builder.path().join("input", "000-001", "0000.jpg"), -1000) adjust_mtime(builder.path().join("input", "000-001", "transform.ini"), -1000) builder.run_program() assert not builder.valid(PreparedImagesOutputChecker) builder.save_transform_ini( "000-001", "[transform]\n" + "chop-background: black\n" + "blur: 0") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_chop_edge(builder): (builder.create_used_image("000-001", "0000.jpg") .add_border(0, 60, 60, 0, (0, 0, 255)) .add_border(30, 0, 0, 30, (0, 255, 0))) (builder.override_reference_image() .add_border(0, 0, 60, 0, (0, 0, 255)) .add_border(30, 0, 0, 30, (0, 255, 0))) postprocess_builder(builder) builder.save_transform_ini("000-001", "[transform]\n" + "chop-background: blue\n" + "chop-edge: North\n" + "chop-size: 35\n" + "blur: 0") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def test_image_depends_on_transform(builder): (builder.create_used_image("000-001", "0000.jpg") .add_border(30, 30, 30, 30, (0, 0, 0)) .border_count_to_check(0)) postprocess_builder(builder) builder.save_transform_ini("000-001", "[transform]\njustconvert: yes\n") # Image file does not trigger update by itself. adjust_mtime(builder.path().join("input", "000-001", "0000.jpg"), -1000) adjust_mtime(builder.path().join("input", "000-001", "transform.ini"), -1000) builder.run_program() assert not builder.valid(PreparedImagesOutputChecker) builder.save_transform_ini("000-001", "[transform]\n" + "chop-background: black\n" + "blur: 0") builder.run_program() assert builder.valid(PreparedImagesOutputChecker)
def prepare_three_images(builder): for i in range(1, 4): builder.create_used_image("001-003", "%04d.jpg" % i) builder.save_images() put_transform_contents(builder, "001-003")