fix: the choice of items to reprint ends with the print, a new final or "Gerar de novo", so a later correction always goes to the machine (#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 7m54s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m27s
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 7m54s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m27s
Kept until Finalizado, an old choice would leave out an item corrected after it (an order back from Revisão, or a second correction). It is now cleared when the pass to Revisão records it, when a final changes and when the files are generated again; the next entry to the queue works it out anew. An integration test follows the whole reprint: first print, one item corrected, the queue, the hot folder with that item only, Revisão. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -435,6 +435,68 @@ def run():
|
||||
assert (moved['operator'], moved['reason']) == ('Prumo', 'Prova OK'), moved
|
||||
print('PASS: a file finished after Prova OK becomes the final and queues the order')
|
||||
|
||||
# Reprinting some items (Marcus, 2026-11-26, #105): an order the machine
|
||||
# already printed, back in the queue after one item's final changed, sends
|
||||
# only that item; the pass to Revisão keeps it for the machine's metres and
|
||||
# the choice is then over.
|
||||
first_art = upload_bytes(client, artwork(), name='LOCAL-REPRINT-A.png')
|
||||
second_art = upload_bytes(client, artwork(), name='LOCAL-REPRINT-B.png')
|
||||
two = [loose_item(first_art), loose_item(second_art)]
|
||||
quote = client.call('/quotes', {'request_key': str(uuid4()), 'customer': CUSTOMER,
|
||||
'items': two, 'freight': {'service': 'pickup'}})
|
||||
approval(client, quote, two)
|
||||
reprint = client.call('/orders/dev-paid', {'quote_id': quote['id']})
|
||||
rid = reprint['id']
|
||||
deadline = time.monotonic() + 120
|
||||
while True:
|
||||
board_order = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == rid)
|
||||
made = {r['item_index']: r for r in board_order['print_files']}
|
||||
if len(made) == 2 and all(r['status'] == 'ready' for r in made.values()):
|
||||
break
|
||||
assert time.monotonic() < deadline, made
|
||||
time.sleep(1)
|
||||
generated = {i: str(made[i]['upload_id']) for i in (0, 1)}
|
||||
v = client.call('/operator/orders/' + rid + '/final-files',
|
||||
{'version': board_order['version'], 'note': 'ok',
|
||||
'files': [{'item_index': i, 'upload_id': generated[i]} for i in (0, 1)]}, operator=True)['version']
|
||||
with db.connect() as c:
|
||||
# The machine took both files on a first print.
|
||||
for i in (0, 1):
|
||||
c.execute('''INSERT INTO dtf_local.hot_parts(order_id,round,seq,item_index,upload_id,name,state)
|
||||
VALUES(%s,1,%s,%s,%s,%s,'consumed')''', (rid, i + 1, i, generated[i], f'item-{i + 1}.png'))
|
||||
# Item 2 is corrected; item 1 keeps its file ("Manter o arquivo atual").
|
||||
corrected = upload_bytes(client, artwork(), name='LOCAL-REPRINT-B2.png', order_id=rid)
|
||||
v = client.call('/operator/orders/' + rid + '/final-files',
|
||||
{'version': v, 'note': 'arte corrigida',
|
||||
'files': [{'item_index': 0, 'upload_id': generated[0]},
|
||||
{'item_index': 1, 'upload_id': corrected}]}, operator=True)['version']
|
||||
board_order = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == rid)
|
||||
assert board_order['printed_before'] and board_order['print_suggested'] == [1], board_order.get('print_suggested')
|
||||
client.call('/operator/orders/' + rid + '/move', {'state': 'tra', 'version': v}, operator=True)
|
||||
from app import hotfolder
|
||||
with db.connect() as c:
|
||||
assert c.execute('SELECT print_items FROM dtf_local.orders WHERE id=%s', (rid,)).fetchone()['print_items'] == [1]
|
||||
hotfolder.start(c, rid)
|
||||
queued = c.execute('SELECT item_index,upload_id FROM dtf_local.hot_parts WHERE order_id=%s AND round=2',
|
||||
(rid,)).fetchall()
|
||||
assert [(q['item_index'], str(q['upload_id'])) for q in queued] == [(1, corrected)], queued
|
||||
c.execute("UPDATE dtf_local.hot_parts SET state='consumed' WHERE order_id=%s AND round=2", (rid,))
|
||||
c.execute("UPDATE dtf_local.orders SET state='imp' WHERE id=%s", (rid,))
|
||||
v = c.execute('SELECT version FROM dtf_local.orders WHERE id=%s', (rid,)).fetchone()['version']
|
||||
client.call('/operator/orders/' + rid + '/move', {'state': 'rev', 'version': v}, operator=True)
|
||||
with db.connect() as c:
|
||||
moved = c.execute('''SELECT items FROM dtf_local.movements WHERE order_id=%s AND to_state='rev'
|
||||
ORDER BY id DESC LIMIT 1''', (rid,)).fetchone()
|
||||
left = c.execute('SELECT print_items FROM dtf_local.orders WHERE id=%s', (rid,)).fetchone()['print_items']
|
||||
assert moved['items'] == [1] and left is None, (moved, left)
|
||||
# Chosen by hand: every item means all, as on a first print.
|
||||
with db.connect() as c:
|
||||
c.execute("UPDATE dtf_local.orders SET state='rec' WHERE id=%s", (rid,))
|
||||
assert client.call('/operator/orders/' + rid + '/print-items', {'items': [0, 1]}, operator=True)['print_items'] is None
|
||||
assert client.call('/operator/orders/' + rid + '/print-items', {'items': [0]}, operator=True)['print_items'] == [0]
|
||||
client.call('/operator/orders/' + rid + '/print-items', {'items': [5]}, operator=True, expected=422)
|
||||
print('PASS: a reprint sends only the item whose final changed, and the choice ends with the print')
|
||||
|
||||
# A CDR cannot be decoded by the worker. The designer prepares the full
|
||||
# parent PNG, then the worker automatically cuts the child's proof from it.
|
||||
manual_source = upload_bytes(client, b'LOCAL PRINT TEST - NOT AN IMAGE', name='MANUAL-PROOF.cdr')
|
||||
|
||||
Reference in New Issue
Block a user