fix: Tiny's connection test no longer times out listing orders
All checks were successful
Build and deploy / Validate source (push) Successful in 1m38s
Build and deploy / Integration suite on a real stack (push) Successful in 4m33s
Build and deploy / Secret scan and release gate (push) Successful in 11s
Build and deploy / Publish images (push) Successful in 1m51s

"Testar conexão" asked Tiny for one order with no filter, and on the
client's account Tiny answered 400 "Sua consulta levou muito tempo". It now
asks for orders since yesterday, which proves the same permission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-14 10:54:19 -03:00
parent 914c55c329
commit 3c9f05041e
2 changed files with 16 additions and 3 deletions

View File

@@ -450,11 +450,14 @@ def check(auth=None, transport=None, orders=None):
otherwise reports each read separately."""
orders = orders or TinyOrders(auth=auth or TinyAuth(), transport=transport)
def listed(path):
orders.request('GET', path, params={'limit': 1})
def listed(path, **filters):
orders.request('GET', path, params={'limit': 1, **filters})
return 'ok'
reads = [('pedidos', lambda: listed('/pedidos')), ('contatos', lambda: listed('/contatos'))]
# Unfiltered, a large account's order list times out ("Sua consulta levou
# muito tempo"): yesterday's orders prove the same permission.
since = (local_today() - timedelta(days=1)).isoformat()
reads = [('pedidos', lambda: listed('/pedidos', dataInicial=since)), ('contatos', lambda: listed('/contatos'))]
reads += [(PRODUCTS[mode], lambda mode=mode: configured_skus(orders, mode) if mode_codes(mode)
else configured_product(orders, mode)[1]) for mode in PRODUCT_SETTINGS]
reads.append(('forma de envio de retirada', lambda: configured_pickup(orders)[1]))