feat: gate_bus mask stash
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -33,3 +33,11 @@ class GateBus:
|
||||
raise GateCancelled()
|
||||
time.sleep(period)
|
||||
return cls.messages.pop(sid)
|
||||
|
||||
@classmethod
|
||||
def put_mask(cls, node_id, data):
|
||||
cls.masks[str(node_id)] = data
|
||||
|
||||
@classmethod
|
||||
def pop_mask(cls, node_id):
|
||||
return cls.masks.pop(str(node_id), None)
|
||||
|
||||
@@ -26,3 +26,13 @@ def test_arm_clears_stale_state():
|
||||
gb.GateBus.arm("1")
|
||||
assert "1" not in gb.GateBus.messages
|
||||
assert gb.GateBus.cancelled is False
|
||||
|
||||
def test_mask_stash_roundtrip():
|
||||
gb.GateBus.put_mask("9", b"PNGDATA")
|
||||
assert gb.GateBus.pop_mask("9") == b"PNGDATA"
|
||||
assert gb.GateBus.pop_mask("9") is None # popped
|
||||
|
||||
def test_arm_clears_mask():
|
||||
gb.GateBus.put_mask("9", b"x")
|
||||
gb.GateBus.arm("9")
|
||||
assert gb.GateBus.pop_mask("9") is None
|
||||
|
||||
Reference in New Issue
Block a user