Skip to content

Commit

Permalink
Add tests of getting/setting user demands
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Feb 8, 2024
1 parent 8425005 commit 4b597f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions core/src/create.jl
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ function User(db::DB, config::Config)::User

node_ids = NodeID.(node_ids)

user = User(
return User(
node_ids,
active,
demand,
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions core/test/allocation_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4b597f7

Please sign in to comment.