From 4b597f7ae611c623f368f02eab60d188a1b4cf04 Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Thu, 8 Feb 2024 13:36:49 +0100 Subject: [PATCH] Add tests of getting/setting user demands --- core/src/create.jl | 4 +--- core/test/allocation_test.jl | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/create.jl b/core/src/create.jl index a9b64852e..499d42b8f 100644 --- a/core/src/create.jl +++ b/core/src/create.jl @@ -747,7 +747,7 @@ function User(db::DB, config::Config)::User node_ids = NodeID.(node_ids) - user = User( + return User( node_ids, active, demand, @@ -759,8 +759,6 @@ function User(db::DB, config::Config)::User priorities, record, ) - - return user end function Subgrid(db::DB, config::Config, basin::Basin)::Subgrid diff --git a/core/test/allocation_test.jl b/core/test/allocation_test.jl index 35632e181..5ca7074d8 100644 --- a/core/test/allocation_test.jl +++ b/core/test/allocation_test.jl @@ -39,6 +39,12 @@ @test allocated[1] ≈ [0.0, 0.5] @test allocated[2] ≈ [4.0, 0.0] @test allocated[3] ≈ [0.0, 0.0] + + # Test getting and setting user demands + (; user) = p + Ribasim.set_user_demand!(user, NodeID(11), 2, Float64(π)) + @test user.demand[4] ≈ π + @test Ribasim.get_user_demand(user, NodeID(11), 2) ≈ π end @testitem "Allocation objective types" begin