Files
dtf-system/tests/test_reprint.py
Cauê Faleiros b64947eb76 fix: a proof sheet counts its real length in the machine's metres, in metres, not 15 m
PROOF_SHEET_CM (15) was added to a total in metres, so every proof counted
15 m of film: one proof was enough for the 10 m cleaning alert, and Números
overstated production. A proof now counts the film it took, the finest
stroke's window and the colour samples with the clear film between them (up
to 30 cm, Marcus, 2026-11-26), read from its print file; 15 cm for a sheet
made before the samples. One function serves the machine log and Números.
The Kanban's proof rule says 30 cm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 15:03:36 -03:00

52 lines
2.3 KiB
Python

"""Reprinting some items (Marcus, 2026-11-26, #105): back in the queue after a
print, only the items whose final changed go to the machine again.
Run from the repository root: python3 -m unittest tests.test_reprint -v.
"""
import unittest
from decimal import Decimal
from app.hotfolder import reprint_default
from app.machine_log import film_metres
class ReprintTests(unittest.TestCase):
def test_only_the_item_with_a_new_final_goes_again(self):
finals = [(0, 'a'), (1, 'b-new'), (2, 'c')]
self.assertEqual(reprint_default(finals, {'a', 'b-old', 'c'}, 3), [1])
def test_never_printed_or_nothing_new_or_all_new_is_every_item(self):
finals = [(0, 'a'), (1, 'b')]
self.assertIsNone(reprint_default(finals, None, 2)) # never printed
self.assertIsNone(reprint_default(finals, {'a', 'b'}, 2)) # printed again as it was
self.assertIsNone(reprint_default(finals, {'x', 'y'}, 2)) # every file new
def test_a_film_in_parts_goes_again_when_one_part_is_new(self):
finals = [(0, 'p1'), (0, 'p2-new'), (1, 'q'), (2, 'r')]
self.assertEqual(reprint_default(finals, {'p1', 'p2', 'q', 'r'}, 3), [0])
def test_the_machine_counts_only_the_items_printed_again(self):
snapshot = {'items': [{'billed_metres': '2.0'}, {'billed_metres': '3.5'}]}
self.assertEqual(film_metres(snapshot), Decimal('5.5'))
self.assertEqual(film_metres(snapshot, [1]), Decimal('3.5'))
class ProofFilmTests(unittest.TestCase):
# A proof sheet is centimetres of film, counted in metres: it once counted
# 15 m per proof, enough for the machine's 10 m cleaning alert.
proof = {'proof_of': 81, 'items': [{'billed_metres': '0'}, {'billed_metres': '0'}]}
def test_a_proof_with_colour_samples_counts_its_real_length(self):
# Marcus, 2026-11-26: the finest stroke's 15 cm and two 5 cm samples,
# 1 cm of clear film between them: 27 cm.
windows = {'0': [['10', '25'], ['40', '45'], ['80', '85']]}
self.assertEqual(film_metres(self.proof, [0], windows), Decimal('0.27'))
def test_a_proof_made_before_the_samples_counts_15_cm(self):
self.assertEqual(film_metres(self.proof), Decimal('0.30'))
self.assertEqual(film_metres(self.proof, None, {'1': [['0', '15']]}), Decimal('0.30'))
if __name__ == '__main__':
unittest.main()