Merge Critical Corrections plan 002: two API processes, worker drains its queue
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 6m11s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 59s
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 6m11s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 59s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
27
tests/test_worker_drain.py
Normal file
27
tests/test_worker_drain.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""The outbox worker drains a backlog instead of one job per second (item 9).
|
||||
|
||||
Run from the repository root: python3 -m unittest tests.test_worker_drain -v.
|
||||
The worker imports psycopg and boto3, so a host without the API image's
|
||||
dependencies cannot import it; CI runs this in the api container.
|
||||
"""
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from app import worker
|
||||
|
||||
|
||||
class WorkerDrainTest(unittest.TestCase):
|
||||
def test_drain_stops_when_the_queue_is_empty(self):
|
||||
with mock.patch.object(worker, 'tick',
|
||||
side_effect=[True, True, True, False]) as tick:
|
||||
worker.drain()
|
||||
self.assertEqual(tick.call_count, 4)
|
||||
|
||||
def test_drain_stops_at_the_limit(self):
|
||||
with mock.patch.object(worker, 'tick', return_value=True) as tick:
|
||||
worker.drain()
|
||||
self.assertEqual(tick.call_count, 50)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user