test: a paid ready sheet with its empty strips cut bills 1 m and prints only what is left
Some checks failed
Build and deploy / Validate source (push) Successful in 13s
Build and deploy / Integration suite on a real stack (push) Failing after 4m20s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Has been skipped

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) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-18 13:29:46 -03:00
parent b3ecba590b
commit 70eb6947eb

View File

@@ -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 Run inside the API container (it needs Pillow): python -m tests.print_file_test
""" """
import io import io
from decimal import Decimal
import time import time
from urllib.request import urlopen from urllib.request import urlopen
from uuid import uuid4 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'] 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') 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 # Item 7: "Abrir e conferir" gets the file in pieces, the first of which is
# the top of the film, then the original. # the top of the film, then the original.
view = client.call('/operator/orders/' + order['id'] + '/view', operator=True)['files'] view = client.call('/operator/orders/' + order['id'] + '/view', operator=True)['files']