feat: two cards at most in Imprimindo per machine, one printing and one ripping (Dropstar's third round, item 11)
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 4m14s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m5s

A third pull onto the same machine is refused with "máquina5 já tem 2 em
Imprimindo", and so is changing a printing order to a full machine. On
the board, the first order to enter Imprimindo on its machine is labelled
Imprimindo and the next Ripando; the column shows each machine's count,
as "máquina5 · 2/2".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-29 16:19:04 -03:00
parent 757008566c
commit 9c44cdf2a1
5 changed files with 108 additions and 4 deletions

View File

@@ -311,6 +311,50 @@ def run():
assert (shared['orders'], shared['metres'], shared['printing_hours'], shared['metres_per_hour']) == \
(2, 1.5, 0.5, 3.0), shared
# Two at most in Imprimindo per machine (Dropstar, 2026-10-29): the first
# to come in is printing, the second ripping; a third waits for a place.
cap = admin.call('/operator/machines', {'name': f'Cap {tag}', 'products': ['textil']})['id']
machines.append(cap)
with db.connect() as c:
pulled = [order_fixture(c, owner, 'file') for _ in range(4)]
made.extend(pulled)
for _, oid in pulled:
upload = uuid4()
c.execute('''INSERT INTO dtf_local.uploads(id,owner,name,size,object_key,multipart_id,complete,
expires_at,scan_state) VALUES(%s,%s,'final.pdf',1,%s,'m',true,now()+interval '20 days','clean')''',
(upload, owner, f'test/{upload}'))
c.execute('''INSERT INTO dtf_local.order_files(id,order_id,upload_id,item_index,kind,note,created_by)
VALUES(%s,%s,%s,0,'final','ok','t')''', (uuid4(), oid, upload))
c.execute("UPDATE dtf_local.orders SET state='tra', machine_id=%s, machine_chosen=true WHERE id=%s",
(cap, oid))
first, second_in, third, elsewhere = (str(oid) for _, oid in pulled)
pull = lambda oid, version=0: su.call(f'/operator/orders/{oid}/move', {'state': 'imp', 'version': version,
'reason': ''}, operator=True)
running = pull(first)
pull(second_in)
refused = su.call(f'/operator/orders/{third}/move', {'state': 'imp', 'version': 0, 'reason': ''},
operator=True, expected=409)
assert refused['detail'] == f'Cap {tag} já tem 2 em Imprimindo.', refused
loaded = su.call('/operator/board', operator=True)
board = {o['id']: o for o in loaded['orders']}
assert (board[first]['printing'], board[second_in]['printing'], board[third]['printing']) == \
('imprimindo', 'ripando', None)
assert loaded['printing_cap'] == 2
assert next(m for m in loaded['machines'] if m['id'] == cap)['states'] == {'imp': 2, 'tra': 2}
# Nor does an order already printing elsewhere come onto the full machine.
with db.connect() as c:
c.execute("UPDATE dtf_local.orders SET state='imp', machine_id=%s WHERE id=%s", (textil, elsewhere))
su.call(f'/operator/orders/{elsewhere}/machine', {'machine_id': cap}, operator=True, expected=409)
assert next(o for o in su.call('/operator/board', operator=True)['orders']
if o['id'] == elsewhere)['machine']['id'] == textil
# The one printing goes to Revisão: the one ripping is now printing, and a place opens.
su.call(f'/operator/orders/{first}/move', {'state': 'rev', 'version': running['version'], 'reason': ''},
operator=True)
pull(third)
board = {o['id']: o for o in su.call('/operator/board', operator=True)['orders']}
assert (board[first]['printing'], board[second_in]['printing'], board[third]['printing']) == \
(None, 'imprimindo', 'ripando')
# Switched off, a machine gives its automatic orders to another one.
with db.connect() as c:
c.execute('UPDATE dtf_local.orders SET machine_id=%s, machine_chosen=false WHERE id=%s', (textil2, second))
@@ -386,9 +430,11 @@ def run():
for _, oid in made:
c.execute('DELETE FROM dtf_local.movements WHERE order_id=%s', (oid,))
c.execute('DELETE FROM dtf_local.print_files WHERE order_id=%s', (oid,))
c.execute('DELETE FROM dtf_local.order_files WHERE order_id=%s', (oid,))
c.execute('DELETE FROM dtf_local.outbox WHERE event_key LIKE %s', (f'{oid}:%',))
c.execute('DELETE FROM dtf_local.orders WHERE id=%s', (oid,))
c.execute('DELETE FROM dtf_local.quotes WHERE id=ANY(%s)', ([q for q, _ in made],))
c.execute('DELETE FROM dtf_local.uploads WHERE owner=%s', (owner,))
c.execute('DELETE FROM dtf_local.operators WHERE email LIKE %s', (f'%-{tag}@example.test',))
c.execute('DELETE FROM dtf_local.machines WHERE id=ANY(%s::uuid[])', (machines,))