feat: the proof card, machine pull and print file corrections (Dropstar, 05/11)
The proof card owns its final PNG, keeps its parent locked until the seller answers, enters the queue first, and shares one machine with the parent. The board no longer assigns a machine at payment; the puller records it. A stalled print file times out with a card warning and a retry, finished orders sort by completion, and finals are stored as PNG. The original download carries the order number (items 0.1, 0.4 to 0.7 and 0.9).
This commit is contained in:
@@ -205,6 +205,7 @@ try{
|
||||
// Open the order's panel from its card, then click the real transition
|
||||
// buttons there, including the rerender after each move.
|
||||
await kanban.click('[data-tab="board"]');
|
||||
assert.equal(await kanban.eval(`!!document.querySelector('[data-card="${oid}"] .card-open')`),true);
|
||||
await kanban.click(`[data-card="${oid}"]`);
|
||||
await waitFor(()=>kanban.eval(`!!document.querySelector('[data-order="${oid}"] [data-move]')`),'order panel');
|
||||
// Dropstar's flow (2026-10-23): Arte conferida is the queue, Revisão before Finalizado.
|
||||
@@ -233,6 +234,13 @@ try{
|
||||
await kanban.click(`[data-order="${oid}"] [data-move="${state}"]`);
|
||||
await waitFor(()=>kanban.eval(`board.orders.find(o=>o.id==='${oid}').state==='${state}'`),'transition '+state);
|
||||
if(state==='tra'){
|
||||
// The file opens from the card itself, without first expanding the order.
|
||||
await kanban.eval('closePanel()');
|
||||
await kanban.click(`[data-card="${oid}"] .card-open`);
|
||||
await waitFor(()=>kanban.eval(`!!document.querySelector('.viewer[open]')`),'file viewer from the card');
|
||||
assert.equal(await kanban.eval(`$('drawer').hidden`),true);
|
||||
await kanban.click('.viewer .vbtn.pri');
|
||||
await kanban.click(`[data-card="${oid}"]`);
|
||||
// Entering the queue moves its file to Arte conferida, whole and named after the order.
|
||||
const prefix='DTF-'+await kanban.eval(`board.orders.find(o=>o.id==='${oid}').number`)+'-item-1';
|
||||
await waitFor(async()=>(await savedFiles('2. Arte conferida')).some(n=>n.startsWith(prefix)&&!n.endsWith('.baixando')),'final file in Arte conferida',45000);
|
||||
|
||||
54
tests/finished_order_test.py
Normal file
54
tests/finished_order_test.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""Finalizado sorts by completion, including when an older order finishes last.
|
||||
|
||||
Run against the local stack: python3 -m tests.finished_order_test
|
||||
"""
|
||||
from urllib.parse import urlencode
|
||||
from uuid import uuid4
|
||||
|
||||
from psycopg.types.json import Jsonb
|
||||
|
||||
from app.core import db
|
||||
from tests.smoke_test import Client
|
||||
|
||||
|
||||
def run():
|
||||
client = Client()
|
||||
owner = uuid4()
|
||||
older_quote, newer_quote = uuid4(), uuid4()
|
||||
older_order, newer_order = uuid4(), uuid4()
|
||||
snapshot = {'customer': {'mail': 'finished-order@example.test', 'cnpj': '11222333000181'},
|
||||
'items': [{'mode': 'file', 'billed_metres': '1.00'}]}
|
||||
try:
|
||||
with db.connect() as c:
|
||||
for quote_id in (older_quote, newer_quote):
|
||||
c.execute('''INSERT INTO dtf_local.quotes(id,owner,request_key,request_hash,draft)
|
||||
VALUES(%s,%s,%s,'finished-order-test',%s)''',
|
||||
(quote_id, owner, uuid4(), Jsonb(snapshot)))
|
||||
for order_id, quote_id, age in ((older_order, older_quote, 2), (newer_order, newer_quote, 1)):
|
||||
c.execute('''INSERT INTO dtf_local.orders(id,quote_id,owner,snapshot,payment,origin,state,created_at)
|
||||
VALUES(%s,%s,%s,%s,%s,'site','fin',now()-%s*interval '1 day')''',
|
||||
(order_id, quote_id, owner, Jsonb(snapshot), Jsonb({'provider': 'teste'}), age))
|
||||
# The older purchase finishes later; it must be first in Finalizado.
|
||||
for order_id, minutes in ((older_order, 2), (newer_order, 1)):
|
||||
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason,back,created_at)
|
||||
VALUES(%s,'rev','fin','finished-order-test','',false,now()+%s*interval '1 minute')''',
|
||||
(order_id, minutes))
|
||||
board = client.call('/operator/board', operator=True)['orders']
|
||||
finished = [o for o in board if o['state'] == 'fin']
|
||||
ids = [o['id'] for o in finished]
|
||||
assert ids.index(str(older_order)) < ids.index(str(newer_order)), ids
|
||||
page = client.call('/operator/orders/finished?limit=2', operator=True)['orders']
|
||||
assert [o['id'] for o in page] == [str(older_order), str(newer_order)], page
|
||||
cursor = urlencode({'before_finished_at': page[0]['finished_at'], 'before_id': page[0]['id']})
|
||||
next_page = client.call('/operator/orders/finished?' + cursor + '&limit=1', operator=True)['orders']
|
||||
assert [o['id'] for o in next_page] == [str(newer_order)], next_page
|
||||
print('PASS: Finalizado and its cursor use completion time, not order creation time')
|
||||
finally:
|
||||
with db.connect() as c:
|
||||
c.execute('DELETE FROM dtf_local.movements WHERE order_id=ANY(%s)', ([older_order, newer_order],))
|
||||
c.execute('DELETE FROM dtf_local.orders WHERE id=ANY(%s)', ([older_order, newer_order],))
|
||||
c.execute('DELETE FROM dtf_local.quotes WHERE id=ANY(%s)', ([older_quote, newer_quote],))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
64
tests/machine_pull_test.py
Normal file
64
tests/machine_pull_test.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""A card has no machine until pull, and a proof gives its machine to its parent."""
|
||||
from uuid import uuid4
|
||||
|
||||
from psycopg.types.json import Jsonb
|
||||
|
||||
from app.core import db
|
||||
from tests.smoke_test import Client
|
||||
from tests.users_test import order_fixture
|
||||
|
||||
|
||||
def final_stub(c, oid, owner):
|
||||
uid = uuid4()
|
||||
c.execute('''INSERT INTO dtf_local.uploads(id,owner,name,size,object_key,multipart_id,complete,
|
||||
expires_at,scan_state) VALUES(%s,%s,'machine-test.png',1,%s,'',true,now()+interval '1 day','clean')''',
|
||||
(uid, owner, f'machine-test/{uid}'))
|
||||
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','machine test','test')''', (uuid4(), oid, uid))
|
||||
|
||||
|
||||
def run():
|
||||
client = Client()
|
||||
client.call('/session')
|
||||
tag = uuid4().hex[:6]
|
||||
machine = client.call('/operator/machines', {'name': f'Pull {tag}', 'products': ['textil']}, operator=True)['id']
|
||||
other = client.call('/operator/machines', {'name': f'Other {tag}', 'products': ['textil']}, operator=True)['id']
|
||||
owner = uuid4()
|
||||
with db.connect() as c:
|
||||
_, oid = order_fixture(c, owner, 'file')
|
||||
final_stub(c, oid, owner)
|
||||
c.execute("UPDATE dtf_local.orders SET state='tra' WHERE id=%s", (oid,))
|
||||
board = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == str(oid))
|
||||
assert board['machine'] is None, board['machine']
|
||||
moved = client.call(f'/operator/orders/{oid}/move', {'state': 'imp', 'version': 0,
|
||||
'machine_id': machine}, operator=True)
|
||||
assert str(moved['machine_id']) == machine
|
||||
shown = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == str(oid))
|
||||
assert shown['machine_pulled']['by'] and shown['machine_pulled']['at'], shown
|
||||
assert client.call(f'/operator/orders/{oid}/history', operator=True)[-1]['machine'] == f'Pull {tag}'
|
||||
|
||||
with db.connect() as c:
|
||||
_, parent = order_fixture(c, owner, 'file')
|
||||
parent_row = c.execute('SELECT snapshot FROM dtf_local.orders WHERE id=%s', (parent,)).fetchone()
|
||||
child = uuid4()
|
||||
c.execute('''INSERT INTO dtf_local.orders(id,owner,snapshot,payment,origin,parent_id,state)
|
||||
VALUES(%s,%s,%s,%s,'site',%s,'tra')''',
|
||||
(child, owner, Jsonb({**parent_row['snapshot'], 'proof_of': 1}),
|
||||
Jsonb({'provider': 'prova'}), parent))
|
||||
final_stub(c, child, owner)
|
||||
shown = {o['id']: o for o in client.call('/operator/board', operator=True)['orders']}
|
||||
assert shown[str(parent)]['machine'] is None and shown[str(child)]['machine'] is None
|
||||
client.call(f'/operator/orders/{child}/move', {'state': 'imp', 'version': 0,
|
||||
'machine_id': machine}, operator=True)
|
||||
shown = {o['id']: o for o in client.call('/operator/board', operator=True)['orders']}
|
||||
assert shown[str(parent)]['machine']['id'] == machine == shown[str(child)]['machine']['id']
|
||||
with db.connect() as c:
|
||||
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s", (child,))
|
||||
client.call(f'/operator/orders/{child}/proof-answer', {'result': 'ok'}, operator=True)
|
||||
locked = client.call(f'/operator/orders/{parent}/machine', {'machine_id': other}, operator=True, expected=409)
|
||||
assert 'mesma máquina' in locked['detail'], locked
|
||||
print('PASS: no machine at creation; pull records operator and time; proof and parent share one machine')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
@@ -153,7 +153,8 @@ def run():
|
||||
assert tester.call('/operator/quotes/' + test_quote + '/test-order', {}, operator=True)['id'] == order['id']
|
||||
version = order['version']
|
||||
# Arte conferida, the print queue, takes the order once its final is approved.
|
||||
final = upload_bytes(tester, b'TEST ORDER FINAL', order_id=order['id'])
|
||||
from tests.smoke_test import final_png_bytes
|
||||
final = upload_bytes(tester, final_png_bytes('test order'), name='TEST-ORDER-FINAL.png', order_id=order['id'])
|
||||
version = tester.call('/operator/orders/' + order['id'] + '/final-files',
|
||||
{'version': version, 'files': [{'item_index': 0, 'upload_id': final}], 'note': 'Teste'},
|
||||
operator=True)['version']
|
||||
|
||||
@@ -36,15 +36,15 @@ CUSTOMER = {'cnpj': '11222333000181', 'zap': '11999999999', 'mail': 'print-test@
|
||||
|
||||
|
||||
def artwork(kind='PNG'):
|
||||
image = Image.new('RGBA', (600, 300), (0, 0, 0, 0))
|
||||
for x in range(40, 560):
|
||||
for y in range(40, 260):
|
||||
image = Image.new('RGBA', (1600, 800), (0, 0, 0, 0))
|
||||
for x in range(40, 1560):
|
||||
for y in range(40, 760):
|
||||
image.putpixel((x, y), (220, 30, 60, 255))
|
||||
out = io.BytesIO()
|
||||
if kind == 'PDF':
|
||||
image.convert('RGB').save(out, 'PDF', resolution=72)
|
||||
else:
|
||||
image.save(out, kind)
|
||||
image.save(out, kind, dpi=(300, 300))
|
||||
return out.getvalue()
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ def run():
|
||||
uid = upload_bytes(client, artwork(), name='LOCAL-PRINT-TEST.png')
|
||||
order = paid_order(client, loose_item(uid))
|
||||
order, row = wait_print(client, order['id'], 'ready')
|
||||
assert row['detail']['placements'] == 2 and row['detail']['min_dpi'] == round(600 / (20 / 2.54))
|
||||
assert row['detail']['placements'] == 2 and row['detail']['min_dpi'] == round(1600 / (20 / 2.54))
|
||||
# A 300 DPI PNG on a transparent background (item 13): the layout's 10 cm
|
||||
# and the 1,5 cm footer band, outside the billed length.
|
||||
film = download_png(client, row['upload_id'])
|
||||
@@ -142,7 +142,10 @@ def run():
|
||||
version += 1
|
||||
# Printing, the folders still get the file of an order they hold (to take
|
||||
# it to Finalizado later), and no one else's.
|
||||
client.call('/operator/orders/' + oid + '/move', {'state': 'imp', 'version': version}, operator=True)
|
||||
machine = client.call('/operator/machines', {'name': 'Print test '+uuid4().hex[:6],
|
||||
'products': ['textil']}, operator=True)['id']
|
||||
client.call('/operator/orders/' + oid + '/move', {'state': 'imp', 'version': version,
|
||||
'machine_id': machine}, operator=True)
|
||||
version += 1
|
||||
held = client.call('/operator/queue/folder', {'early': True, 'held': [oid]}, operator=True)
|
||||
assert [(f['state'], f['upload_id']) for f in held['files'] if f['order'] == oid] == [('imp', str(row['upload_id']))], held
|
||||
@@ -223,15 +226,17 @@ def run():
|
||||
with db.connect() as c:
|
||||
assert not c.execute('SELECT 1 FROM dtf_local.outbox WHERE event_key LIKE %s', (card['id'] + '%',)).fetchone()
|
||||
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s", (card['id'],))
|
||||
final = upload_bytes(client, b'LOCAL PROOF FINAL FIXTURE', order_id=parent['id'])
|
||||
version = client.call('/operator/orders/' + parent['id'] + '/final-files',
|
||||
{'version': parent['version'], 'files': [{'item_index': 0, 'upload_id': final}],
|
||||
'note': 'Local proof test final'}, operator=True)['version']
|
||||
version = client.call('/operator/orders/' + parent['id'] + '/move', {'state': 'tra', 'version': version},
|
||||
operator=True)['version']
|
||||
held = client.call('/operator/orders/' + parent['id'] + '/move', {'state': 'imp', 'version': version},
|
||||
operator=True, expected=409)
|
||||
final = str(uuid4())
|
||||
held = client.call('/operator/orders/' + parent['id'] + '/final-files',
|
||||
{'version': parent['version'], 'files': [{'item_index': 0, 'upload_id': final}],
|
||||
'note': 'Local proof test final'}, operator=True, expected=409)
|
||||
assert 'Aguardando prova' in held['detail'], held
|
||||
for path, body in [('/move', {'state': 'tra', 'version': parent['version']}),
|
||||
('/contraction', {'item_index': 0, 'value': 'C1'}),
|
||||
('/machine', {'machine_id': None}),
|
||||
('/queue', {'after': card['id']})]:
|
||||
held = client.call('/operator/orders/' + parent['id'] + path, body, operator=True, expected=409)
|
||||
assert 'Aguardando prova' in held['detail'], (path, held)
|
||||
client.call('/operator/orders/' + card['id'] + '/move', {'state': 'fin', 'version': card['version']},
|
||||
operator=True, expected=409)
|
||||
# Reprovada needs its reason; the order goes back to Arte recebida.
|
||||
@@ -245,6 +250,11 @@ def run():
|
||||
assert mine['state'] == 'rec' and mine['proof_card']['proof_result'] == 'rejected', mine['proof_card']
|
||||
assert mine['proof_card']['proof_reason'] == 'Cor do fundo errada'
|
||||
assert not [o for o in board if o['id'] == card['id']], 'an answered proof card leaves the board'
|
||||
# Rejection releases the parent for corrected artwork, until a new proof card is opened.
|
||||
final = upload_bytes(client, artwork(), name='LOCAL-PROOF-FINAL.png', order_id=parent['id'])
|
||||
version = client.call('/operator/orders/' + parent['id'] + '/final-files',
|
||||
{'version': mine['version'], 'files': [{'item_index': 0, 'upload_id': final}],
|
||||
'note': 'Local proof test final'}, operator=True)['version']
|
||||
# A new card, and Prova OK lets the order into the queue.
|
||||
again = client.call('/operator/orders/' + parent['id'] + '/proof-card', {}, operator=True)
|
||||
client.call('/operator/orders/' + parent['id'] + '/proof-card', {}, operator=True, expected=409)
|
||||
@@ -252,7 +262,7 @@ def run():
|
||||
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s", (again['id'],))
|
||||
client.call('/operator/orders/' + again['id'] + '/proof-answer', {'result': 'ok'}, operator=True)
|
||||
mine = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == parent['id'])
|
||||
assert mine['proof_ok_at'] and mine['proof_card']['proof_result'] == 'ok', mine
|
||||
assert mine['proof_ok_at'] and mine['proof_card']['proof_result'] == 'ok' and mine['state'] == 'tra', mine
|
||||
print('PASS: an order with a proof waits for its proof card, which is answered OK or rejected in Revisão')
|
||||
|
||||
# A customer cannot see or reuse another order's generated file.
|
||||
@@ -313,7 +323,7 @@ def run():
|
||||
finished = client.call('/operator/orders/finished?limit=1', operator=True)
|
||||
if finished['orders']:
|
||||
last = finished['orders'][-1]
|
||||
client.call('/operator/orders/finished?before_created_at=' + last['created_at'].replace('+', '%2B')
|
||||
client.call('/operator/orders/finished?before_finished_at=' + last['finished_at'].replace('+', '%2B')
|
||||
+ '&before_id=' + last['id'], operator=True)
|
||||
print('PASS: send log, payment history and finished orders page and filter')
|
||||
|
||||
|
||||
@@ -7,12 +7,25 @@ import hashlib
|
||||
import http.cookiejar
|
||||
import json
|
||||
import os
|
||||
import struct
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
import time
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import build_opener, HTTPCookieProcessor, Request, urlopen
|
||||
from uuid import uuid4
|
||||
|
||||
|
||||
def final_png_bytes(label='final'):
|
||||
"""A tiny real RGBA PNG tagged 300 DPI for operator final-file tests."""
|
||||
def chunk(kind, body):
|
||||
return struct.pack('>I', len(body)) + kind + body + struct.pack('>I', zlib.crc32(kind + body) & 0xffffffff)
|
||||
red = hashlib.sha256(label.encode()).digest()[0]
|
||||
row = b'\x00' + bytes((red, 30, 60, 255, 0, 0, 0, 0))
|
||||
return (b'\x89PNG\r\n\x1a\n' + chunk(b'IHDR', struct.pack('>IIBBBBB', 2, 1, 8, 6, 0, 0, 0)) +
|
||||
chunk(b'pHYs', struct.pack('>IIB', 11811, 11811, 1)) +
|
||||
chunk(b'IDAT', zlib.compress(row)) + chunk(b'IEND', b''))
|
||||
|
||||
if Path('.env').exists():
|
||||
for line in Path('.env').read_text().splitlines():
|
||||
if line.strip() and not line.startswith('#') and '=' in line:
|
||||
@@ -269,7 +282,7 @@ def run():
|
||||
if state=='tra':
|
||||
# The queue takes approved final files only.
|
||||
client.call('/operator/orders/'+oid+'/move',{'state':'tra','version':version},operator=True,expected=409)
|
||||
files=[{'item_index':i,'upload_id':upload_bytes(client,b'LOCAL FINAL FIXTURE '+str(i).encode(),order_id=oid)} for i in range(4)]
|
||||
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']
|
||||
if state=='imp':
|
||||
|
||||
27
tests/test_printpng_validate.py
Normal file
27
tests/test_printpng_validate.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""Final artwork acceptance is based on PNG bytes, alpha and 300 DPI metadata."""
|
||||
import io
|
||||
import unittest
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from app.printpng_validate import final_png_issue
|
||||
|
||||
|
||||
def png(mode='RGBA', dpi=(300, 300)):
|
||||
out = io.BytesIO()
|
||||
Image.new(mode, (3, 3), (0, 0, 0, 0) if mode == 'RGBA' else (0, 0, 0)).save(out, 'PNG', dpi=dpi)
|
||||
return out.getvalue()
|
||||
|
||||
|
||||
class FinalPngTests(unittest.TestCase):
|
||||
def test_accepts_only_rgba_300dpi_png(self):
|
||||
self.assertIsNone(final_png_issue(png()))
|
||||
self.assertIn('precisa ser PNG', final_png_issue(b'%PDF-1.7'))
|
||||
self.assertIn('transparência', final_png_issue(png('RGB')))
|
||||
self.assertIn('300 DPI', final_png_issue(png(dpi=(72, 72))))
|
||||
self.assertIn('300 DPI', final_png_issue(png(dpi=(300, 150))))
|
||||
self.assertIn('incompleto', final_png_issue(png()[:50]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -2,7 +2,7 @@
|
||||
import os
|
||||
from uuid import uuid4
|
||||
from urllib.request import urlopen
|
||||
from tests.smoke_test import Client, approved_quote, upload_bytes, item_spec, register
|
||||
from tests.smoke_test import Client, approved_quote, upload_bytes, item_spec, register, final_png_bytes
|
||||
|
||||
def run():
|
||||
customer=Client();other=Client();customer.call('/session');other.call('/session')
|
||||
@@ -55,7 +55,8 @@ def run():
|
||||
# Arte conferida is the print queue (2026-10-23): it takes approved finals only.
|
||||
version=0
|
||||
customer.call('/operator/orders/'+oid+'/move',{'state':'tra','version':version},operator=True,expected=409)
|
||||
final_id=upload_bytes(customer,b'LOCAL FINAL VERSION ONE',order_id=oid)
|
||||
final_one=final_png_bytes('final one')
|
||||
final_id=upload_bytes(customer,final_one,name='LOCAL-FINAL-ONE.png',order_id=oid)
|
||||
customer.call('/uploads/'+final_id,expected=404)
|
||||
body={'version':version,'files':[{'item_index':0,'upload_id':final_id}],'note':'Manually checked final'}
|
||||
customer.call('/operator/orders/'+oid+'/final-files',body,expected=401)
|
||||
@@ -67,21 +68,21 @@ def run():
|
||||
detail=customer.call('/customer/orders/'+oid)
|
||||
final=detail['files'][0]
|
||||
link=customer.call('/customer/orders/'+oid+'/files/'+final['id']+'/download')
|
||||
assert urlopen(link['url']).read()==b'LOCAL FINAL VERSION ONE'
|
||||
assert urlopen(link['url']).read()==final_one
|
||||
guest=Client();guest.call('/session');guest.call('/customer/orders/'+oid+'/files/'+final['id']+'/download',expected=404)
|
||||
version=move('tra',version)
|
||||
# The print queue's files come named after their order, straight from storage.
|
||||
queued=customer.call('/operator/queue/finals',operator=True)['files']
|
||||
mine=[f for f in queued if urlopen(f['url']).read()==b'LOCAL FINAL VERSION ONE']
|
||||
mine=[f for f in queued if urlopen(f['url']).read()==final_one]
|
||||
assert len(mine)==1 and mine[0]['name'].startswith('DTF-%d-item-1-' % mine[0]['number']), queued
|
||||
customer.call('/operator/queue/finals',expected=401)
|
||||
version=move('imp',version);version=move('cor',version)
|
||||
customer.call('/customer/orders/'+oid+'/files/'+final['id']+'/download',expected=404)
|
||||
premature_final=upload_bytes(customer,b'FINAL BEFORE CUSTOMER CORRECTION',order_id=oid)
|
||||
premature_final=upload_bytes(customer,final_png_bytes('premature'),name='LOCAL-PREMATURE-FINAL.png',order_id=oid)
|
||||
version=customer.call('/operator/orders/'+oid+'/final-files',
|
||||
{'version':version,'files':[{'item_index':0,'upload_id':premature_final}],
|
||||
'note':'Prepared before customer sent the new correction'},operator=True)['version']
|
||||
correction_id=upload_bytes(customer,b'LOCAL CORRECTED ORIGINAL')
|
||||
correction_id=upload_bytes(customer,final_png_bytes('correction'),name='LOCAL-CORRECTION.png')
|
||||
payload={'version':version,'files':[{'item_index':0,'upload_id':correction_id}],'note':'Replaced the artwork as requested'}
|
||||
guest.call('/customer/orders/'+oid+'/corrections',payload,expected=404)
|
||||
customer.call('/customer/orders/'+oid+'/corrections',{**payload,'version':0},expected=409)
|
||||
@@ -97,7 +98,7 @@ def run():
|
||||
# The customer's own correction approved as it is: not treated.
|
||||
assert treated() is None, treated()
|
||||
customer.call('/operator/orders/'+oid+'/final-files',{'version':version,'files':[{'item_index':0,'upload_id':correction_id}],'note':'Twice'},operator=True,expected=409)
|
||||
new_final=upload_bytes(customer,b'LOCAL FINAL VERSION TWO',order_id=oid)
|
||||
new_final=upload_bytes(customer,final_png_bytes('final two'),name='LOCAL-FINAL-TWO.png',order_id=oid)
|
||||
version=customer.call('/operator/orders/'+oid+'/final-files',{'version':version,'files':[{'item_index':0,'upload_id':new_final}],'note':'Checked corrected final'},operator=True)['version']
|
||||
assert treated()=={'items':[0],'by':operator_email}, treated()
|
||||
stats=customer.call('/operator/stats?days=7',operator=True)['treated']
|
||||
@@ -128,7 +129,7 @@ def treating():
|
||||
approved_quote(customer,q,items)
|
||||
order=customer.call('/orders/dev-paid',{'quote_id':q['id']});oid=order['id'];number=order['number']
|
||||
files=lambda:[f for f in customer.call('/operator/orders/'+oid+'/files',operator=True) if f['kind']=='final' and f['active']]
|
||||
first=[upload_bytes(customer,b'LOCAL FIRST FINAL %d' % n,order_id=oid) for n in (1,2)]
|
||||
first=[upload_bytes(customer,final_png_bytes(f'first {n}'),name=f'LOCAL-FIRST-FINAL-{n}.png',order_id=oid) for n in (1,2)]
|
||||
version=customer.call('/operator/orders/'+oid+'/final-files',{'version':0,'note':'Aprovado',
|
||||
'files':[{'item_index':i,'upload_id':u} for i,u in enumerate(first)]},operator=True)['version']
|
||||
# Where each item is in the stage folder, named as the folders save it.
|
||||
@@ -137,7 +138,7 @@ def treating():
|
||||
assert all(f['name'].startswith('DTF-%d-item-%d' % (number,f['item'])) for f in folder['files']), folder
|
||||
customer.call('/operator/orders/'+oid+'/folder-files',expected=401)
|
||||
# Saved over with the same name and sent back: item 1 changes, item 2 keeps its final.
|
||||
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
|
||||
png=final_png_bytes('treated')
|
||||
treated=upload_bytes(customer,png,name='DTF-%d-item-1.png' % number,order_id=oid)
|
||||
both=[{'item_index':0,'upload_id':treated},{'item_index':1,'upload_id':first[1]}]
|
||||
version=customer.call('/operator/orders/'+oid+'/final-files',{'version':version,'files':both,'note':'Arte tratada'},operator=True)['version']
|
||||
|
||||
Reference in New Issue
Block a user