commit 639dce9780608bd01b764d6fb09094f70a0d499c
parent fff09db1a0ed0a4d4ed84d6afbd266dc067c47b4
Author: srfsh <dev@srf.sh>
Date: Tue, 16 Aug 2022 17:29:24 +0300
Zenflows{Test,}: tiny fixes
I think my editor gone mad, idk.
I swear I published these changes.
Diffstat:
6 files changed, 26 insertions(+), 196 deletions(-)
diff --git a/src/zenflows/gql/schema.ex b/src/zenflows/gql/schema.ex
@@ -56,15 +56,15 @@ import_types VF.ProductBatch.Type
import_types VF.EconomicResource.Type
import_types VF.EconomicEvent.Type
#import_types VF.Appreciation.Type
-#import_types VF.Intent.Type
+import_types VF.Intent.Type
#import_types VF.Commitment.Type
#import_types VF.Fulfillment.Type
#import_types VF.EventOrCommitment.Type
#import_types VF.Satisfaction.Type
#import_types VF.Claim.Type
#import_types VF.Settlement.Type
-#import_types VF.Proposal.Type
-#import_types VF.ProposedIntent.Type
+import_types VF.Proposal.Type
+import_types VF.ProposedIntent.Type
#import_types VF.ProposedTo.Type
query do
@@ -102,15 +102,14 @@ query do
import_fields :query_economic_resource
import_fields :query_economic_event
#import_fields :query_appreciation
- #import_fields :query_intent
+ import_fields :query_intent
#import_fields :query_commitment
#import_fields :query_fulfillment
#import_fields :query_event_or_commitment
#import_fields :query_satisfaction
#import_fields :query_claim
#import_fields :query_settlement
- #import_fields :query_proposal
- #import_fields :query_proposed_intent
+ import_fields :query_proposal
#import_fields :query_proposed_to
end
@@ -150,15 +149,15 @@ mutation do
import_fields :mutation_economic_resource
import_fields :mutation_economic_event
#import_fields :mutation_appreciation
- #import_fields :mutation_intent
+ import_fields :mutation_intent
#import_fields :mutation_commitment
#import_fields :mutation_fulfillment
#import_fields :mutation_event_or_commitment
#import_fields :mutation_satisfaction
#import_fields :mutation_claim
#import_fields :mutation_settlement
- #import_fields :mutation_proposal
- #import_fields :mutation_proposed_intent
+ import_fields :mutation_proposal
+ import_fields :mutation_proposed_intent
#import_fields :mutation_proposed_to
end
diff --git a/src/zenflows/vf/proposal/type.ex b/src/zenflows/vf/proposal/type.ex
@@ -35,6 +35,7 @@ create commitments; commonly seen in a price list or e-commerce.
"""
@created "The date and time the proposal was created."
@eligible_location "The location at which this proposal is eligible."
+@eligible_location_id "(`SpatialThing`) #{@eligible_location}"
@desc """
Published requests or offers, sometimes with what is expected in return.
@@ -61,10 +62,16 @@ object :proposal do
field :inserted_at, :datetime, name: "created"
@desc @eligible_location
- field :eligible_location, resolve: &Resolv.eligible_location/3
+ field :eligible_location, :spatial_thing, resolve: &Resolv.eligible_location/3
field :publishes, list_of(non_null(:proposed_intent)),
resolve: &Resolv.publishes/3
+
+ field :primary_intents, list_of(non_null(:intent)),
+ resolve: &Resolv.primary_intents/3
+
+ field :reciprocal_intents, list_of(non_null(:intent)),
+ resolve: &Resolv.reciprocal_intents/3
end
object :proposal_response do
@@ -97,8 +104,8 @@ input_object :proposal_create_params do
@desc @unit_based
field :unit_based, :boolean
- @desc "(`SpatialThing`) #{@eligible_location}"
- field :eligible_location_id, name: "eligible_location"
+ @desc @eligible_location_id
+ field :eligible_location_id, :id, name: "eligible_location"
end
input_object :proposal_update_params do
@@ -119,8 +126,8 @@ input_object :proposal_update_params do
@desc @unit_based
field :unit_based, :boolean
- @desc "(`SpatialThing`) #{@eligible_location}"
- field :eligible_location_id, name: "eligible_location"
+ @desc @eligible_location_id
+ field :eligible_location_id, :id, name: "eligible_location"
end
object :query_proposal do
diff --git a/src/zenflows/vf/proposed_intent/type.ex b/src/zenflows/vf/proposed_intent/type.ex
@@ -37,7 +37,10 @@ object :proposed_intent do
field :reciprocal, non_null(:boolean)
@desc "The published proposal which this intent is part of."
- field :published_in, non_null(proposal)
+ field :published_in, non_null(:proposal), resolve: &Resolv.published_in/3
+
+ @desc "The intent which is part of this published proposal."
+ field :publishes, non_null(:intent), resolve: &Resolv.publishes/3
end
object :proposed_intent_response do
diff --git a/test/vf/agreement/domain.test.exs b/test/vf/agreement/domain.test.exs
@@ -49,7 +49,7 @@ describe "create/1" do
assert agreem.note == params.note
end
- test "with bad params: doesn't create an" do
+ test "with bad params: doesn't create an Agreement" do
assert {:error, %Changeset{}} = Domain.create(%{})
end
end
diff --git a/test/vf/intent.test.exs b/test/vf/intent.test.exs
@@ -1,179 +0,0 @@
-# Zenflows is designed to implement the Valueflows vocabulary,
-# written and maintained by srfsh <info@dyne.org>.
-# Copyright (C) 2021-2022 Dyne.org foundation <foundation@dyne.org>.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-defmodule ZenflowsTest.VF.Intent do
-use ZenflowsTest.Help.EctoCase, async: true
-
-alias Ecto.Changeset
-alias Zenflows.VF.Intent
-
-setup do
- %{params: %{
- name: Factory.uniq("name"),
- action_id: Factory.build(:action_id),
- input_of_id: Factory.insert!(:process).id,
- output_of_id: Factory.insert!(:process).id,
- resource_classified_as: Factory.uniq_list("uri"),
- resource_conforms_to_id: Factory.insert!(:resource_specification).id,
- resource_inventoried_as_id: Factory.insert!(:economic_resource).id,
- resource_quantity: %{
- has_unit_id: Factory.insert!(:unit).id,
- has_numerical_value: Factory.float(),
- },
- effort_quantity: %{
- has_unit_id: Factory.insert!(:unit).id,
- has_numerical_value: Factory.float(),
- },
- available_quantity: %{
- has_unit_id: Factory.insert!(:unit).id,
- has_numerical_value: Factory.float(),
- },
- at_location_id: Factory.insert!(:spatial_thing).id,
- has_beginning: DateTime.utc_now(),
- has_end: DateTime.utc_now(),
- has_point_in_time: DateTime.utc_now(),
- due: DateTime.utc_now(),
- finished: Factory.bool(),
- image: Factory.img(),
- note: Factory.uniq("note"),
- # in_scope_of_id:
- agreed_in: Factory.uniq("uri"),
- }}
-end
-
-describe "create Intent" do
- test "with only :provider", %{params: params} do
- params = Map.put(params, :provider_id, Factory.insert!(:agent).id)
-
- assert {:ok, %Intent{} = int} =
- params
- |> Intent.chgset()
- |> Repo.insert()
-
- assert int.name == params.name
- assert int.action_id == params.action_id
- assert int.provider_id == params.provider_id
- assert int.receiver_id == nil
- assert int.input_of_id == params.input_of_id
- assert int.output_of_id == params.output_of_id
- assert int.resource_classified_as == params.resource_classified_as
- assert int.resource_conforms_to_id == params.resource_conforms_to_id
- assert int.resource_inventoried_as_id == params.resource_inventoried_as_id
- assert int.resource_quantity_has_unit_id == params.resource_quantity.has_unit_id
- assert int.resource_quantity_has_numerical_value == params.resource_quantity.has_numerical_value
- assert int.effort_quantity_has_unit_id == params.effort_quantity.has_unit_id
- assert int.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value
- assert int.available_quantity_has_unit_id == params.available_quantity.has_unit_id
- assert int.available_quantity_has_numerical_value == params.available_quantity.has_numerical_value
- assert int.at_location_id == params.at_location_id
- assert int.has_beginning == params.has_beginning
- assert int.has_end == params.has_end
- assert int.has_point_in_time == params.has_point_in_time
- assert int.due == params.due
- assert int.finished == params.finished
- assert int.image == params.image
- assert int.note == params.note
- # assert in_scope_of_id
- assert int.agreed_in == params.agreed_in
- end
-
- test "with only :receiver", %{params: params} do
- params = Map.put(params, :receiver_id, Factory.insert!(:agent).id)
-
- assert {:ok, %Intent{} = int} =
- params
- |> Intent.chgset()
- |> Repo.insert()
-
- assert int.name == params.name
- assert int.action_id == params.action_id
- assert int.provider_id == nil
- assert int.receiver_id == params.receiver_id
- assert int.input_of_id == params.input_of_id
- assert int.output_of_id == params.output_of_id
- assert int.resource_classified_as == params.resource_classified_as
- assert int.resource_conforms_to_id == params.resource_conforms_to_id
- assert int.resource_inventoried_as_id == params.resource_inventoried_as_id
- assert int.resource_quantity_has_unit_id == params.resource_quantity.has_unit_id
- assert int.resource_quantity_has_numerical_value == params.resource_quantity.has_numerical_value
- assert int.effort_quantity_has_unit_id == params.effort_quantity.has_unit_id
- assert int.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value
- assert int.available_quantity_has_unit_id == params.available_quantity.has_unit_id
- assert int.available_quantity_has_numerical_value == params.available_quantity.has_numerical_value
- assert int.at_location_id == params.at_location_id
- assert int.has_beginning == params.has_beginning
- assert int.has_end == params.has_end
- assert int.has_point_in_time == params.has_point_in_time
- assert int.due == params.due
- assert int.finished == params.finished
- assert int.image == params.image
- assert int.note == params.note
- # assert in_scope_of_id
- assert int.agreed_in == params.agreed_in
- end
-
- test "with both :provider and :receiver", %{params: params} do
- params =
- params
- |> Map.put(:provider_id, Factory.insert!(:agent).id)
- |> Map.put(:receiver_id, Factory.insert!(:agent).id)
-
- assert {:error, %Changeset{errors: errs}} =
- params
- |> Intent.chgset()
- |> Repo.insert()
-
- assert {:ok, _} = Keyword.fetch(errs, :provider_id)
- assert {:ok, _} = Keyword.fetch(errs, :receiver_id)
- end
-end
-
-test "update Intent", %{params: params} do
- old = Factory.insert!(:intent)
-
- assert {:ok, %Intent{} = new} =
- old
- |> Intent.chgset(params)
- |> Repo.update()
-
- assert new.name == params.name
- assert new.action_id == params.action_id
- assert new.provider_id == old.provider_id
- assert new.receiver_id == old.receiver_id
- assert new.input_of_id == params.input_of_id
- assert new.output_of_id == params.output_of_id
- assert new.resource_classified_as == params.resource_classified_as
- assert new.resource_conforms_to_id == params.resource_conforms_to_id
- assert new.resource_inventoried_as_id == params.resource_inventoried_as_id
- assert new.resource_quantity_has_unit_id == params.resource_quantity.has_unit_id
- assert new.resource_quantity_has_numerical_value == params.resource_quantity.has_numerical_value
- assert new.effort_quantity_has_unit_id == params.effort_quantity.has_unit_id
- assert new.effort_quantity_has_numerical_value == params.effort_quantity.has_numerical_value
- assert new.available_quantity_has_unit_id == params.available_quantity.has_unit_id
- assert new.available_quantity_has_numerical_value == params.available_quantity.has_numerical_value
- assert new.at_location_id == params.at_location_id
- assert new.has_beginning == params.has_beginning
- assert new.has_end == params.has_end
- assert new.has_point_in_time == params.has_point_in_time
- assert new.due == params.due
- assert new.finished == params.finished
- assert new.image == params.image
- assert new.note == params.note
- # assert in_scope_of_id
- assert new.agreed_in == params.agreed_in
-end
-end
diff --git a/test/vf/intent/domain.test.exs b/test/vf/intent/domain.test.exs
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-defmodule ZenflowsTest.VF.Intent do
+defmodule ZenflowsTest.VF.Intent.Domain do
use ZenflowsTest.Help.EctoCase, async: true
alias Ecto.Changeset