diff --git a/tests/site_admin_test.py b/tests/site_admin_test.py index 8d58ade..f8371d6 100644 --- a/tests/site_admin_test.py +++ b/tests/site_admin_test.py @@ -25,11 +25,13 @@ REDESIGN = 'redesenho' def premium_sheet(): - """A 57 cm wide sheet above 96 DPI at that width, so the server accepts it.""" + """A 57 cm wide sheet above 96 DPI at that width, so the server accepts it. + No DPI recorded: at 300 DPI its 2400 px would be 20,3 cm and the 57 cm + rule would refuse it (output/revisao/contrato-largura-folha.md).""" image = Image.new('RGBA', (2400, 800), (0, 0, 0, 0)) ImageDraw.Draw(image).rectangle([40, 40, 2360, 760], fill=(220, 30, 60, 255)) out = io.BytesIO() - image.save(out, 'PNG', dpi=(300, 300)) + image.save(out, 'PNG') return out.getvalue() diff --git a/tests/upload_limits_test.py b/tests/upload_limits_test.py index 55f25b8..4738ef4 100644 --- a/tests/upload_limits_test.py +++ b/tests/upload_limits_test.py @@ -4,6 +4,7 @@ takes up to 200 files per item (Sentry DTF-WEB-1). Run against the local stack: python -m tests.upload_limits_test """ +import io import json import os import secrets @@ -21,6 +22,19 @@ from app.core.auth import rate_limit from tests.smoke_test import BASE, Client, upload_bytes, with_host PNG = (Path(__file__).resolve().parent / 'fixtures' / 'final-300.png').read_bytes() + + +def without_dpi(data): + """The fixture records 300 DPI: as a ready sheet it would be 0,5 cm wide and + refused (output/revisao/contrato-largura-folha.md). Without pHYs it is + stretched to the film, which is all the sheet-count limit needs.""" + from PIL import Image + out = io.BytesIO() + Image.open(io.BytesIO(data)).save(out, 'PNG') + return out.getvalue() + + +SHEET_PNG = without_dpi(PNG) TOO_MANY = 'Este item tem mais de 200 arquivos. Divida em dois itens.' @@ -97,7 +111,7 @@ def run(): # Sentry DTF-WEB-1: 66 sheets in one ready-sheet item is quoted and # approved; the old cap of 20 refused it with a generic 422. - uploads = [upload_bytes(client, PNG, name=f'SHEET66-{index}.png') for index in range(66)] + uploads = [upload_bytes(client, SHEET_PNG, name=f'SHEET66-{index}.png') for index in range(66)] body = {'request_key': str(uuid4()), 'customer': {'name': 'Carrinho Grande', 'cnpj': '11222333000181', 'zap': '11999999999', 'mail': 'sheet66@example.test'}, 'items': [item_with(uploads)], 'freight': {'service': 'pickup'}}