fulfillment.test.exs (2754B)
1 # Zenflows is designed to implement the Valueflows vocabulary, 2 # written and maintained by srfsh <info@dyne.org>. 3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>. 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU Affero General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU Affero General Public License for more details. 14 # 15 # You should have received a copy of the GNU Affero General Public License 16 # along with this program. If not, see <https://www.gnu.org/licenses/>. 17 18 defmodule ZenflowsTest.VF.Fulfillment do 19 use ZenflowsTest.Help.EctoCase, async: true 20 21 alias Zenflows.VF.Fulfillment 22 23 setup do 24 %{params: %{ 25 note: Factory.str("note"), 26 fulfilled_by_id: Factory.insert!(:economic_event).id, 27 fulfills_id: Factory.insert!(:commitment).id, 28 resource_quantity: %{ 29 has_unit_id: Factory.insert!(:unit).id, 30 has_numerical_value: Factory.decimal(), 31 }, 32 effort_quantity: %{ 33 has_unit_id: Factory.insert!(:unit).id, 34 has_numerical_value: Factory.decimal(), 35 }, 36 }} 37 end 38 39 @tag skip: "TODO: fix events in factory" 40 test "create Fulfillment", %{params: params} do 41 assert {:ok, %Fulfillment{} = fulf} = 42 params 43 |> Fulfillment.changeset() 44 |> Repo.insert() 45 46 assert fulf.note == params.note 47 assert fulf.fulfilled_by_id == params.fulfilled_by_id 48 assert fulf.fulfills_id == params.fulfills_id 49 assert fulf.resource_quantity_has_unit_id == params.resource_quantity.has_unit_id 50 assert fulf.resource_quantity_has_numerical_value == params.resource_quantity.has_numerical_value 51 assert fulf.effort_quantity_has_unit_id == params.effort_quantity.has_unit_id 52 assert fulf.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value 53 end 54 55 @tag skip: "TODO: fix events in factory" 56 test "update Fulfillment", %{params: params} do 57 assert {:ok, %Fulfillment{} = fulf} = 58 :fulfillment 59 |> Factory.insert!() 60 |> Fulfillment.changeset(params) 61 |> Repo.update() 62 63 assert fulf.note == params.note 64 assert fulf.fulfilled_by_id == params.fulfilled_by_id 65 assert fulf.fulfills_id == params.fulfills_id 66 assert fulf.resource_quantity_has_unit_id == params.resource_quantity.has_unit_id 67 assert fulf.resource_quantity_has_numerical_value == params.resource_quantity.has_numerical_value 68 assert fulf.effort_quantity_has_unit_id == params.effort_quantity.has_unit_id 69 assert fulf.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value 70 end 71 end