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:
83
tests/test_stretched_sheets.py
Normal file
83
tests/test_stretched_sheets.py
Normal file
@@ -0,0 +1,83 @@
|
||||
"""ops.stretched_sheets lists the ready sheets laid out wider than they are."""
|
||||
import io
|
||||
import unittest
|
||||
from contextlib import contextmanager
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from ops import stretched_sheets
|
||||
|
||||
|
||||
def png(width, dpi=None):
|
||||
out = io.BytesIO()
|
||||
Image.new('RGBA', (width, 10)).save(out, 'PNG', **({'dpi': (dpi, dpi)} if dpi else {}))
|
||||
return out.getvalue()
|
||||
|
||||
|
||||
class Storage:
|
||||
bucket = 'b'
|
||||
|
||||
def __init__(self, blobs):
|
||||
self.blobs = blobs
|
||||
self.client = self
|
||||
|
||||
def get_object(self, Bucket, Key, Range):
|
||||
return {'Body': io.BytesIO(self.blobs[Key])}
|
||||
|
||||
|
||||
class Result:
|
||||
def __init__(self, rows):
|
||||
self.rows = rows
|
||||
|
||||
def fetchall(self):
|
||||
return self.rows
|
||||
|
||||
def fetchone(self):
|
||||
return self.rows[0] if self.rows else None
|
||||
|
||||
|
||||
class Connection:
|
||||
def __init__(self, orders, uploads):
|
||||
self.orders, self.uploads = orders, uploads
|
||||
|
||||
def execute(self, sql, params):
|
||||
if 'FROM dtf_local.orders' in sql:
|
||||
return Result(self.orders)
|
||||
return Result([self.uploads[params[0]]] if params[0] in self.uploads else [])
|
||||
|
||||
|
||||
def order(number, mode='file', width=57, upload='u', provider='mercadopago'):
|
||||
return {'id': number, 'number': number, 'payment': {'provider': provider}, 'created_at': None,
|
||||
'snapshot': {'items': [{'mode': mode, 'production': {'sources': [
|
||||
{'upload_id': upload, 'kind': 'sheet' if mode != 'avulsa' else 'artwork',
|
||||
'measurement': 'file', 'width_cm': width}]}}]}}
|
||||
|
||||
|
||||
class StretchedSheetsTests(unittest.TestCase):
|
||||
def run_with(self, orders, uploads, blobs):
|
||||
@contextmanager
|
||||
def connect():
|
||||
yield Connection(orders, uploads)
|
||||
lines = []
|
||||
stretched, unknown = stretched_sheets.main([], out=lines.append, storage=Storage(blobs), connect=connect)
|
||||
return stretched, unknown, lines
|
||||
|
||||
def test_only_sheets_laid_out_at_another_width_are_listed(self):
|
||||
uploads = {name: {'name': f'{name}.png', 'object_key': name, 'purged_at': None}
|
||||
for name in ('narrow', 'right', 'nodpi', 'gone', 'loose', 'test')}
|
||||
uploads['gone']['purged_at'] = '2026-11-20'
|
||||
blobs = {'narrow': png(4227, 300), 'right': png(6732, 300), 'nodpi': png(4227),
|
||||
'loose': png(1000, 300), 'test': png(4227, 300)}
|
||||
orders = [order(177, upload='narrow'), order(178, upload='right'), order(179, upload='nodpi'),
|
||||
order(180, upload='gone'), order(181, mode='avulsa', upload='loose'),
|
||||
order(182, upload='test', provider='teste')]
|
||||
stretched, unknown, lines = self.run_with(orders, uploads, blobs)
|
||||
self.assertEqual([row[0] for row in stretched], [177])
|
||||
self.assertIn('largura real 35,8 cm · montada com 57,0 cm · fator 1,59', '\n'.join(lines))
|
||||
self.assertEqual(len(unknown), 2)
|
||||
self.assertTrue(any('#179' in line and 'não grava o DPI' in line for line in unknown))
|
||||
self.assertTrue(any('#180' in line and 'apagado' in line for line in unknown))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user