fix strategy state persistence corrections
This commit is contained in:
@@ -332,6 +332,33 @@ def test_ac7_warn_store_failure_fail_closed():
|
||||
assert "excluded_slots" in resp.payload
|
||||
|
||||
|
||||
def test_ac23_exclusion_precedes_broker_and_strategy_state_readers():
|
||||
repo = InMemorySlotRepository()
|
||||
svc = SlotService(repo)
|
||||
warn_store = InMemoryReconcileWarningStore()
|
||||
slot = _make_holding_slot(repo, svc, portfolio_id="pf-A", symbol=SYM_A, qty=10)
|
||||
warn_store.set_warned(str(slot.slot_id), portfolio_id="pf-A", case_code="C")
|
||||
|
||||
class ExplodingReader:
|
||||
def holdings_for_slots_rpc(self):
|
||||
raise AssertionError("excluded slot reached broker reader")
|
||||
|
||||
class ExplodingStateStore:
|
||||
def get_for_slots(self, _slot_ids):
|
||||
raise AssertionError("excluded slot reached state reader")
|
||||
|
||||
handler = make_slots_rpc_handler(
|
||||
repo,
|
||||
instance_key=INSTANCE,
|
||||
warn_store=warn_store,
|
||||
broker_quantity_reader=ExplodingReader(),
|
||||
strategy_state_store=ExplodingStateStore(),
|
||||
)
|
||||
response = handler(_req(filter="holding")).payload
|
||||
assert response["slots"] == []
|
||||
assert response["excluded_slots"] == {"reconcile_quantity_mismatch": 1}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# AC-8: intent rejected if C-case warning set after last slots RPC (race)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -58,3 +58,14 @@ def test_operator_without_or_with_id_receives_full_map_without_watchdog_update()
|
||||
state = _call(handler, payload)["slots"][0]["strategy_state"]
|
||||
assert set(state) == {"instance-a", "instance-b"}
|
||||
assert watchdog.last_seen(str(slot.slot_id)) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("spy", ["false", "true", 1, [], {}])
|
||||
def test_non_boolean_spy_is_rejected_without_visibility_or_watchdog_update(spy):
|
||||
slot, _, watchdog, handler = _wire()
|
||||
payload = _call(handler, {"spy": spy})
|
||||
assert payload == {
|
||||
"slots": [], "available_slots": None, "degraded": False,
|
||||
"reason": "bad_request:spy", "message": "spy must be a boolean",
|
||||
}
|
||||
assert watchdog.last_seen(str(slot.slot_id)) is None
|
||||
|
||||
Reference in New Issue
Block a user