feat: the Tiny probe's diagnostico finds which part of an order Tiny refuses
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 3m46s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m6s
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 3m46s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m6s
Tiny answered the test order with a bare 403. The command sends the same test order whole, then without one part at a time (ecommerce, pagamento, transportador, dataPrevista), then with only the essentials, stops at the first version Tiny accepts and cancels it at once. It needs a contact that already exists and never creates one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -584,6 +584,50 @@ class TinyProbeTests(FakeTinyCase):
|
||||
self.assertIn('77\t6\tRetirar pessoalmente', text)
|
||||
self.assertTrue(all(method == 'GET' for method, _ in self.calls))
|
||||
|
||||
def test_diagnostico_finds_the_part_tiny_refuses(self):
|
||||
handler = self.handler
|
||||
|
||||
def refusing(request):
|
||||
path = request.url.path.removeprefix('/public-api/v3')
|
||||
if request.method == 'POST' and path == '/pedidos' and 'ecommerce' in json.loads(request.content):
|
||||
self.calls.append((request.method, path))
|
||||
return httpx.Response(403, text='')
|
||||
return handler(request)
|
||||
self.tiny.http = httpx.Client(base_url=tiny_module.API, transport=httpx.MockTransport(refusing))
|
||||
args = ('diagnostico', '--cpf', '130.323.978-71', '--email', 'a@example.test', '--celular', '16999999999')
|
||||
# Never creates a contact: one that exists is required.
|
||||
code, text = self.probe(*args)
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn('não existe no Tiny', text)
|
||||
self.assertNotIn(('POST', '/contatos'), self.calls)
|
||||
self.assertNotIn(('POST', '/pedidos'), self.calls)
|
||||
self.contacts.append({'id': 600, 'cpfCnpj': '130.323.978-71', 'nome': 'Teste Fernandes'})
|
||||
code, text = self.probe(*args)
|
||||
self.assertEqual(code, 0, text)
|
||||
self.assertIn('completo: recusado', text)
|
||||
self.assertIn('sem ecommerce: ACEITO', text)
|
||||
# The one order Tiny accepted is cancelled at once, and nothing after it is sent.
|
||||
self.assertEqual(len(self.orders), 1)
|
||||
self.assertEqual(self.orders[0]['situacao'], tiny_module.CANCELADA)
|
||||
self.assertIn('cancelado no Tiny', text)
|
||||
self.assertNotIn(('POST', '/contatos'), self.calls)
|
||||
|
||||
def test_diagnostico_blames_the_permission_when_all_are_refused(self):
|
||||
handler = self.handler
|
||||
|
||||
def refusing(request):
|
||||
if request.method == 'POST' and request.url.path.endswith('/pedidos'):
|
||||
return httpx.Response(403, text='')
|
||||
return handler(request)
|
||||
self.tiny.http = httpx.Client(base_url=tiny_module.API, transport=httpx.MockTransport(refusing))
|
||||
self.contacts.append({'id': 600, 'cpfCnpj': '130.323.978-71', 'nome': 'Teste Fernandes'})
|
||||
code, text = self.probe('diagnostico', '--cpf', '13032397871', '--email', 'a@example.test',
|
||||
'--celular', '16999999999')
|
||||
self.assertEqual(code, 1)
|
||||
self.assertIn('só o essencial', text)
|
||||
self.assertIn('permissão do usuário do Tiny', text)
|
||||
self.assertEqual(self.orders, [])
|
||||
|
||||
def test_campos_says_which_lookup_needs_a_permission(self):
|
||||
handler = self.handler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user