feat: the Tiny probe tells why an order has no seller, the test order checks the seller Tiny kept, and each delivery records the seller sent (Marcus, 2026-12-02)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 8m30s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m13s

Dropstar says every order reaches Tiny without the seller of the customer's
registration and they add it by hand (#237, DTF-237: contact with Kedma,
order with vendedor null). The field names match Tiny's v3 schema
(contato.vendedor {id, nome}, pedido.vendedor {id}), so the cause is in the
data or in Tiny. "tiny_probe vendedor NUMERO" (read-only) shows the order's
seller, its contact and that contact's seller, the contacts sharing the
CPF/CNPJ, and what the integration's own search and reading give today, with
a conclusion. The supervised test order now previews the contact's seller,
reads the order back and says OK or FALHA for the seller. The Tiny receipt
keeps "seller", the id sent or null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-02 15:43:13 -03:00
parent dea8036b73
commit 6c7af233bc
3 changed files with 128 additions and 6 deletions

View File

@@ -886,6 +886,49 @@ class TinyProbeTests(FakeTinyCase):
self.assertIn('FALHA: o Tiny não guardou DTF-TESTE-', text)
self.assertEqual(self.orders[0]['situacao'], 2)
def test_the_supervised_order_says_whether_tiny_kept_the_seller(self):
# Marcus, 2026-12-02 (#237): the contact has a seller and the order came without.
self.contacts.append({'id': 321, 'cpfCnpj': '11.222.333/0001-81', 'vendedor': {'id': 977226210, 'nome': 'Kedma'}})
code, text = self.probe('pedido', '--cnpj', '11222333000181', '--email', 'a@example.test',
'--celular', '16999999999', '--confirmar')
self.assertEqual(code, 0, text)
self.assertIn('Vendedor do cadastro do contato: id 977226210', text)
self.assertIn('"vendedor": {\n "id": 977226210', text)
self.assertIn('OK: o Tiny gravou o vendedor enviado (id 977226210).', text)
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 != 'vendedor'}
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))
self.orders.clear()
code, text = self.probe('pedido', '--cnpj', '11222333000181', '--email', 'a@example.test',
'--celular', '16999999999', '--confirmar')
self.assertEqual(code, 1, text)
self.assertIn('FALHA: mandamos o vendedor id 977226210 e o Tiny gravou nenhum.', text)
def test_vendedor_tells_why_an_order_has_no_seller(self):
self.contacts.append({'id': 321, 'cpfCnpj': '11.222.333/0001-81', 'vendedor': {'id': 977226210, 'nome': 'Kedma'}})
receipt = self.tiny.deliver('k1', PAID)
# Which seller went is kept with the delivery.
self.assertEqual(receipt['seller'], 977226210)
order = self.orders[0]
order['cliente'] = {'id': 321, 'cpfCnpj': '11.222.333/0001-81'}
order.pop('vendedor') # as Tiny showed #237
code, text = self.probe('vendedor', order['numeroPedido'])
self.assertEqual(code, 0, text)
self.assertIn(f"Vendedor no pedido {order['numeroPedido']}: nenhum", text)
self.assertIn('Vendedor no cadastro desse contato hoje: Kedma (id 977226210)', text)
self.assertIn('A integração encontra o contato id 321 e lê o vendedor: id 977226210', text)
self.assertIn('Conclusão: a integração lê o vendedor hoje e o pedido ficou sem ele.', text)
self.assertNotIn('PUT', [method for method, _ in self.calls if method != 'POST'])
# A second contact with the same document, found first, is named.
self.contacts.insert(0, {'id': 320, 'cpfCnpj': '11.222.333/0001-81'})
code, text = self.probe('vendedor', order['numeroPedido'])
self.assertIn('Contatos com o mesmo CPF/CNPJ: 2', text)
self.assertIn('Conclusão: a busca da integração cai em outro contato que não o do pedido.', text)
def test_cancelar_touches_only_test_orders(self):
self.tiny.deliver('k1', PAID)
real = self.orders[0]