http sender drops reply keys no output port declares

A sender without outputs no longer fails on a {"status": "ok"} reply.
This commit is contained in:
2026-10-15 09:57:51 +02:00
parent e6afc23952
commit 0562753d9c
3 changed files with 34 additions and 5 deletions
+25 -1
View File
@@ -2,8 +2,10 @@
import asyncio
import httpx
from fluksio.flow.messages import DType, MessageSpec
from fluksio.flow.nodes import MqttNode
from fluksio.flow.nodes import HttpNode, MqttNode
from fluksio.flow.nodes.http import close_shared_client, shared_client
@@ -20,6 +22,28 @@ def test_http_senders_share_one_pooled_client():
close_shared_client()
def test_an_http_reply_keeps_only_the_declared_ports(monkeypatch):
"""A `status` beside the value is the endpoint's business, not an error."""
reply = {"temp": 21.5, "status": "ok"}
client = httpx.Client(
transport=httpx.MockTransport(lambda _: httpx.Response(200, json=reply))
)
monkeypatch.setattr("fluksio.flow.nodes.http.shared_client", lambda: client)
def sender(*provides: MessageSpec) -> HttpNode:
node = HttpNode(
requires=[MessageSpec(name="setpoint", dtype=DType.FLOAT)],
provides=provides,
params={"url": "http://thermostat.test/set"},
)
node.assign_flow("heating", "thermostat")
return node
temp = MessageSpec(name="temp", dtype=DType.FLOAT)
assert sender(temp).execute({"heating.setpoint": 21.0}) == {"heating.temp": 21.5}
assert sender().execute({"heating.setpoint": 21.0}) is None
def _sender() -> MqttNode:
node = MqttNode(
requires=[MessageSpec(name="setpoint", port="setpoint", dtype=DType.FLOAT)],