feat: Site orders carry DTF-<n> as Tiny's numeroPedidoEcommerce
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m47s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m14s
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m47s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m14s
Dropstar asked on 2026-10-23 for the Kanban number in numeroPedidoEcommerce. It goes there on every order now, next to numeroOrdemCompra, which the resend check still searches. Tiny's v3 model takes the e-commerce block without a channel id; TINY_ECOMMERCE_ID adds one and can now be set in the stack. The supervised test order reads the number back from Tiny and fails if Tiny did not keep it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -131,6 +131,10 @@ class TinyTests(FakeTinyCase):
|
||||
pedido = order_payload(PAID, 777, date(2026, 9, 24))
|
||||
self.assertEqual((pedido['idContato'], pedido['numeroOrdemCompra'], pedido['data']),
|
||||
(777, 'DTF-42', '2026-09-24'))
|
||||
# The DTF number is also the e-commerce order number; no channel unless one is set.
|
||||
self.assertEqual(pedido['ecommerce'], {'numeroPedidoEcommerce': 'DTF-42'})
|
||||
with mock.patch.dict(os.environ, {'TINY_ECOMMERCE_ID': '555'}):
|
||||
self.assertEqual(order_payload(PAID, 777)['ecommerce'], {'numeroPedidoEcommerce': 'DTF-42', 'id': 555})
|
||||
item = pedido['itens'][0]
|
||||
self.assertEqual((item['produto'], item['quantidade'], item['valorUnitario']),
|
||||
({'id': 102}, 2.8, 24.9))
|
||||
@@ -615,11 +619,27 @@ class TinyProbeTests(FakeTinyCase):
|
||||
self.assertEqual(len(self.orders), 1)
|
||||
self.assertEqual(self.orders[0]['itens'][0]['produto'], {'id': 104})
|
||||
self.assertIn('2º envio: already-created', text)
|
||||
self.assertIn('E-commerce no Tiny: numeroPedidoEcommerce DTF-TESTE-', text)
|
||||
# Then cancelled through the API, and read back: it does not stay open.
|
||||
self.assertEqual(self.orders[0]['situacao'], 2)
|
||||
self.assertIn(f"Pedido nº {self.orders[0]['numeroPedido']} cancelado no Tiny.", text)
|
||||
self.assertEqual(self.tags[self.orders[0]['id']], [{'descricao': 'SITE DTF'}])
|
||||
|
||||
def test_a_number_tiny_did_not_keep_fails_the_supervised_order(self):
|
||||
# Tiny may drop the e-commerce block of an order with no channel.
|
||||
def dropping(request):
|
||||
if request.method == 'POST' and request.url.path.endswith('/pedidos'):
|
||||
body = {k: v for k, v in json.loads(request.content).items() if k != 'ecommerce'}
|
||||
request = httpx.Request(request.method, request.url, headers=request.headers, content=json.dumps(body))
|
||||
return self.handler(request)
|
||||
self.tiny = TinyOrders(auth=FakeAuth(), transport=httpx.MockTransport(dropping), today=date(2026, 9, 24))
|
||||
code, text = self.probe('pedido', '--cnpj', '11222333000181', '--email', 'a@example.test',
|
||||
'--celular', '16999999999', '--confirmar')
|
||||
self.assertEqual(code, 1, text)
|
||||
self.assertIn('numeroPedidoEcommerce (vazio) · sem canal', text)
|
||||
self.assertIn('FALHA: o Tiny não guardou DTF-TESTE-', text)
|
||||
self.assertEqual(self.orders[0]['situacao'], 2)
|
||||
|
||||
def test_cancelar_touches_only_test_orders(self):
|
||||
self.tiny.deliver('k1', PAID)
|
||||
real = self.orders[0]
|
||||
|
||||
Reference in New Issue
Block a user