test: bucket cover_crop_params geometry

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 22:48:13 +02:00
parent cdd742c950
commit 0413e25571
+20
View File
@@ -25,3 +25,23 @@ def test_buckets_are_on_grid_and_within_budget():
def test_square_is_exactly_1280():
assert buckets.pick_bucket(512, 512, 1280, 64) == (1280, 1280)
def test_cover_crop_exact_aspect_no_crop():
# a=2.0 image onto 1792x896 bucket -> scale 0.896, no crop
new_w, new_h, left, top, scale = buckets.cover_crop_params(2000, 1000, 1792, 896)
assert (new_w, new_h) == (1792, 896)
assert (left, top) == (0, 0)
assert round(scale, 3) == 0.896
def test_cover_crop_square_into_landscape_crops_height():
new_w, new_h, left, top, scale = buckets.cover_crop_params(1000, 1000, 1792, 896)
assert new_w == 1792 and new_h >= 896
assert left == 0 and top == (new_h - 896) // 2 # centered vertical crop
assert scale > 1.0 # upscaled to cover width
def test_cover_crop_upscale_square():
*_, scale = buckets.cover_crop_params(1000, 1000, 1280, 1280)
assert round(scale, 2) == 1.28