"""A node that loaded but is not working shows up as an issue on its flow. Health used to go nowhere: the connector reported it, the controller stored it, and no screen ever asked. These cover the derivation that closes that gap. """ from pathlib import Path from fluksio.flow.controller import FlowController, LoadedNode from fluksio.flow.store import FlowStore def a_controller(tmp_path: Path) -> FlowController: controller = FlowController(FlowStore(tmp_path / "flows")) controller.loaded["house.owm"] = LoadedNode( id="house.owm", flow="house", health="down", health_detail="ConnectionError: name resolution failed", ) return controller def test_a_down_node_is_an_issue_on_its_flow(tmp_path: Path) -> None: controller = a_controller(tmp_path) issues = controller.flow_issues("house") assert [issue.code for issue in issues] == ["node_unhealthy"] assert issues[0].node == "house.owm" assert "name resolution failed" in issues[0].message # Not advisory: the canvas has to mark the node. assert not issues[0].advisory assert controller.flow_issues("other") == [] def test_the_issue_clears_when_the_node_reports_itself_well(tmp_path: Path) -> None: controller = a_controller(tmp_path) controller.loaded["house.owm"].health = "ok" assert controller.flow_issues("house") == []