feat: one order, one machine: UV and textile never share an order (Marcus, 2026-11-26)
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m16s
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m16s
The server refuses a cart (and a review) with UV and textile items; the Site says so as soon as the customer opens a product of the other line, or adds it, with "Finalizar este pedido" and "Trocar o carrinho por este item". Basic and premium textile still go together. Proof cards copy their order's items, so they follow. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -196,12 +196,16 @@ def run():
|
||||
print('PASS: multipart resume, incomplete rejection, immutable completion, ownership, private/downloaded bytes')
|
||||
|
||||
# Above QUOTE_AUTO_MAX_METRES (50 m by default), so a person reviews it.
|
||||
items=[item_spec(m,'13',90,uid) for m in ('file','avulsa','uvfile','uv')]
|
||||
# One order, one machine (Marcus, 2026-11-26): the two textile products;
|
||||
# UV goes in an order of its own.
|
||||
items=[item_spec(m,'26',90,uid) for m in ('file','avulsa')]
|
||||
draft={'request_key':str(uuid4()),'customer':{'cnpj':'11222333000181','zap':'11999999999','mail':'local-smoke@example.test'},
|
||||
'items':items,'freight':{'service':'mock-standard','postal_code':'14400000'},
|
||||
'destination':{'recipient':'Local Smoke Ltda','street':'Rua de Teste','number':'100',
|
||||
'district':'Centro','city':'Franca','state':'SP','postal_code':'14400000'}}
|
||||
client.call('/quotes',{**draft,'total_cents':1},expected=422)
|
||||
mixed_cart=client.call('/quotes',{**draft,'items':[items[0],item_spec('uvfile','13',90,uid)]},expected=422)['detail']
|
||||
assert any('outra máquina' in str(e.get('msg','')) for e in mixed_cart), mixed_cart
|
||||
# Freight quoted by CEP alone cannot ship: the address is required, must be
|
||||
# the quoted CEP, and a pickup order takes none.
|
||||
client.call('/quotes',{**draft,'destination':None},expected=422)
|
||||
@@ -237,8 +241,8 @@ def run():
|
||||
corrected=[{**items[0],'metres':'1.01','grade':0},*items[1:]]
|
||||
approved=client.call('/operator/quotes/'+qid+'/approve',{'items':corrected},operator=True)
|
||||
assert approved['items'][0]['total_cents']==2189 and approved['items'][0]['grade']==0
|
||||
assert [i['unit_cents'] for i in approved['items'][1:]]==[2190,7990,8990]
|
||||
assert approved['total_cents']==2189+28470+103870+116870+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
|
||||
assert [i['unit_cents'] for i in approved['items'][1:]]==[2190]
|
||||
assert approved['total_cents']==2189+56940+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
|
||||
assert approved['destination']=={**draft['destination'],'complement':''}
|
||||
client.call('/operator/quotes/'+qid+'/approve',{'items':items},operator=True,expected=409)
|
||||
assert not client.call('/quotes/'+qid)['auto_approved']
|
||||
@@ -331,7 +335,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,final_png_bytes(str(i)),name=f'LOCAL-FINAL-{i}.png',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(len(items))]
|
||||
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 ''}
|
||||
|
||||
29
tests/test_one_machine.py
Normal file
29
tests/test_one_machine.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""One order, one machine (Marcus, 2026-11-26): UV and textile never share an
|
||||
order; basic and premium textile may.
|
||||
|
||||
Run from the repository root: python3 -m unittest tests.test_one_machine -v.
|
||||
"""
|
||||
import unittest
|
||||
|
||||
from app.core.models import ONE_MACHINE, Item, check_one_machine
|
||||
from tests.test_sheet_trim import sheet_item
|
||||
|
||||
|
||||
def items(*modes):
|
||||
return [Item.model_validate(sheet_item(mode=mode)) for mode in modes]
|
||||
|
||||
|
||||
class OneMachineTests(unittest.TestCase):
|
||||
def test_uv_and_textile_never_share_an_order(self):
|
||||
for modes in (('file', 'uvfile'), ('premium', 'uvfile'), ('uvfile', 'file', 'file')):
|
||||
with self.assertRaises(ValueError) as caught:
|
||||
check_one_machine(items(*modes))
|
||||
self.assertEqual(str(caught.exception), ONE_MACHINE)
|
||||
|
||||
def test_one_line_passes(self):
|
||||
check_one_machine(items('file', 'premium', 'file'))
|
||||
check_one_machine(items('uvfile', 'uvfile'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user