feat: the bobbin footer names the customer and counts the pieces, without price (Rodada 5, C3)
DROPSTAR · Pedido DTF-7 · <cliente> · Item 1/2 · data · metros · N peças (loose arts) or N cópias (a ready sheet repeated). The name is tidied to cp1252 and cut at 24 characters; the proof footer is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,7 +33,8 @@ def download_png(client, upload_id):
|
||||
image = Image.open(io.BytesIO(response.read()))
|
||||
assert image.format == 'PNG' and image.mode == 'RGBA', (image.format, image.mode)
|
||||
return image
|
||||
CUSTOMER = {'cnpj': '11222333000181', 'zap': '11999999999', 'mail': 'print-test@example.test'}
|
||||
CUSTOMER = {'cnpj': '11222333000181', 'zap': '11999999999', 'mail': 'print-test@example.test',
|
||||
'name': 'Cliente Print Test'}
|
||||
|
||||
|
||||
def artwork(kind='PNG'):
|
||||
@@ -104,7 +105,10 @@ def run():
|
||||
for copy in range(2):
|
||||
assert film.getpixel((px(20 * copy + 10), px(5))) == (220, 30, 60, 255), copy
|
||||
assert film.getpixel((px(50), px(5)))[3] == 0
|
||||
assert row['detail']['footer'].startswith('DROPSTAR · Pedido DTF-%d · Item 1/1 · ' % order['number']), row['detail']
|
||||
footer = row['detail']['footer']
|
||||
assert footer.startswith('DROPSTAR · Pedido DTF-%d · %s · Item 1/1 · '
|
||||
% (order['number'], CUSTOMER['name'])), footer
|
||||
assert footer.endswith(' · 2 peças'), 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
|
||||
|
||||
@@ -129,7 +129,7 @@ class PrintFileTests(unittest.TestCase):
|
||||
job = {'snapshot': {'items': [spec, spec]}, 'number': 7, 'item_index': 1,
|
||||
'ordered_at': datetime(2026, 10, 23, 15, 0, tzinfo=timezone.utc)}
|
||||
line = footer(job, spec)
|
||||
self.assertEqual(line, 'DROPSTAR · Pedido DTF-7 · Item 2/2 · 23/10/2026 · 1,00 m · ESPELHADO')
|
||||
self.assertEqual(line, 'DROPSTAR · Pedido DTF-7 · Item 2/2 · 23/10/2026 · 1,00 m · 1 peça · ESPELHADO')
|
||||
self.assertIn(b'/F1 31 Tf ( \xb7 ESPELHADO) Tj', footer_commands(line, (100, 80)))
|
||||
# About 1 cm tall on the 57 cm film (Dropstar, 2026-10-28); on the 27 cm UV
|
||||
# the line shrinks to fit the width instead of running off the film.
|
||||
@@ -149,6 +149,35 @@ class PrintFileTests(unittest.TestCase):
|
||||
self.assertEqual(file_prefix(130, 0, 2), 'DTF-130-v2-item-1')
|
||||
self.assertEqual(file_prefix(130, 0, 1), 'DTF-130-item-1')
|
||||
|
||||
def test_the_footer_names_the_customer_and_the_pieces(self):
|
||||
from datetime import datetime, timezone
|
||||
from app.printjobs import footer
|
||||
|
||||
def line(name, spec, items=2):
|
||||
customer = {} if name is None else {'name': name}
|
||||
job = {'snapshot': {'items': [spec] * items, 'customer': customer},
|
||||
'number': 7, 'item_index': 0,
|
||||
'ordered_at': datetime(2026, 10, 21, 15, 0, tzinfo=timezone.utc)}
|
||||
return footer(job, spec)
|
||||
|
||||
spec = item([placement(0, 0, 20, 10)], [source(20, 10)], 10)
|
||||
start = 'DROPSTAR · Pedido DTF-7 · '
|
||||
end = ' · Item 1/2 · 21/10/2026 · 1,00 m · 1 peça'
|
||||
# An accent stays; an emoji does not; a long name is cut with an ellipsis.
|
||||
self.assertEqual(line('Gráfica São José', spec), start + 'Gráfica São José' + end)
|
||||
self.assertEqual(line('Loja 🌟 Azul', spec), start + 'Loja Azul' + end)
|
||||
self.assertEqual(line('Gráfica São José do Vale do Paraíba', spec),
|
||||
start + 'Gráfica São José do Val…' + end)
|
||||
# Without a name the field is left out, with no stray separator.
|
||||
self.assertEqual(line(None, spec), 'DROPSTAR · Pedido DTF-7' + end)
|
||||
# A ready sheet counts its copies, and only says so above one.
|
||||
sheet = item([placement(0, 0, 20, 10)], [{**source(20, 10), 'kind': 'sheet', 'copies': 3}], 10)
|
||||
self.assertEqual(line('Cliente', sheet),
|
||||
'DROPSTAR · Pedido DTF-7 · Cliente · Item 1/2 · 21/10/2026 · 1,00 m · 3 cópias')
|
||||
single = item([placement(0, 0, 20, 10)], [{**source(20, 10), 'kind': 'sheet', 'copies': 1}], 10)
|
||||
self.assertEqual(line('Cliente', single),
|
||||
'DROPSTAR · Pedido DTF-7 · Cliente · Item 1/2 · 21/10/2026 · 1,00 m')
|
||||
|
||||
def test_jpeg_bytes_are_embedded_unchanged(self):
|
||||
path = self.save(quadrants(), 'a.jpg', quality=90)
|
||||
pdf, _ = self.render(item([placement(0, 0, 20, 10)], [source(20, 10)], 10), [path])
|
||||
|
||||
Reference in New Issue
Block a user