Some checks failed
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled
The layout sees a ready sheet as one piece, so a part was cut at its length, through the artwork. Where no gap between pieces is near the limit, the film is read there: the cut falls in the middle of the nearest clear band of 3 mm, else of the widest clear band (#83's packed sheets have 2 mm between rows), else on the row with the least ink. A part is never shorter than half the limit, and the render limit allows one part more. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
59 lines
2.5 KiB
Python
59 lines
2.5 KiB
Python
"""The proof window: 15 cm around the finest stroke, never outside the film."""
|
|
import unittest
|
|
from decimal import Decimal
|
|
|
|
from app.printjobs import proof_part
|
|
from app.printpng import proof_cut
|
|
|
|
|
|
class ProofPartTests(unittest.TestCase):
|
|
def test_one_part_keeps_the_same_fraction(self):
|
|
self.assertEqual(proof_part([100], 100, 0.5), (0, 0.5))
|
|
self.assertEqual(proof_part([30], 30, 0.8), (0, 0.8))
|
|
|
|
def test_the_part_holding_the_finest_stroke_is_chosen(self):
|
|
self.assertEqual(proof_part([1000, 1000, 1000], 3000, 0.1), (0, 0.3))
|
|
self.assertEqual(proof_part([1000, 1000, 1000], 3000, 0.5), (1, 0.5))
|
|
self.assertEqual(proof_part([1000, 1000, 1000], 3000, 0.75), (2, 0.25))
|
|
|
|
def test_the_fraction_is_recalculated_inside_the_chosen_part(self):
|
|
self.assertEqual(proof_part([1500, 1500], 3000, 0.75), (1, 0.5))
|
|
self.assertEqual(proof_part([1500, 1500], 3000, 1), (1, 1))
|
|
|
|
|
|
class ProofCutTests(unittest.TestCase):
|
|
def test_centres_the_window_on_the_finest_stroke(self):
|
|
self.assertEqual(proof_cut(100, 15, 0.5), [Decimal('42.5'), Decimal('57.5')])
|
|
self.assertEqual(proof_cut(100, 15, 0.8), [Decimal('72.5'), Decimal('87.5')])
|
|
|
|
def test_clamps_at_both_ends(self):
|
|
self.assertEqual(proof_cut(100, 15, 0), [Decimal(0), Decimal(15)])
|
|
self.assertEqual(proof_cut(100, 15, 1), [Decimal(85), Decimal(100)])
|
|
|
|
def test_a_short_film_is_the_whole_proof(self):
|
|
self.assertEqual(proof_cut(10, 15, 0.5), [Decimal(0), Decimal(10)])
|
|
self.assertEqual(proof_cut(10, 15, None), [Decimal(0), Decimal(10)])
|
|
|
|
def test_without_a_measure_the_old_top_window_remains(self):
|
|
self.assertEqual(proof_cut(100, 15, None), [Decimal(0), Decimal(15)])
|
|
|
|
|
|
class RenderLimitTests(unittest.TestCase):
|
|
"""Order #20 (2026-11-12): a 23.6 m film ran past one 15 min limit."""
|
|
|
|
def test_the_limit_grows_with_the_parts(self):
|
|
from app.printjobs import RENDER_SECONDS, render_seconds
|
|
|
|
def film(height):
|
|
return {'production': {'height_cm': height, 'placements': [
|
|
{'y_cm': 0, 'length_cm': height, 'source_index': 0}]}}
|
|
self.assertEqual(render_seconds(film(800)), RENDER_SECONDS)
|
|
# A film in parts gets one part more: a cut moved to a clear band (#136).
|
|
self.assertEqual(render_seconds(film(2359.2)), 3 * RENDER_SECONDS)
|
|
self.assertEqual(render_seconds(film(4600)), 5 * RENDER_SECONDS)
|
|
self.assertEqual(render_seconds({'mode': 'file'}), RENDER_SECONDS)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|