Files
AlphaPulse/backend/tests/conftest.py
T
eezd 8766e829f9
Development CI / check-and-build (push) Successful in 3m3s
GitHub Git mirror / mirror (push) Successful in 6s
Development CI / deploy-development (push) Successful in 2m29s
Coordinate AI retries and recover shared provider outages
Retry transient requests after one and three minutes and coordinate provider recovery across processes with bounded probe intervals. Preserve completed results when recovery bookkeeping fails, keep concurrent failure accounting accurate, and expose retry state in the UI.
2026-11-06 16:25:16 +08:00

24 lines
1.1 KiB
Python

import pytest
@pytest.fixture
def trading(monkeypatch):
# 测试只替换 I/O 边界,不读取项目凭证,也不连接线上数据库或 Redis。
for key, value in {
"DATABASE_URL": "postgresql+asyncpg://test:[email protected]/test",
"REDIS_URL": "redis://127.0.0.1:1/0", "JWT_SECRET": "test-only",
"ADMIN_USERNAME": "test", "SECRET_ENCRYPTION_KEY": "MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA=",
}.items():
monkeypatch.setenv(key, value)
from alphapulse.trading import executor
from unittest.mock import AsyncMock
from alphapulse.ai import llm, recovery
class HealthyGate:
async def call(self, operation, request_id='', epoch=-1):
return {'epoch': 0, 'level': 0, 'retry_at': 0, 'probe': False, 'admitted': True, 'now': 0}
monkeypatch.setattr(llm, 'recovery_gate', lambda _: HealthyGate())
monkeypatch.setattr(recovery, 'mark_waiting', AsyncMock())
monkeypatch.setattr(recovery, 'clear_waiting', AsyncMock())
monkeypatch.setattr(recovery, 'waiting_count', AsyncMock(return_value=0))
return executor