fix: deleting a cancelled order keeps its Tiny cancellation, and production without the real Tiny holds the sends
Some checks failed
Some checks failed
- Deleting an order removed its Tiny events, delivered or not: cancelled and deleted before the worker sent it (or with Tiny down), the order stayed open in Tiny. A real order's events now stay; only a test order's go. - With TINY_ADAPTER missing from the production stack, the simulator marked paid orders delivered with made-up receipts, and they had to be queued again by hand. Production now holds the sends (the outbox retries and Sentry is told); with the real Tiny back, the worker sends them at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -53,5 +53,29 @@ class RefusedDeliveryTest(unittest.TestCase):
|
||||
self.assertEqual(self.tick_with(9, limit).call_count, 1)
|
||||
|
||||
|
||||
class HeldTinyTest(unittest.TestCase):
|
||||
"""Production without the real Tiny holds the sends and tells Sentry; the
|
||||
simulator marked real orders delivered with made-up receipts."""
|
||||
def test_production_without_the_real_tiny_holds(self):
|
||||
self.assertIsInstance(worker.tiny_adapter('fake', 'production'), worker.HeldTiny)
|
||||
self.assertIsInstance(worker.tiny_adapter(None, 'production'), worker.HeldTiny)
|
||||
self.assertIsInstance(worker.tiny_adapter('fake', 'local'), worker.FakeTiny)
|
||||
|
||||
def test_a_held_send_stays_undelivered_and_is_reported(self):
|
||||
job = {'id': 1, 'provider': 'tiny', 'event_key': 'o:paid:tiny', 'payload': {}, 'attempts': 0}
|
||||
conn = mock.MagicMock()
|
||||
conn.execute.return_value.fetchone.return_value = job
|
||||
connect = mock.MagicMock()
|
||||
connect.return_value.__enter__.return_value = conn
|
||||
with mock.patch.object(worker, 'connect', connect), \
|
||||
mock.patch.dict(worker.adapters, {'tiny': worker.HeldTiny()}), \
|
||||
mock.patch.object(worker.logging, 'error') as error:
|
||||
worker.tick()
|
||||
updates = [call.args[0] for call in conn.execute.call_args_list[1:]]
|
||||
self.assertTrue(updates and 'delivered_at=now()' not in updates[0] and 'last_error' in updates[0], updates)
|
||||
self.assertEqual(conn.execute.call_args_list[1].args[1][0], worker.HELD)
|
||||
self.assertEqual(error.call_count, 1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user