feat: a PNG that records 200 DPI or more offers its own size, Manter, and the Prumo says if it was kept (Rodada 5, A1)
The Site reads the pHYs chunk of a loose art; at 200 DPI or more the size in the file is the default width and a Manter button sits before the table sizes (also when the art is turned 90 degrees). The source carries saved_width_cm and saved_dpi, used only by the Prumo report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,30 @@ class PrumoReportTests(unittest.TestCase):
|
||||
self.assertIn('Prumo levou 41 s', text)
|
||||
self.assertNotIn('Prumo levou 341 s', text)
|
||||
|
||||
def test_saved_png_size_says_whether_the_customer_kept_it(self):
|
||||
order = self.order()
|
||||
item = order['snapshot']['items'][0]
|
||||
item['production']['sources'] = [
|
||||
{'width_cm': '28.0', 'length_cm': '35.2',
|
||||
'saved_width_cm': '28.0', 'saved_dpi': 300},
|
||||
{'width_cm': '20', 'length_cm': '25',
|
||||
'saved_width_cm': '15', 'saved_dpi': 240},
|
||||
]
|
||||
text = '\n'.join(report(order, {'u1': {'name': 'arte.pdf'}}))
|
||||
self.assertIn('Arte 1: tamanho lido do arquivo 28,0 × 35,2 cm (300 DPI), mantido', text)
|
||||
self.assertIn('Arte 2: tamanho lido do arquivo 15,0 × 18,8 cm (240 DPI), '
|
||||
'alterado pelo cliente para 20,0 cm', text)
|
||||
# Turned 90°: the art's own width is the length along the film.
|
||||
item['production']['sources'] = [
|
||||
{'width_cm': '35.2', 'length_cm': '28.0', 'rotation_degrees': 90,
|
||||
'saved_width_cm': '28.0', 'saved_dpi': 300}]
|
||||
text = '\n'.join(report(order, {'u1': {'name': 'arte.pdf'}}))
|
||||
self.assertIn('Arte 1: tamanho lido do arquivo 28,0 × 35,2 cm (300 DPI), mantido', text)
|
||||
|
||||
def test_without_a_saved_png_size_no_line_is_added(self):
|
||||
text = '\n'.join(report(self.order(), {'u1': {'name': 'arte.pdf'}}))
|
||||
self.assertNotIn('tamanho lido do arquivo', text)
|
||||
|
||||
def test_without_a_claim_time_the_generation_line_is_hidden(self):
|
||||
order = self.order()
|
||||
del order['print_files'][0]['claimed_at']
|
||||
|
||||
26
tests/test_saved_size.py
Normal file
26
tests/test_saved_size.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""The PNG's own size on an artwork source (item A1, round 5)."""
|
||||
import unittest
|
||||
from uuid import uuid4
|
||||
|
||||
try:
|
||||
from pydantic import ValidationError
|
||||
from app.core.models import ProductionSource
|
||||
except ImportError:
|
||||
# The validate job runs this file on the host, without the runtime image's
|
||||
# dependencies; the runtime suites exercise the model there.
|
||||
ProductionSource = ValidationError = None
|
||||
|
||||
|
||||
class ProductionSourceSavedSizeTests(unittest.TestCase):
|
||||
@unittest.skipUnless(ProductionSource, 'pydantic is only in the runtime image')
|
||||
def test_saved_size_is_optional_and_saved_dpi_must_be_positive(self):
|
||||
base = {'upload_id': str(uuid4()), 'kind': 'artwork', 'width_cm': '28.0',
|
||||
'length_cm': '35.2', 'copies': 1, 'measurement': 'file'}
|
||||
ProductionSource.model_validate(base)
|
||||
ProductionSource.model_validate({**base, 'saved_width_cm': '28.0', 'saved_dpi': 300})
|
||||
with self.assertRaises(ValidationError):
|
||||
ProductionSource.model_validate({**base, 'saved_width_cm': '28.0', 'saved_dpi': 0})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user