feat: a reprint sends only the items chosen to the machine (Marcus, 2026-11-26, #105)
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 7m55s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m34s

An order the machine already printed, back in Arte conferida, sends again
only the items whose final changed since the machine took them; the panel's
"Vai para a máquina" shows and changes the choice, and the card says
"Reimpressão". The order stays one card. The pass to Revisão keeps the
items printed, so the machine's metres count only those.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-27 10:00:54 -03:00
parent 47f3251d3e
commit b8496b858f
11 changed files with 165 additions and 14 deletions

View File

@@ -265,6 +265,8 @@ def run():
assert not client.call(f'/operator/queue/hot/{part}', {'state': 'consumed'}, operator=True)['ok']
board = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == oid)
assert board['hot'] == {'parts': 1, 'taken': 1, 'waiting': 0}, board['hot']
# Which items go again is chosen before Imprimindo, not while printing (#105).
client.call('/operator/orders/' + oid + '/print-items', {'items': [0]}, operator=True, expected=409)
print('PASS: the printing file goes once into its machine\'s hot folder for its class')
finally:
client.call('/operator/machines/' + machine, {'name': f'Hot {tag}', 'products': ['textil'], 'active': False},

35
tests/test_reprint.py Normal file
View File

@@ -0,0 +1,35 @@
"""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_stats import _film
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(snapshot), Decimal('5.5'))
self.assertEqual(_film(snapshot, [1]), Decimal('3.5'))
if __name__ == '__main__':
unittest.main()