Files
dtf-system/tests/test_sheet_gap.py
Cauê Faleiros 8ba30e057c
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 7m43s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m23s
feat: 8 mm of clear film between the copies and sheets of a ready sheet, billed (Marcus, 2026-11-26)
The Site stacked a ready sheet's copies with nothing between them (#81's were
0,3 mm apart). Now 8 mm separates each copy and each sheet from the next, and
the metres include it, as Marcus confirmed. A new cart without the gap is
refused with the reason; a quote made before is still reviewed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-26 12:53:11 -03:00

44 lines
1.8 KiB
Python

"""8 mm of clear film between the copies of a ready sheet (Marcus, 2026-11-26):
a new cart must carry it; a quote made before is still reviewed.
Run from the repository root: python3 -m unittest tests.test_sheet_gap -v.
"""
import unittest
from uuid import uuid4
from app.core.models import SHEET_GAP_CHANGED, Item, check_sheet_gaps
def sheet(copies=3, gap=0.8, mode='file'):
upload = str(uuid4())
width = 27 if mode == 'uvfile' else 57
length = 20
placements = [{'source_index': 0, 'copy_index': i, 'x_cm': 0, 'y_cm': round(i * (length + gap), 4),
'width_cm': width, 'length_cm': length, 'rotation_degrees': 0, 'mirrored': False}
for i in range(copies)]
height = round(copies * length + (copies - 1) * gap, 4)
return Item.model_validate({
'mode': mode, 'metres': str(height / 100), 'grade': 100, 'uploads': [upload],
'quality_status': 'ok', 'quality_acknowledged': False,
'production': {'version': 3, 'film_width_cm': width, 'height_cm': height,
'sources': [{'upload_id': upload, 'kind': 'sheet', 'width_cm': width,
'length_cm': length, 'copies': copies, 'measurement': 'file'}],
'placements': placements}})
class SheetGapTests(unittest.TestCase):
def test_copies_8_mm_apart_pass(self):
check_sheet_gaps([sheet()])
check_sheet_gaps([sheet(copies=1, gap=0)])
check_sheet_gaps([sheet(mode='uvfile')])
def test_copies_without_the_gap_are_refused_with_the_reason(self):
for gap in (0, 0.03, 0.5):
with self.assertRaises(ValueError) as caught:
check_sheet_gaps([sheet(gap=gap)])
self.assertEqual(str(caught.exception), SHEET_GAP_CHANGED)
if __name__ == '__main__':
unittest.main()