Github user mxmrlv commented on a diff in the pull request:
https://github.com/apache/incubator-ariatosca/pull/46#discussion_r95078094
--- Diff: tests/storage/test_model_storage.py ---
@@ -144,3 +152,77 @@ def test_application_storage_factory():
assert storage.execution
release_sqlite_storage(storage)
+
+
+def test_relationship_model_ordering(context):
+ deployment =
context.model.deployment.get_by_name(models.DEPLOYMENT_NAME)
+ source_node =
context.model.node.get_by_name(models.DEPENDENT_NODE_NAME)
+ source_node_instance = context.model.node_instance.get_by_name(
+ models.DEPENDENT_NODE_INSTANCE_NAME)
+ new_node = model.Node(
+ name='new_node',
+ type='test_node_type',
+ type_hierarchy=[],
+ number_of_instances=1,
+ planned_number_of_instances=1,
+ deploy_number_of_instances=1,
+ properties={},
+ operations=dict((key, {}) for key in operations.NODE_OPERATIONS),
+ min_number_of_instances=1,
+ max_number_of_instances=1,
+ deployment=deployment
+ )
+ new_relationship = model.Relationship(
+ source_node=source_node,
+ target_node=new_node,
+ source_interfaces={},
+ source_operations=dict((key, {}) for key in
operations.RELATIONSHIP_OPERATIONS),
+ target_interfaces={},
+ target_operations=dict((key, {}) for key in
operations.RELATIONSHIP_OPERATIONS),
+ type='rel_type',
+ type_hierarchy=[],
+ properties={},
+ )
+ new_node_instance = model.NodeInstance(
+ name='new_node_instance',
+ runtime_properties={},
+ version=None,
+ node=new_node,
+ state='',
+ scaling_groups=[]
+ )
+ new_relationship_instance = model.RelationshipInstance(
+ relationship=new_relationship,
+ target_node_instance=new_node_instance,
+ source_node_instance=source_node_instance,
+ )
+
+ context.model.node.put(new_node)
+ context.model.node_instance.put(new_node_instance)
+ context.model.relationship.put(new_relationship)
+ context.model.relationship_instance.put(new_relationship_instance)
+
+ assert len(source_node.outbound_relationships) == 2
+ assert len(source_node_instance.outbound_relationship_instances) == 2
+ first_rel, second_rel = source_node.outbound_relationships
+ first_rel_instance, second_rel_instance =
source_node_instance.outbound_relationship_instances
+
+ assert first_rel.position == first_rel_instance.position == 0
+ assert second_rel.position == second_rel_instance.position == 0
+
+ reversed_relationships =
list(reversed(source_node.outbound_relationships))
+ reversed_relationship_instances = list(
+ reversed(source_node_instance.outbound_relationship_instances))
+
+ assert source_node.outbound_relationships != reversed_relationships
+ assert source_node_instance.outbound_relationship_instances !=
reversed_relationship_instances
+
+ source_node.outbound_relationships[:] = reversed_relationships
--- End diff --
inbound aswell
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---