Files
dtf-system/tests/test_saved_size.py
Cauê Faleiros 7fc091a1bd 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>
2026-11-30 11:11:21 -03:00

27 lines
1.1 KiB
Python

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