feat: Site orders reach Tiny in the DUPLICADO DROP category, tagged KANBANDTF
Some checks failed
Build and deploy / Validate source (push) Successful in 1m29s
Build and deploy / Integration suite on a real stack (push) Successful in 5m8s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Failing after 1m34s
Some checks failed
Build and deploy / Validate source (push) Successful in 1m29s
Build and deploy / Integration suite on a real stack (push) Successful in 5m8s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Failing after 1m34s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,8 @@ class FakeTinyCase(unittest.TestCase):
|
||||
self.orders = []
|
||||
self.calls = []
|
||||
self.refuse_status = 0
|
||||
self.refuse_tag = 0
|
||||
self.tags = {}
|
||||
self.methods = {'77': {'id': 77, 'nome': 'Retirar pessoalmente', 'tipo': '6',
|
||||
'formasFrete': [{'id': 771, 'nome': 'Retirar em loja'}]},
|
||||
'78': {'id': 78, 'nome': 'Correios', 'tipo': '1',
|
||||
@@ -94,8 +96,15 @@ class FakeTinyCase(unittest.TestCase):
|
||||
if request.method == 'GET' and path == '/pedidos':
|
||||
return httpx.Response(200, json={'itens': [{'id': o['id'], 'numeroPedido': o['numeroPedido']}
|
||||
for o in self.orders]})
|
||||
if request.method == 'GET' and path.endswith('/marcadores'):
|
||||
return httpx.Response(200, json=[{'descricao': 'SITE DTF'}])
|
||||
if path.startswith('/pedidos/') and path.endswith('/marcadores'):
|
||||
wanted = int(path.split('/')[2])
|
||||
if request.method == 'GET':
|
||||
return httpx.Response(200, json=self.tags.get(wanted, []))
|
||||
if self.refuse_tag:
|
||||
self.refuse_tag -= 1
|
||||
return httpx.Response(503, text='indisponível')
|
||||
self.tags.setdefault(wanted, []).extend(json.loads(request.content))
|
||||
return httpx.Response(204)
|
||||
if request.method == 'GET' and path.startswith('/pedidos/'):
|
||||
wanted = int(path.rsplit('/', 1)[-1])
|
||||
return httpx.Response(200, json=next(o for o in self.orders if o['id'] == wanted))
|
||||
@@ -306,7 +315,7 @@ class TinyStatusTests(FakeTinyCase):
|
||||
|
||||
def test_orders_are_filled_in_as_the_store_s_own(self):
|
||||
from datetime import date
|
||||
from app.tiny import PICKUP_CARRIER, RECEIPT_METHODS
|
||||
from app.tiny import CATEGORY, PICKUP_CARRIER, RECEIPT_METHODS
|
||||
thursday = date(2026, 9, 24)
|
||||
with mock.patch.dict(os.environ, {'FREIGHT_PRODUCTION_DAYS': '1'}):
|
||||
pickup = order_payload({**PICKUP, 'payment': {'method': 'pix'}}, 1, thursday, shipping=self.tiny.shipping)
|
||||
@@ -314,7 +323,7 @@ class TinyStatusTests(FakeTinyCase):
|
||||
self.assertEqual(pickup['transportador'], {'fretePorConta': 'R', 'id': PICKUP_CARRIER,
|
||||
'formaEnvio': {'id': 77}, 'formaFrete': {'id': 771}})
|
||||
self.assertEqual(pickup['dataPrevista'], '2026-09-25')
|
||||
self.assertEqual(pickup['pagamento'], {'formaRecebimento': {'id': RECEIPT_METHODS['pix']},
|
||||
self.assertEqual(pickup['pagamento'], {'categoria': {'id': CATEGORY}, 'formaRecebimento': {'id': RECEIPT_METHODS['pix']},
|
||||
'parcelas': [{'dias': 0, 'data': '2026-09-24', 'valor': 84.72, 'formaRecebimento': {'id': RECEIPT_METHODS['pix']}}]})
|
||||
# Delivery: the Correios contract's PAC or SEDEX, or Jadlog; the date in working days.
|
||||
for service, method, frete in (('pac', 78, 781), ('sedex', 78, 782), ('jadlog', 80, 801)):
|
||||
@@ -327,10 +336,32 @@ class TinyStatusTests(FakeTinyCase):
|
||||
self.assertEqual(sent['pagamento']['formaRecebimento'], {'id': RECEIPT_METHODS['card']})
|
||||
# Looked up once per service.
|
||||
self.assertEqual(self.calls.count(('GET', '/formas-envio/78')), 2)
|
||||
# A test order, or a carrier Tiny does not have: the order still goes, without them.
|
||||
# A test order, or a carrier Tiny does not have: the order still goes, without them,
|
||||
# in the store's category all the same, and with no seller: the team links one in Tiny.
|
||||
plain = order_payload(PAID, 1, thursday, shipping=self.tiny.shipping)
|
||||
self.assertNotIn('transportador', plain)
|
||||
self.assertNotIn('pagamento', plain)
|
||||
self.assertEqual(plain['pagamento'], {'categoria': {'id': CATEGORY}})
|
||||
self.assertNotIn('vendedor', plain)
|
||||
|
||||
def test_the_order_is_tagged_kanbandtf_once(self):
|
||||
first = self.tiny.deliver('k1', PAID)
|
||||
self.assertEqual(first['marcador'], 'KANBANDTF')
|
||||
tiny_id = self.orders[0]['id']
|
||||
self.assertEqual(self.tags[tiny_id], [{'descricao': 'KANBANDTF'}])
|
||||
# A second delivery finds the order and its tag, and adds nothing.
|
||||
self.tiny.deliver('k1', PAID)
|
||||
self.assertEqual(len(self.orders), 1)
|
||||
self.assertEqual(self.tags[tiny_id], [{'descricao': 'KANBANDTF'}])
|
||||
|
||||
def test_a_failed_tag_is_retried_without_a_second_order(self):
|
||||
self.refuse_tag = 1
|
||||
with self.assertRaises(TinyError):
|
||||
self.tiny.deliver('k1', PAID)
|
||||
self.assertEqual(len(self.orders), 1)
|
||||
retry = self.tiny.deliver('k1', PAID)
|
||||
self.assertEqual((retry['status'], retry['marcador']), ('already-created', 'KANBANDTF'))
|
||||
self.assertEqual(len(self.orders), 1)
|
||||
self.assertEqual(self.tags[self.orders[0]['id']], [{'descricao': 'KANBANDTF'}])
|
||||
|
||||
def test_pickup_forma_de_envio_is_found_by_name(self):
|
||||
from app.tiny import check, find_pickup
|
||||
@@ -539,6 +570,8 @@ class TinyProbeTests(FakeTinyCase):
|
||||
self.assertEqual(code, 0)
|
||||
self.assertIn('"numeroOrdemCompra": "DTF-TESTE-', text)
|
||||
self.assertIn('Nada foi criado', text)
|
||||
self.assertIn('"categoria": {', text)
|
||||
self.assertIn('Marcador: KANBANDTF', text)
|
||||
self.assertEqual(self.orders, [])
|
||||
self.assertTrue(all(method == 'GET' for method, _ in self.calls))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user