Merge front 7a.4: montador Venda with shipping
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,8 @@ def run():
|
||||
'zap': '1633334444', 'mail': f'interno-{tag}@example.test'}
|
||||
venda_customer = {'name': 'Maria Souza', 'cnpj': '12345678909',
|
||||
'zap': '16988887777', 'mail': f'venda-{tag}@example.test'}
|
||||
envio_customer = {'name': 'Maria Souza', 'cnpj': '12345678909',
|
||||
'zap': '16988887777', 'mail': f'envio-{tag}@example.test'}
|
||||
identities = [operator_identity(emails['expedicao']), operator_identity(emails['vendedor'])]
|
||||
made_orders, made_quotes = [], []
|
||||
# A code of its own, so a brand someone saved in Estampas/ is never touched.
|
||||
@@ -200,8 +202,36 @@ def run():
|
||||
designer.call('/operator/montador/orders', {'request_key': str(uuid4()), **venda}, expected=403)
|
||||
shipping.call('/operator/montador/orders', {'request_key': str(uuid4()), 'kind': 'interno',
|
||||
'items': [montador_item(stamp, 'file')]}, expected=422)
|
||||
|
||||
# Venda with Envio: the Site's freight, re-quoted by the server.
|
||||
destination = {'recipient': 'Maria Souza', 'street': 'Rua das Flores', 'number': '100',
|
||||
'complement': 'Sala 2', 'district': 'Centro', 'city': 'Franca',
|
||||
'state': 'SP', 'postal_code': '14400000'}
|
||||
envio_stamp = upload_stamp(seller)
|
||||
envio = {'kind': 'venda', 'customer': envio_customer, 'items': [montador_item(envio_stamp)],
|
||||
'freight': {'service': 'mock-standard', 'postal_code': '14400000'},
|
||||
'destination': destination}
|
||||
order_envio = seller.call('/operator/montador/orders', {'request_key': str(uuid4()), **envio})
|
||||
made_orders.append(UUID(order_envio['id']))
|
||||
made_quotes.append(UUID(order_envio['quote_id']))
|
||||
snapshot = order_envio['snapshot']
|
||||
assert snapshot['destination'] == destination, snapshot.get('destination')
|
||||
assert snapshot['freight']['service'] == 'mock-standard', snapshot.get('freight')
|
||||
assert snapshot['freight']['total_cents'] > 0, snapshot.get('freight')
|
||||
assert snapshot['total_cents'] == (sum(item['total_cents'] for item in snapshot['items']) +
|
||||
snapshot['freight']['total_cents']), snapshot['total_cents']
|
||||
with db.connect() as c:
|
||||
assert c.execute('SELECT 1 FROM dtf_local.outbox WHERE event_key=%s AND provider=%s',
|
||||
(f"{order_envio['id']}:paid:tiny", 'tiny')).fetchone()
|
||||
# Envio needs the full address; an Interno order never ships.
|
||||
sem_destino = {key: value for key, value in envio.items() if key != 'destination'}
|
||||
seller.call('/operator/montador/orders', {'request_key': str(uuid4()), **sem_destino}, expected=422)
|
||||
shipping.call('/operator/montador/orders', {'request_key': str(uuid4()), 'kind': 'interno',
|
||||
'items': [montador_item(stamp)],
|
||||
'destination': destination}, expected=422)
|
||||
print('PASS: Expedição makes Interno and Vendedor makes Venda; the internal customer, the Tiny '
|
||||
'contacts, the stamp brand and the table price in Números work; invalid profiles and modes are refused')
|
||||
'contacts, the stamp brand and the table price in Números work; a Venda with Envio carries '
|
||||
'the destination and the quoted freight; invalid profiles, modes and deliveries are refused')
|
||||
finally:
|
||||
with db.connect() as c:
|
||||
if made_orders:
|
||||
@@ -215,8 +245,8 @@ def run():
|
||||
c.execute('DELETE FROM dtf_local.orders WHERE id=%s', (oid,))
|
||||
if made_quotes:
|
||||
c.execute('DELETE FROM dtf_local.quotes WHERE id=ANY(%s)', (made_quotes,))
|
||||
c.execute('DELETE FROM dtf_local.mail_queue WHERE to_addr IN (%s,%s)',
|
||||
(internal_customer['mail'], venda_customer['mail']))
|
||||
c.execute('DELETE FROM dtf_local.mail_queue WHERE to_addr IN (%s,%s,%s)',
|
||||
(internal_customer['mail'], venda_customer['mail'], envio_customer['mail']))
|
||||
for identity in identities:
|
||||
c.execute('DELETE FROM dtf_local.uploads WHERE owner=%s', (identity,))
|
||||
c.execute('DELETE FROM dtf_local.stamps WHERE code=%s', (stamp_code,))
|
||||
|
||||
Reference in New Issue
Block a user