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