fix(account-snapshot): treat timeout/http5xx as transient fallback failures
Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
co-authored by
genichin
parent
084e05a97d
commit
e3142017c9
@@ -75,10 +75,11 @@ def test_refresh_persists_independent_holdings_and_cash_capture_times():
|
||||
assert second.cash_captured_at == first.cash_captured_at
|
||||
|
||||
|
||||
def test_sell_falls_back_only_for_transport_failure_and_within_sell_ttl():
|
||||
@pytest.mark.parametrize("error_code", ["transport_failed", "timeout", "http_5xx"])
|
||||
def test_sell_falls_back_for_transient_live_read_failures_within_sell_ttl(error_code):
|
||||
broker, _, service, now = _wire()
|
||||
assert service.refresh()
|
||||
broker.balance_error = "transport_failed"
|
||||
broker.balance_error = error_code
|
||||
now[0] += timedelta(seconds=601)
|
||||
|
||||
assert service.holdings_for_sell() == [BalanceItem("005930", 2)]
|
||||
@@ -126,6 +127,16 @@ def test_buy_guard_accounts_for_existing_pending_cash_and_never_renews_age():
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("error_code", ["transport_failed", "timeout", "http_5xx"])
|
||||
def test_buy_guard_keeps_existing_cash_snapshot_on_transient_cash_refresh_failure(error_code):
|
||||
broker, _, service, _ = _wire()
|
||||
assert service.refresh()
|
||||
broker.cash_error = error_code
|
||||
|
||||
assert service.refresh() is False
|
||||
assert service.buy_guard(qty=2, limit_price=100_000) is None
|
||||
|
||||
|
||||
def test_current_account_hash_is_required_on_every_consume():
|
||||
broker, _, service, _ = _wire()
|
||||
assert service.refresh()
|
||||
|
||||
Reference in New Issue
Block a user