Files
dtf-system/tests/test_proof_cut.py
Cauê Faleiros 392e7da85b fix: the proof crops the finest stroke and closes the contact wait (0.1)
The browser records where the thinnest stroke sits in the assembled film;
the proof takes a 15 cm window around it instead of always the top. A free
proof no longer fails the layout's billed-metres check, and answering the
proof card clears "Aguardando contato" and ends its timer.
2026-11-06 11:02:39 -03:00

27 lines
1.0 KiB
Python

"""The proof window: 15 cm around the finest stroke, never outside the film."""
import unittest
from decimal import Decimal
from app.printpng import proof_cut
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)])
if __name__ == '__main__':
unittest.main()