test: the two ready-sheet fixtures record no DPI, as the sheets they stand for (CI run 410)

upload_limits_test sent a 60 px PNG recorded at 300 DPI (0,5 cm) as a ready
sheet and site_admin_test a 2400 px one (20,3 cm) described as a 57 cm sheet;
the 57 cm rule (7111995) refused both, as it should. Without pHYs they are
stretched to the film, which is what both tests are about. All 32
integration suites pass on the local stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-01 18:05:46 -03:00
parent 711199558f
commit 961a72c0eb
2 changed files with 19 additions and 3 deletions

View File

@@ -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()

View File

@@ -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'}}