From 70eb6947ebe583d36aca83c5c03f9aab91168c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Wed, 18 Nov 2026 13:29:46 -0300 Subject: [PATCH] test: a paid ready sheet with its empty strips cut bills 1 m and prints only what is left End to end on the real stack: a 27 x 30 cm UV PNG with 20 cm of art in the middle, quoted with the 4,5 cm the Site cuts above and below, paid; the worker's PNG is 21 cm plus the footer, transparent 0,5 cm above and below the art, and the Prumo report says "Faixas vazias cortadas: 9,0 cm". Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/print_file_test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/print_file_test.py b/tests/print_file_test.py index 81e66a0..fcb22f7 100644 --- a/tests/print_file_test.py +++ b/tests/print_file_test.py @@ -9,6 +9,7 @@ Kanban until someone records what was done. Run inside the API container (it needs Pillow): python -m tests.print_file_test """ import io +from decimal import Decimal import time from urllib.request import urlopen from uuid import uuid4 @@ -106,6 +107,34 @@ def run(): assert row['detail']['footer'].startswith('DROPSTAR · Pedido DTF-%d · Item 1/1 · ' % order['number']), row['detail'] print('PASS: paid order generated a 57 x 10 cm PNG print file with both copies and its footer') + # A ready sheet with its empty strips cut (Marcus, 2026-11-18): the cart + # sends what the Site cut from the top and bottom of a 27 x 30 cm UV sheet + # with 20 cm of art in the middle, as web/site-upload.js aplicaCorte does. + # The order bills and prints the 21 cm left, the art whole. + sheet = Image.new('RGBA', (270, 300)) + sheet.paste(Image.new('RGBA', (230, 200), (30, 60, 200, 255)), (20, 50)) + buffer = io.BytesIO() + sheet.save(buffer, 'PNG', dpi=(25.4, 25.4)) + sheet_upload = upload_bytes(client, buffer.getvalue(), name='LOCAL-TRIMMED-SHEET.png') + trimmed = {'mode': 'uvfile', 'metres': '0.21', 'grade': 90, 'uploads': [sheet_upload], + 'production': {'version': 3, 'film_width_cm': 27, 'height_cm': 21, + 'sources': [{'upload_id': sheet_upload, 'kind': 'sheet', 'width_cm': 27, + 'length_cm': 21, 'copies': 1, 'rotation_degrees': 0, 'mirrored': False, + 'measurement': 'file', 'trim_top_cm': 4.5, 'trim_bottom_cm': 4.5}], + 'placements': [{'source_index': 0, 'copy_index': 0, 'x_cm': 0, 'y_cm': 0, + 'width_cm': 27, 'length_cm': 21, 'rotation_degrees': 0, + 'mirrored': False}]}, + 'quality_status': 'ok', 'quality_acknowledged': False} + sheet_order, sheet_row = wait_print(client, paid_order(client, trimmed)['id'], 'ready') + assert any(line.endswith('Faixas vazias cortadas: 9,0 cm') for line in sheet_order['prumo']), sheet_order['prumo'] + assert Decimal(sheet_order['snapshot']['items'][0]['billed_metres']) == 1, sheet_order['snapshot']['items'][0] + film = download_png(client, sheet_row['upload_id']) + assert film.size == (px(27), px(21) + px(1.5)), film.size + # 0,5 cm of margin above and below the art, which fills the rest. + assert film.getpixel((px(13), px(0.2)))[3] == 0 and film.getpixel((px(13), px(20.8)))[3] == 0 + assert film.getpixel((px(13), px(1))) == (30, 60, 200, 255) and film.getpixel((px(13), px(20))) == (30, 60, 200, 255) + print('PASS: a ready sheet with its empty strips cut bills and prints only what is left') + # Item 7: "Abrir e conferir" gets the file in pieces, the first of which is # the top of the film, then the original. view = client.call('/operator/orders/' + order['id'] + '/view', operator=True)['files']