diff --git a/core/test/utils_test.jl b/core/test/utils_test.jl index 009105d88..1ffe78c88 100644 --- a/core/test/utils_test.jl +++ b/core/test/utils_test.jl @@ -286,25 +286,27 @@ end end @testitem "constraints_from_nodes" begin + using Ribasim: Model, snake_case, nodetypes, is_flow_constraining + toml_path = normpath(@__DIR__, "../../generated_testmodels/basic/ribasim.toml") @test ispath(toml_path) - model = Ribasim.Model(toml_path) + model = Model(toml_path) (; p) = model.integrator constraining_types = (:Pump, :Outlet, :LinearResistance) - for type in Ribasim.nodetypes + for type in nodetypes type == :Terminal && continue # has no parameter field node = getfield(p, snake_case(type)) if type in constraining_types - @test Ribasim.is_flow_constraining(node) + @test is_flow_constraining(node) else - @test !Ribasim.is_flow_constraining(node) + @test !is_flow_constraining(node) end end end @testitem "Node types" begin - using Ribasim: nodetypes, NodeType, Parameters, AbstractParameterNode + using Ribasim: nodetypes, NodeType, Parameters, AbstractParameterNode, snake_case @test Set(nodetypes) == Set([ :Terminal, diff --git a/core/test/validation_test.jl b/core/test/validation_test.jl index cae8d52e5..dfd928b3e 100644 --- a/core/test/validation_test.jl +++ b/core/test/validation_test.jl @@ -60,7 +60,7 @@ end "A Q(h) relationship for TabulatedRatingCurve #2 from the time table has repeated levels, this can not be interpolated." end -@testitem "Neighbor count validation" skip = true begin +@testitem "Neighbor count validation" begin using Graphs: DiGraph using Logging using MetaGraphsNext: MetaGraph @@ -91,19 +91,9 @@ end set_edge_metadata!(NodeID(:Pump, 6), NodeID(:Basin, 2), EdgeType.flow) set_edge_metadata!(NodeID(:FractionalFlow, 5), NodeID(:Pump, 6), EdgeType.control) - pump = Ribasim.Pump( - NodeID.(:Pump, [1, 6]), - [true, true], - [0.0, 0.0], - [0.0, 0.0], - [1.0, 1.0], - Dict{Tuple{NodeID, String}, NamedTuple}(), - falses(2), - ) - logger = TestLogger() with_logger(logger) do - @test !Ribasim.valid_n_neighbors(pump, graph) + @test !Ribasim.valid_n_neighbors(:Pump, graph) end @test length(logger.logs) == 3 @@ -120,15 +110,9 @@ end set_edge_metadata!(NodeID(:FractionalFlow, 5), NodeID(:Basin, 3), EdgeType.flow) set_edge_metadata!(NodeID(:FractionalFlow, 5), NodeID(:Basin, 4), EdgeType.flow) - fractional_flow = Ribasim.FractionalFlow( - [NodeID(:FractionalFlow, 5)], - [1.0], - Dict{Tuple{NodeID, String}, NamedTuple}(), - ) - logger = TestLogger(; min_level = Debug) with_logger(logger) do - @test !Ribasim.valid_n_neighbors(fractional_flow, graph) + @test !Ribasim.valid_n_neighbors(:FractionalFlow, graph) end @test length(logger.logs) == 2 @@ -209,7 +193,7 @@ end "PID listened Basin #5 is not on either side of controlled Pump #2." end -@testitem "FractionalFlow validation" skip = true begin +@testitem "FractionalFlow validation" begin import SQLite using Logging using Ribasim: NodeID @@ -224,7 +208,7 @@ end db_path = Ribasim.input_path(config, config.database) db = SQLite.DB(db_path) graph = Ribasim.create_graph(db, config, [1, 1]) - fractional_flow = Ribasim.FractionalFlow(db, config) + fractional_flow = Ribasim.FractionalFlow(db, config, graph) logger = TestLogger() with_logger(logger) do diff --git a/python/ribasim_testmodels/ribasim_testmodels/invalid.py b/python/ribasim_testmodels/ribasim_testmodels/invalid.py index 87ea383d0..031111c47 100644 --- a/python/ribasim_testmodels/ribasim_testmodels/invalid.py +++ b/python/ribasim_testmodels/ribasim_testmodels/invalid.py @@ -112,6 +112,10 @@ def invalid_fractional_flow_model() -> Model: model.basin[2], model.fractional_flow[8], ) + model.edge.add( + model.fractional_flow[8], + model.terminal[5], + ) return model