feat: a ready sheet prints at its real size, centred on the film, with the customer's confirmation (Marcus, 2026-12-02)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m55s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m43s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m55s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m43s
Replaces 7111995 (only 57,0 cm entered; a whole order of 56,5-56,9 cm
sheets was refused, DTF-WEB-2C). Marcus's rules, for Arquivo por metro,
Premium (57 cm) and UV (27 cm):
1. A known width up to the film (PNG recording 200 DPI or more, or a PDF
page) enters at its real size, centred, billed by its real height.
2. Narrower: his warning before the cart, confirmation required
(Imprimir no tamanho real / Enviar outro arquivo); recorded in the
Prumo report ("cliente confirmou folha de 35,8 cm no tamanho real") and
shown in the cart and payment summaries.
3. Wider than the film: refused with his message.
4. Unknown width: taken as the film's, DPI from the pixels; 200 or more
with a confirmation, under 200 refused with the artes avulsas hint.
Within 0,1 cm of the film counts as the film. The server checks it all
again at checkout (sheet_width_issue, centred placement, size_confirmed).
Also ops.stretched_sheets: the ready-sheet orders since 16/10 laid out
wider than their real width (number, real width, factor), for Marcus.
Contract: output/revisao/contrato-folha-real.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -243,58 +243,98 @@ class ProportionTests(unittest.TestCase):
|
||||
|
||||
|
||||
class SheetWidthTests(unittest.TestCase):
|
||||
"""A 57 cm ready sheet must really be 57 cm wide where the file tells
|
||||
(contrato-largura-folha.md), or the cart is refused."""
|
||||
"""A ready sheet prints at its real size, centred on the film
|
||||
(contrato-folha-real.md, Server V1–V5)."""
|
||||
|
||||
def cart(self, mode, name, width_cm=57):
|
||||
source = {'upload_id': name, 'kind': 'sheet', 'width_cm': width_cm}
|
||||
def cart(self, mode, name, width_cm=57, **source):
|
||||
source = {'upload_id': name, 'kind': 'sheet', 'width_cm': width_cm,
|
||||
'measurement': 'file', **source}
|
||||
return [{'mode': mode, 'production': {'sources': [source]}}], {name: {'name': name}}
|
||||
|
||||
def test_a_narrow_png_is_refused(self):
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('file', 'sheet.png')
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('35,8 cm', issue)
|
||||
self.assertIn('300 DPI', issue)
|
||||
def test_an_unknown_sheet_is_laid_out_at_the_film_width(self):
|
||||
# Rule 4: no DPI recorded, the sheet is taken as 57 cm; another width is a stretched layout.
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (6732, 100))})
|
||||
items, rows = self.cart('file', 'sheet.png', width_cm=40, size_confirmed=True)
|
||||
self.assertIn('foi montada com 40,0 cm, mas tem 57 cm', grade_check.sheet_width_issue(files, items, rows))
|
||||
|
||||
def test_a_wide_png_is_refused(self):
|
||||
def test_a_narrow_known_sheet_asks_for_confirmation(self):
|
||||
# V3: 4227 px at 300 DPI is 35,8 cm, below the 57 cm film.
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('file', 'sheet.png', width_cm=35.79)
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('confirme a folha 1 de 35,8 cm no tamanho real', issue)
|
||||
|
||||
def test_a_confirmed_narrow_sheet_passes(self):
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('file', 'sheet.png', width_cm=35.79, size_confirmed=True)
|
||||
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows))
|
||||
|
||||
def test_a_stretched_sheet_must_be_mounted_again(self):
|
||||
# V2: the source says 57 cm, the file measures 35,8 cm.
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('file', 'sheet.png', width_cm=57)
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('foi montada com 57,0 cm, mas tem 35,8 cm', issue)
|
||||
|
||||
def test_a_sheet_wider_than_the_film_is_refused(self):
|
||||
# V1: 7200 px at 300 DPI is 61,0 cm.
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (7200, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('file', 'sheet.png')
|
||||
self.assertIn('61,0 cm', grade_check.sheet_width_issue(files, items, rows))
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('61,0 cm', issue)
|
||||
self.assertIn('não cabe', issue)
|
||||
|
||||
def test_sheet_width_rounding_boundaries(self):
|
||||
for width_px, refused in ((6732, False), (6721, False), (6720, True)):
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (width_px, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('file', 'sheet.png')
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
if refused:
|
||||
self.assertIn('56,9 cm', issue)
|
||||
else:
|
||||
self.assertIsNone(issue, width_px)
|
||||
def test_a_sheet_within_tolerance_of_the_film_passes(self):
|
||||
# 6732 px at 300 DPI is 56,998 cm: within 0,1 cm of the film, no dialog.
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (6732, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('file', 'sheet.png', width_cm=56.998)
|
||||
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows))
|
||||
|
||||
def test_png_under_trusted_dpi_passes(self):
|
||||
for options in ({}, {'dpi': (96, 96)}, {'dpi': (150, 150)}):
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), **options)})
|
||||
items, rows = self.cart('file', 'sheet.png')
|
||||
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows), options)
|
||||
def test_an_unknown_width_is_taken_as_the_film(self):
|
||||
# V5: no pHYs, 6732 px over 57 cm is 300 effective DPI.
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (6732, 100))})
|
||||
items, rows = self.cart('file', 'sheet.png')
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('confirme a folha 1 de 57 cm antes de pagar', issue)
|
||||
items, rows = self.cart('file', 'sheet.png', size_confirmed=True)
|
||||
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows))
|
||||
|
||||
def test_only_the_57_cm_modes_are_checked(self):
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('premium', 'sheet.png')
|
||||
self.assertIn('35,8 cm', grade_check.sheet_width_issue(files, items, rows))
|
||||
for mode in ('uvfile', 'avulsa'):
|
||||
items, rows = self.cart(mode, 'sheet.png')
|
||||
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows), mode)
|
||||
def test_an_unknown_width_under_the_minimum_dpi_is_refused(self):
|
||||
# V4: 2154 px over 57 cm is 96 effective DPI.
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (2154, 100))})
|
||||
items, rows = self.cart('file', 'sheet.png')
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('96 DPI em 57 cm', issue)
|
||||
|
||||
def test_a_pdf_width_is_checked(self):
|
||||
def test_uv_uses_the_27_cm_film(self):
|
||||
# 2362 px at 300 DPI is 20,0 cm on the 27 cm UV film.
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (2362, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('uvfile', 'sheet.png', width_cm=20)
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('confirme a folha 1 de 20,0 cm no tamanho real', issue)
|
||||
|
||||
def test_a_narrow_pdf_asks_for_confirmation(self):
|
||||
files = FakeFiles({})
|
||||
items, rows = self.cart('file', 'sheet.pdf', width_cm=30)
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('30,0 cm', issue)
|
||||
self.assertNotIn('DPI', issue)
|
||||
for width_cm in (57, '56.95'):
|
||||
items, rows = self.cart('file', 'sheet.pdf', width_cm=width_cm)
|
||||
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows), width_cm)
|
||||
self.assertIn('confirme a folha 1 de 30,0 cm no tamanho real', issue)
|
||||
|
||||
def test_a_pdf_wider_than_the_film_is_refused(self):
|
||||
files = FakeFiles({})
|
||||
items, rows = self.cart('file', 'sheet.pdf', width_cm=60)
|
||||
issue = grade_check.sheet_width_issue(files, items, rows)
|
||||
self.assertIn('não cabe', issue)
|
||||
self.assertIn('60,0 cm', issue)
|
||||
|
||||
def test_customer_measured_sheets_pass(self):
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('file', 'sheet.png', width_cm=35.79, measurement='customer')
|
||||
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows))
|
||||
|
||||
def test_loose_art_is_not_checked(self):
|
||||
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
|
||||
items, rows = self.cart('avulsa', 'sheet.png', width_cm=35.79)
|
||||
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows))
|
||||
|
||||
def test_png_saved_dpi(self):
|
||||
head = encoded('PNG', (4227, 100), dpi=(300, 300))
|
||||
|
||||
Reference in New Issue
Block a user