Preserve calendar failure cooldown across worker restarts
GitHub Git mirror / mirror (push) Successful in 5s
Development CI / check-and-build (push) Successful in 2m14s
Development CI / deploy-development (push) Failing after 8s

This commit is contained in:
eezd committed 2026-11-05 13:32:19 +08:00
1 parent d0c2beb9b3
commit 655813d4d9
3 files changed
+29 -2

No files matched your search

+19
View File
@@ -249,3 +249,22 @@ def test_dol_lagging_index_uses_only_expected_official_archive(trading):
await worker.http.aclose()
await worker.bls.aclose()
asyncio.run(run())
def test_restart_honors_persisted_source_pause(trading, monkeypatch):
from alphapulse.calendar import worker as module
session = AsyncMock()
session.__aenter__.return_value = session
session.scalars.return_value = [SimpleNamespace(code='adp', enabled=True, paused_until=datetime.now(UTC) + timedelta(hours=1))]
session.get.return_value = None
monkeypatch.setattr(module, 'SessionLocal', lambda: session)
async def run():
worker = module.CalendarWorker()
worker.fetch = AsyncMock(side_effect=httpx.ConnectError('offline'))
try:
await worker.schedules()
assert all(call.args[0] != 'adp' for call in worker.fetch.await_args_list)
finally:
await worker.http.aclose()
await worker.bls.aclose()
asyncio.run(run())