From 5b3b85dfef20e08625100c8a8b7102a44ba3c51b Mon Sep 17 00:00:00 2001 From: Bart de Koning <74617371+SouthEndMusic@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:54:08 +0100 Subject: [PATCH] test is_flow_constraining (#1182) Fixes https://github.com/Deltares/Ribasim/issues/1128. I'm pretty sure this wasn't an issue to begin with, since `LinearResistance` was automatically detected as a flow restricting node now that the struct has a `max_flow_rate` field. I just added a test for the `is_flow_constraining` function to be sure. --- core/test/utils_test.jl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/test/utils_test.jl b/core/test/utils_test.jl index 6c23e7558..f7e3b6311 100644 --- a/core/test/utils_test.jl +++ b/core/test/utils_test.jl @@ -299,3 +299,20 @@ end 2.0, ) === 1.0 end + +@testitem "constraints_from_nodes" begin + toml_path = normpath(@__DIR__, "../../generated_testmodels/basic/ribasim.toml") + @test ispath(toml_path) + model = Ribasim.Model(toml_path) + (; p) = model.integrator + constraining_types = (:pump, :outlet, :linear_resistance) + + for type in Ribasim.nodefields(p) + node = getfield(p, type) + if type in constraining_types + @test Ribasim.is_flow_constraining(node) + else + @test !Ribasim.is_flow_constraining(node) + end + end +end