ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: ARIA-116-Missing-type_hierarchy-in-relationship [Forced Update!]
Date Mon, 06 Mar 2017 08:54:55 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-105-integrate-modeling 5ceb14cd4 -> 24ad8ba1e (forced update)
  refs/heads/ARIA-116-Missing-type_hierarchy-in-relationship 347f8503a -> c1e7685a6 (forced
update)


ARIA-116-Missing-type_hierarchy-in-relationship


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c1e7685a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c1e7685a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c1e7685a

Branch: refs/heads/ARIA-116-Missing-type_hierarchy-in-relationship
Commit: c1e7685a6e9ef10d9a073b979d81e50909230bb8
Parents: dc18c1d
Author: max-orlov <maxim@gigaspaces.com>
Authored: Sun Mar 5 18:31:36 2017 +0200
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Mon Mar 6 10:54:49 2017 +0200

----------------------------------------------------------------------
 aria/storage/modeling/instance_elements.py |  3 +-
 tests/storage/test_models.py               | 81 +++++++++++++++++--------
 2 files changed, 59 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c1e7685a/aria/storage/modeling/instance_elements.py
----------------------------------------------------------------------
diff --git a/aria/storage/modeling/instance_elements.py b/aria/storage/modeling/instance_elements.py
index 2b102f1..86e2ea6 100644
--- a/aria/storage/modeling/instance_elements.py
+++ b/aria/storage/modeling/instance_elements.py
@@ -1179,8 +1179,9 @@ class RelationshipBase(structure.ModelMixin):
     target_capability_name = Column(Text)
     type_name = Column(Text)
     template_name = Column(Text)
+    type_hierarchy = Column(aria_types.List)
 
-    # # region orchestrator required columns
+    # region orchestrator required columns
     source_position = Column(Integer)
     target_position = Column(Integer)
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c1e7685a/tests/storage/test_models.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_models.py b/tests/storage/test_models.py
index 1e8d6b5..81b4122 100644
--- a/tests/storage/test_models.py
+++ b/tests/storage/test_models.py
@@ -91,12 +91,20 @@ def _node_template_storage():
 
 
 def _nodes_storage():
-    storage = _nodes_storage()
+    storage = _node_template_storage()
     service_instance = storage.service_instance.get_by_name(mock.models.DEPLOYMENT_NAME)
-    dependent_node_template = storage.node_template.get_by_name(mock.models.DEPENDENT_NODE_NAME)
+
     dependency_node_template = storage.node_template.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
     dependency_node = mock.models.get_dependency_node_instance(dependency_node_template,
                                                                service_instance)
+
+    req_template, cap_template = mock.models.get_relationship(dependency_node)
+    storage.requirement_template.put(req_template)
+    storage.capability_template.put(cap_template)
+
+    dependent_node_template = mock.models.get_dependent_node(service_instance,
+                                                             req_template,
+                                                             cap_template)
     dependent_node = mock.models.get_dependent_node_instance(dependent_node_template,
                                                              service_instance)
     storage.node.put(dependency_node)
@@ -670,29 +678,54 @@ class TestNodeInstanceIP(object):
         return node_instance
 
 
-@pytest.mark.skip('Should be reworked into relationship')
 class TestRelationshipInstance(object):
-    def test_relatiship_instance_model_creation(self, nodes_storage):
-        relationship = mock.models.get_relationship(
-            target=nodes_storage.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
-        )
-        nodes_storage.relationship.put(relationship)
-        node_instances = nodes_storage.node
-        source_node_instance = node_instances.get_by_name(mock.models.DEPENDENT_NODE_INSTANCE_NAME)
-        target_node_instance = node_instances.get_by_name(mock.models.DEPENDENCY_NODE_INSTANCE_NAME)
-
-        relationship_instance = _test_model(
-            is_valid=True,
-            storage=nodes_storage,
-            model_cls=Relationship,
-            model_kwargs=dict(
-                relationship=relationship,
-                source_node_instance=source_node_instance,
-                target_node_instance=target_node_instance
-            ))
-        assert relationship_instance.relationship == relationship
-        assert relationship_instance.source_node_instance == source_node_instance
-        assert relationship_instance.target_node_instance == target_node_instance
+    @pytest.mark.parametrize(
+        'is_valid, source_requirement_index, target_node_id, target_capability_name, type_name,
'
+        'template_name, type_hierarchy, source_position, target_position',
+        [
+            (False, m_cls, 'target_node_id', 'target_cap_name', 'type_name', 'template_name',
[], 0,
+             0),
+            (False, 0, m_cls, 'target_cap_name', 'type_name', 'template_name', [], 0, 0),
+            (False, 0, 'target_node_id', m_cls, 'type_name', 'template_name', [], 0, 0),
+            (False, 0, 'target_node_id', 'target_cap_name', m_cls, 'template_name', [], 0,
0),
+            (False, 0, 'target_node_id', 'target_cap_name', 'type_name', m_cls, [], 0, 0),
+            (False, 0, 'target_node_id', 'target_cap_name', 'type_name', 'template_name',
m_cls, 0,
+             0),
+            (False, 0, 'target_node_id', 'target_cap_name', 'type_name', 'template_name',
[], m_cls,
+             0),
+            (False, 0, 'target_node_id', 'target_cap_name', 'type_name', 'template_name',
[], 0,
+             m_cls),
+
+            (True, 0, 'target_node_id', 'target_cap_name', 'type_name', 'template_name',
[], 0, 0),
+            (True, None, 'target_node_id', 'target_cap_name', 'type_name', 'template_name',
[], 0,
+             0),
+            (True, 0, None, 'target_cap_name', 'type_name', 'template_name', [], 0, 0),
+            (True, 0, 'target_node_id', None, 'type_name', 'template_name', [], 0, 0),
+            (True, 0, 'target_node_id', 'target_cap_name', None, 'template_name', [], 0,
0),
+            (True, 0, 'target_node_id', 'target_cap_name', 'type_name', None, [], 0, 0),
+            (True, 0, 'target_node_id', 'target_cap_name', 'type_name', 'template_name',
[], None,
+             0),
+            (True, 0, 'target_node_id', 'target_cap_name', 'type_name', 'template_name',
[], 0,
+             None),
+
+        ]
+    )
+    def test_relationship(self, nodes_storage, is_valid, source_requirement_index, target_node_id,
+                          target_capability_name, type_name, template_name, type_hierarchy,
+                          source_position, target_position):
+        _test_model(is_valid=is_valid,
+                    storage=nodes_storage,
+                    model_cls=Relationship,
+                    model_kwargs=dict(
+                        source_requirement_index=source_requirement_index,
+                        target_node_id=target_node_id,
+                        target_capability_name=target_capability_name,
+                        type_name=type_name,
+                        template_name=template_name,
+                        type_hierarchy=type_hierarchy,
+                        source_position=source_position,
+                        target_position=target_position
+                    ))
 
 
 class TestPlugin(object):


Mime
View raw message