Files
dtf-system/tests/test_layout_rules.py
Cauê Faleiros ebe8b29db2
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m27s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m0s
feat: UV is 27 cm wide (Dropstar, 2026-10-28)
It was 28,5 cm. The Site's UV products, ready-sheet check, layout and size
shortcuts, the server's film-width check, the print file and the Tiny item
names follow; two pieces of up to 13,2 cm share a UV row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 11:08:07 -03:00

42 lines
1.8 KiB
Python

"""What an order's layout may carry: the layout version, and no mirrored textile."""
import unittest
from uuid import uuid4
from pydantic import ValidationError
from app.core.models import Item
def item(mode='avulsa', mirrored=False, version=3):
upload = uuid4()
film = 27 if mode in ('uv', 'uvfile') else 57
return {'mode': mode, 'metres': '0.21', 'grade': 100, 'uploads': [str(upload)],
'quality_status': 'ok', 'quality_acknowledged': False,
'production': {'version': version, 'film_width_cm': film, 'height_cm': 21,
'sources': [{'upload_id': str(upload), 'kind': 'artwork', 'width_cm': 10,
'length_cm': 20, 'copies': 1, 'rotation_degrees': 0,
'mirrored': mirrored, 'measurement': 'file'}],
'placements': [{'source_index': 0, 'copy_index': 0, 'x_cm': 0.5, 'y_cm': 0.5,
'width_cm': 10, 'length_cm': 20, 'rotation_degrees': 0,
'mirrored': mirrored}]}}
class LayoutRulesTest(unittest.TestCase):
def test_a_textile_transfer_is_never_mirrored(self):
# Pressed face down, a mirrored transfer prints backwards (Dropstar, 2026-10-21).
with self.assertRaises(ValidationError):
Item.model_validate(item('avulsa', mirrored=True))
Item.model_validate(item('avulsa'))
# UV keeps the choice until Dropstar decides.
Item.model_validate(item('uv', mirrored=True))
def test_layout_versions(self):
Item.model_validate(item(version=3))
Item.model_validate(item(version=2))
with self.assertRaises(ValidationError):
Item.model_validate(item(version=1))
if __name__ == '__main__':
unittest.main()