fix: a reprint keeps an all-items choice, an undone pass to Revisão prints nothing again, and Prova OK tells Tiny (#105)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m26s

- Every item ticked was saved as NULL, which also means "not chosen", so the
  pass to the queue replaced it with the suggestion and only the changed
  item went to the machine; the panel showed the suggestion again. The
  choice is now the whole list.
- Undoing a pass to Revisão (back to Imprimindo) started a new round with
  every file, so FlexiPRINT printed the order again. It now writes back only
  what Flexi had not taken, and the reprint choice of that pass returns. A
  pass undone this way no longer counts its film twice in the machine's
  metres (machine log and Números).
- An order entering the queue by Prova OK never sent Tiny's "Preparando
  envio". The stage's Tiny event is now one function, used by the move and
  by the Prova OK.

Integration test follows the real moves: suggestion, all items kept, pull
onto a machine, two undone passes to Revisão, metres counted once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-27 14:48:34 -03:00
parent 194797c412
commit f35a347a28
10 changed files with 166 additions and 49 deletions

View File

@@ -23,7 +23,7 @@ class Database:
"""Just the reads and writes approve_parent makes."""
def __init__(self, parts, active):
self.parts, self.active, self.inserted = parts, active, []
self.parts, self.active, self.inserted, self.outbox = parts, active, [], []
def execute(self, sql, params=()):
text = ' '.join(sql.split())
@@ -37,10 +37,17 @@ class Database:
return Rows([{'upload_id': u} for u in self.active])
if text.startswith('INSERT INTO dtf_local.order_files'):
self.inserted.append(params[2])
if text.startswith('UPDATE dtf_local.orders SET state'):
return Rows([{'version': 2}])
if 'FROM dtf_local.outbox' in text:
return Rows([])
if text.startswith('INSERT INTO dtf_local.outbox'):
self.outbox.append((params[0], params[2].obj['event']))
return Rows([{'ok': 1}])
ORDER = {'id': 'o', 'state': 'rec', 'cancelled_at': None, 'snapshot': {'items': [{'mode': 'file'}]}}
ORDER = {'id': 'o', 'number': 131, 'state': 'rec', 'cancelled_at': None, 'payment': {'provider': 'mercadopago'},
'snapshot': {'items': [{'mode': 'file'}]}}
class ProofPartsTests(unittest.TestCase):
@@ -54,6 +61,13 @@ class ProofPartsTests(unittest.TestCase):
approve_parent(db, ORDER, 'Prumo')
self.assertEqual(db.inserted, ['p2'])
def test_entering_the_queue_by_prova_ok_tells_tiny(self):
# Tiny's "Preparando envio", as for a card moved by hand: orders with
# a proof skipped it.
db = Database(['p1'], set())
self.assertTrue(approve_parent(db, ORDER, 'Prumo'))
self.assertEqual(db.outbox, [('o:production_started:tiny', 'production_started')])
def test_a_final_someone_prepared_stays(self):
db = Database(['p1', 'p2'], {'treated'})
approve_parent(db, ORDER, 'Prumo')