fluksio.arrived(): a node can tell which inputs the wave behind it wrote, so a value written again unchanged is seen
This commit is contained in:
@@ -348,3 +348,34 @@ def test_a_consumer_of_only_quiet_producers_still_does_not_run():
|
||||
power.inject()
|
||||
|
||||
assert ran == []
|
||||
|
||||
|
||||
def test_a_node_hears_which_of_its_inputs_arrived():
|
||||
"""A value written again unchanged still arrives; one only in state does not.
|
||||
|
||||
The arbiter tells a spoken "on" over a light the scene already lit from
|
||||
the scene re-asserting itself this way, since the values are identical.
|
||||
"""
|
||||
from fluksio.flow.nodes.base import ARRIVED
|
||||
|
||||
heard = []
|
||||
|
||||
def arbiter(auto, manual, params):
|
||||
heard.append(ARRIVED.get())
|
||||
return {"command": manual}
|
||||
|
||||
node = make_node(
|
||||
"arbiter",
|
||||
"lights",
|
||||
arbiter,
|
||||
requires=[spec("auto", DType.BOOL), spec("manual", DType.BOOL)],
|
||||
provides=[spec("command", DType.BOOL)],
|
||||
)
|
||||
pipeline = Pipeline(nodes=[node])
|
||||
pipeline.state["lights.auto"] = True
|
||||
pipeline.state["lights.manual"] = True
|
||||
|
||||
pipeline.publish({"lights.manual": True})
|
||||
pipeline.publish({"lights.auto": True})
|
||||
|
||||
assert heard == [["manual"], ["auto"]]
|
||||
|
||||
Reference in New Issue
Block a user