fix: a transfer asks which part the new machine resumes from and names the old machine's .prt to delete (Marcus, 2026-12-01)

The hot folder takes a PNG in about 10 s and the Hoson queues it, so the
last part taken is not the one being ripped. The dialog lists the parts
(already taken or still in the folder) and asks where to resume once any
was taken; the new round starts there, and the parts from there on that
the old machine took are named as Hoson .prt files to delete, in the
toast, the card and the history. The film card no longer claims which part
prints: '2/3 partes com a máquina'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-01 09:39:58 -03:00
parent ea05ba6a31
commit 41e905555b
7 changed files with 111 additions and 38 deletions

View File

@@ -1,5 +1,7 @@
"""An order in Imprimindo changes machine: the new one resumes from the part
the old was ripping, with the reason kept for the Revisor (Rodada 5, D4)."""
"""An order in Imprimindo changes machine: Gestão says which part the new one
resumes from, the reason stays for the Revisor, and the old machine's .prt
files from that part on are named for the operator to delete (Rodada 5, D4;
Marcus, 2026-12-01)."""
from uuid import uuid4
from app.core import db
@@ -39,10 +41,18 @@ def run():
# It only goes to another machine.
answer = client.call(path, {'machine_id': machine, 'reason': 'quebrou'}, operator=True, expected=409)
assert answer['detail'] == 'O pedido já está nessa máquina.', answer
# With the reason, the old machine unloads what was not taken and the
# new round resumes from part 2, renumbered.
assert client.call(path, {'machine_id': other, 'reason': ' quebrou a cabeça '},
operator=True) == {'ok': True}
# The old machine took parts 1 and 2: the part to resume from is asked,
# and it must be one of the order's.
answer = client.call(path, {'machine_id': other, 'reason': 'quebrou'}, operator=True, expected=422)
assert answer['detail'] == 'Escolha de qual parte a nova máquina recomeça.', answer
answer = client.call(path, {'machine_id': other, 'reason': 'quebrou', 'resume_from': 9},
operator=True, expected=422)
assert answer['detail'] == 'Essa parte não existe neste pedido.', answer
# Part 1 was printed, part 2 was waiting in the Hoson queue: the new
# round resumes from part 2, renumbered, and the old machine's part 2
# .prt is to be deleted; parts 3 and 4 leave its folder.
assert client.call(path, {'machine_id': other, 'reason': ' quebrou a cabeça ', 'resume_from': 2},
operator=True) == {'ok': True, 'delete_prt': ['parte 2.prt']}
with db.connect() as c:
parts = c.execute('''SELECT round,seq,state,name FROM dtf_local.hot_parts
WHERE order_id=%s ORDER BY round,seq''', (order,)).fetchall()
@@ -57,9 +67,13 @@ def run():
assert str(moved['machine_id']) == other and moved['machine_chosen'], moved
row = c.execute('SELECT * FROM dtf_local.machine_transfers WHERE order_id=%s', (order,)).fetchone()
assert row['resumed_from'] == 2 and row['reason'] == 'quebrou a cabeça', row
assert row['delete_prt'] == ['parte 2.prt'], row
assert (row['from_name'], row['to_name']) == (f'Transfere A {tag}', f'Transfere B {tag}'), row
mine = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == str(order))
assert mine['transfers'][0]['resumed_from'] == 2, mine.get('transfers')
assert mine['transfers'][0]['delete_prt'] == ['parte 2.prt'], mine.get('transfers')
# The board lists the new round's parts for the next transfer's dialog.
assert [p['seq'] for p in mine['hot_parts']] == [1, 2, 3], mine.get('hot_parts')
# Only Gestão and the administrators move a card between machines.
op = signed_in(email)
op.call(path, {'machine_id': machine, 'reason': 'outra tentativa'}, expected=403)
@@ -68,8 +82,8 @@ def run():
c.execute("UPDATE dtf_local.orders SET state='tra' WHERE id=%s", (order,))
answer = client.call(path, {'machine_id': machine, 'reason': 'fora de hora'}, operator=True, expected=409)
assert answer['detail'] == 'Só um pedido em Imprimindo muda de máquina por aqui.', answer
print('PASS: an order in Imprimindo transfers machine with its reason, '
'the old machine unloads what was not taken and the new resumes from part 2')
print('PASS: an order in Imprimindo transfers machine with its reason and the part to resume from, '
'the old machine unloads what was not taken and its .prt to delete is named')
finally:
if order is not None:
with db.connect() as c: