test: the suite follows pull-only machines, the proof lock and 200 DPI

The old tests created orders with an automatic machine and moved them
without one. They now choose a machine or pass it to the pull, expect the
proof lock before any move, and use the 200 DPI clean grade.
This commit is contained in:
Cauê Faleiros
2026-11-06 11:02:43 -03:00
parent 392e7da85b
commit 054a642a61
3 changed files with 60 additions and 71 deletions

View File

@@ -210,9 +210,11 @@ def run():
# A cart the Site priced is approved at once and can be paid straight away,
# at the server's own prices; no operator can then change it.
# The server works the grade out from the file: this PNG is 6059 px across
# 57 cm, 270 DPI, which is grade 90.
# 57 cm, 270 DPI, which is grade 100 under the 200 DPI clean threshold.
png=b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR'+(6059).to_bytes(4,'big')+(2000).to_bytes(4,'big')+b'\x08\x06\x00\x00\x00'+b'\x00'*4
graded=upload_bytes(client,png,name='arte-270dpi.png')
low_png=b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR'+(3366).to_bytes(4,'big')+(2000).to_bytes(4,'big')+b'\x08\x06\x00\x00\x00'+b'\x00'*4
low=upload_bytes(client,low_png,name='arte-150dpi.png')
small={**draft,'request_key':str(uuid4()),'items':[item_spec('avulsa','2.75',90,graded)]}
auto=client.call('/quotes',small)
assert auto['status']=='approved'
@@ -258,9 +260,10 @@ def run():
assert client.call('/quotes/'+held['id'])['review_reason']=='Nota não conferida no servidor'
# A better grade than the file supports, or one the server cannot check, waits too:
# the price ignores the grade, but the order shows it.
inflated=client.call('/quotes',{**small,'request_key':str(uuid4()),'items':[item_spec('avulsa','2.75',100,graded)]})
low_item={**item_spec('avulsa','2.75',100,low),'quality_status':'warning','quality_acknowledged':True}
inflated=client.call('/quotes',{**small,'request_key':str(uuid4()),'items':[low_item]})
assert inflated['status']=='pending_review'
assert client.call('/quotes/'+inflated['id'])['review_reason']=='Nota 100 maior que a do arquivo (90)'
assert client.call('/quotes/'+inflated['id'])['review_reason']=='Nota 100 maior que a do arquivo (75)'
unchecked=client.call('/quotes',{**small,'request_key':str(uuid4()),'items':[item_spec('avulsa','2.75',90,uid)]})
assert client.call('/quotes/'+unchecked['id'])['review_reason']=='Nota não conferida no servidor'
print('PASS: priced carts are approved at checkout; large or inconsistent ones wait for review')
@@ -275,9 +278,19 @@ def run():
board=client.call('/operator/board',operator=True)
assert len([o for o in board['orders'] if o['quote_id']==qid])==1
client.call('/operator/orders/'+oid+'/move',{'state':'fin','version':0},operator=True,expected=409)
client.call('/operator/orders/'+oid+'/move',{'state':'cor','version':0},operator=True,expected=422)
version=0
# Above 10 m the proof comes first: the parent cannot move at all until
# Prova OK on its proof card in Revisão (item 0.1).
held=client.call('/operator/orders/'+oid+'/move',{'state':'cor','version':0},operator=True,expected=409)
assert 'Aguardando prova' in held['detail'], held
card=next(o for o in board['orders'] if o['id']==oid)['proof_card']
from app.core import db
with db.connect() as c:
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s",(card['id'],))
client.call('/operator/orders/'+card['id']+'/proof-answer',{'result':'ok'},operator=True)
version=next(o for o in client.call('/operator/board',operator=True)['orders'] if o['id']==oid)['version']
client.call('/operator/orders/'+oid+'/move',{'state':'cor','version':version},operator=True,expected=422)
# Dropstar's flow (2026-10-23): Arte conferida is the queue, Revisão comes before Finalizado.
machine=None
for state in ('cor','rec','tra','imp','rev','fin'):
if state=='tra':
# The queue takes approved final files only.
@@ -285,18 +298,12 @@ def run():
files=[{'item_index':i,'upload_id':upload_bytes(client,final_png_bytes(str(i)),name=f'LOCAL-FINAL-{i}.png',order_id=oid)} for i in range(4)]
result=client.call('/operator/orders/'+oid+'/final-files',{'version':version,'files':files,'note':'Local test manual final-file approval'},operator=True)
version=result['version']
body={'state':state,'version':version,'reason':'Local test correction' if state=='cor' else ''}
if state=='imp':
# Above 10 m the proof comes first (app/proof.py): the order waits
# outside the queue for Prova OK on its proof card in Revisão.
held=client.call('/operator/orders/'+oid+'/move',{'state':'imp','version':version},operator=True,expected=409)
assert 'Aguardando prova' in held['detail'], held
card=next(o for o in client.call('/operator/board',operator=True)['orders'] if o['id']==oid)['proof_card']
from app.core import db
with db.connect() as c:
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s",(card['id'],))
client.call('/operator/orders/'+card['id']+'/proof-answer',{'result':'ok'},operator=True)
version+=1
moved=client.call('/operator/orders/'+oid+'/move',{'state':state,'version':version,'reason':'Local test correction' if state=='cor' else ''},operator=True)
if machine is None:
machine=client.call('/operator/machines',{'name':'Smoke '+uuid4().hex[:6],'products':['textil']},operator=True)['id']
body['machine_id']=machine
moved=client.call('/operator/orders/'+oid+'/move',body,operator=True)
version+=1;assert moved['version']==version
client.call('/operator/orders/'+oid+'/move',{'state':'rec','version':0},operator=True,expected=409)
assert len(client.call('/operator/orders/'+oid+'/history',operator=True))==6