zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

satisfaction.test.exs (2780B)


      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.Satisfaction do
     19 use ZenflowsTest.Help.EctoCase, async: true
     20 
     21 alias Zenflows.VF.Satisfaction
     22 
     23 setup do
     24 	%{params: %{
     25 		note: Factory.str("note"),
     26 		satisfied_by_event_id: Factory.insert!(:economic_event).id,
     27 		satisfies_id: Factory.insert!(:intent).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 Satisfaction", %{params: params} do
     41 	assert {:ok, %Satisfaction{} = satis} =
     42 		params
     43 		|> Satisfaction.changeset()
     44 		|> Repo.insert()
     45 
     46 	assert satis.satisfied_by_id == params.satisfied_by_id
     47 	assert satis.satisfies_id == params.satisfies_id
     48 	assert satis.resource_quantity_has_unit_id == params.resource_quantity.has_unit_id
     49 	assert satis.resource_quantity_has_numerical_value == params.resource_quantity.has_numerical_value
     50 	assert satis.effort_quantity_has_unit_id == params.effort_quantity.has_unit_id
     51 	assert satis.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value
     52 	assert satis.note == params.note
     53 end
     54 
     55 @tag skip: "TODO: fix events in factory"
     56 test "update Satisfaction", %{params: params} do
     57 	assert {:ok, %Satisfaction{} = satis} =
     58 		Factory.insert!(:satisfaction)
     59 		|> Satisfaction.changeset(params)
     60 		|> Repo.update()
     61 
     62 	assert satis.satisfied_by_id == params.satisfied_by_id
     63 	assert satis.satisfies_id == params.satisfies_id
     64 	assert satis.resource_quantity_has_unit_id == params.resource_quantity.has_unit_id
     65 	assert satis.resource_quantity_has_numerical_value == params.resource_quantity.has_numerical_value
     66 	assert satis.effort_quantity_has_unit_id == params.effort_quantity.has_unit_id
     67 	assert satis.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value
     68 	assert satis.note == params.note
     69 end
     70 end