ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emblempar...@apache.org
Subject [1/2] incubator-ariatosca git commit: Move types into service template; continue fixing tests
Date Fri, 03 Mar 2017 23:44:29 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-105-integrate-modeling 091152f27 -> 36eb2d24c


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 0b95b31..522cc78 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -15,134 +15,139 @@
 
 from datetime import datetime
 
-from aria.modeling import model
+from aria.modeling import models
 from . import operations
 
-DEPLOYMENT_NAME = 'test_deployment_id'
-BLUEPRINT_NAME = 'test_blueprint_id'
+SERVICE_NAME = 'test_service_id'
+SERVICE_TEMPLATE_NAME = 'test_service_template_id'
 WORKFLOW_NAME = 'test_workflow_id'
 EXECUTION_NAME = 'test_execution_id'
 TASK_RETRY_INTERVAL = 1
 TASK_MAX_ATTEMPTS = 1
 
-DEPENDENCY_NODE_NAME = 'dependency_node'
-DEPENDENCY_NODE_INSTANCE_NAME = 'dependency_node_instance'
-DEPENDENT_NODE_NAME = 'dependent_node'
-DEPENDENT_NODE_INSTANCE_NAME = 'dependent_node_instance'
-RELATIONSHIP_NAME = 'relationship'
-RELATIONSHIP_INSTANCE_NAME = 'relationship_instance'
+DEPENDENCY_NODE_NAME = 'dependency_node_template'
+DEPENDENCY_NODE_INSTANCE_NAME = 'dependency_node'
+DEPENDENT_NODE_NAME = 'dependent_node_template'
+DEPENDENT_NODE_INSTANCE_NAME = 'dependent_node'
 
 
-def get_dependency_node(deployment):
-    return model.NodeTemplate(
+def create_dependency_node_template(service):
+    return models.NodeTemplate(
         name=DEPENDENCY_NODE_NAME,
-        type_name='test_node_type',
-        type_hierarchy=[],
+        type=service.service_template.node_types.get_descendant('test_node_type'),
         default_instances=1,
         min_instances=1,
         max_instances=1,
-        service_template=deployment.service_template,
+        service_template_fk=service.service_template.id,
     )
 
 
-def get_dependency_node_instance(dependency_node, deployment):
-    return model.Node(
+def create_dependency_node(dependency_node_template, service):
+    return models.Node(
         name=DEPENDENCY_NODE_INSTANCE_NAME,
-        service_instance=deployment,
+        type=dependency_node_template.type,
+        service=service,
         runtime_properties={'ip': '1.1.1.1'},
         version=None,
-        node_template=dependency_node,
+        node_template=dependency_node_template,
         state='',
         scaling_groups=[]
     )
 
 
-def get_relationship(target):
-    requirement_template = model.RequirementTemplate(target_node_template_name=target.name)
-    capability_template = model.CapabilityTemplate()
-
+def create_requirement(source):
+    requirement_template = models.RequirementTemplate(node_template=source)
+    capability_template = models.CapabilityTemplate(
+        node_template=source,
+        type=source.service_template.capability_types.get_descendant('test_capability_type'))
     return requirement_template, capability_template
 
 
-def get_relationship_instance(source_instance, target_instance):
-    return model.Relationship(
+def create_relationship(source_instance, target_instance):
+    return models.Relationship(
         target_node=target_instance,
         source_node=source_instance,
     )
 
 
-def get_dependent_node(deployment, requirement_template, capability_template):
-    operation_templates = [model.OperationTemplate(implementation=op,
-                                                   service_template=deployment.service_template)
-                           for op in operations.NODE_OPERATIONS]
-    interface_template = model.InterfaceTemplate(operation_templates=operation_templates)
+def create_dependent_node_template(service, requirement_template, capability_template):
+    operation_templates = dict((op, models.OperationTemplate(
+        name=op,
+        implementation='test'))
+                                for op in operations.NODE_OPERATIONS)
+    interface_template = models.InterfaceTemplate(
+        type=service.service_template.interface_types.get_descendant('test_interface_type'),
+        operation_templates=operation_templates)
 
-    return model.NodeTemplate(
+    return models.NodeTemplate(
         name=DEPENDENT_NODE_NAME,
-        type_name='test_node_type',
-        type_hierarchy=[],
+        type=service.service_template.node_types.get_descendant('test_node_type'),
         default_instances=1,
         min_instances=1,
         max_instances=1,
-        service_template=deployment.service_template,
-        interface_templates=[interface_template],
+        service_template=service.service_template,
+        interface_templates=_dictify(interface_template),
         requirement_templates=[requirement_template],
-        capability_templates=[capability_template],
+        capability_templates=_dictify(capability_template),
     )
 
 
-def get_dependent_node_instance(dependent_node, deployment):
-    return model.Node(
+def create_dependent_node(dependent_node_template, service):
+    return models.Node(
         name=DEPENDENT_NODE_INSTANCE_NAME,
-        service_instance=deployment,
+        service=service,
         runtime_properties={},
         version=None,
-        node_template=dependent_node,
+        node_template=dependent_node_template,
         state='',
         scaling_groups=[],
     )
 
 
-def get_blueprint():
+def create_service_template():
     now = datetime.now()
-    return model.ServiceTemplate(
-        plan={},
-        name=BLUEPRINT_NAME,
+    return models.ServiceTemplate(
+        name=SERVICE_TEMPLATE_NAME,
         description=None,
         created_at=now,
         updated_at=now,
-        main_file_name='main_file_name'
+        main_file_name='main_file_name',
+        node_types=models.Type(variant='node', name='test_node_type'),
+        group_types=models.Type(variant='group', name='test_group_type'),
+        policy_types=models.Type(variant='policy', name='test_policy_type'),
+        relationship_types=models.Type(variant='relationship', name='test_relationship_type'),
+        capability_types=models.Type(variant='capability', name='test_capability_type'),
+        artifact_types=models.Type(variant='artifact', name='test_artifact_type'),
+        interface_types=models.Type(variant='interface', name='test_interface_type')
     )
 
 
-def get_execution(deployment):
-    return model.Execution(
-        service_instance=deployment,
-        status=model.Execution.STARTED,
+def create_execution(service):
+    return models.Execution(
+        service=service,
+        status=models.Execution.STARTED,
         workflow_name=WORKFLOW_NAME,
         started_at=datetime.utcnow(),
         parameters=None
     )
 
 
-def get_deployment(blueprint):
+def create_service(service_template):
     now = datetime.utcnow()
-    return model.ServiceInstance(
-        name=DEPLOYMENT_NAME,
-        service_template=blueprint,
+    return models.Service(
+        name=SERVICE_NAME,
+        service_template=service_template,
         description='',
         created_at=now,
         updated_at=now,
         workflows={},
         permalink='',
-        policy_triggers={},
-        policy_types={},
         scaling_groups={},
     )
 
 
-def get_plugin(package_name='package', package_version='0.1'):
-    return model.Plugin(
+def create_plugin(package_name='package', package_version='0.1'):
+    return models.Plugin(
         archive_name='archive_name',
         distribution='distribution',
         distribution_release='dist_release',
@@ -157,26 +162,30 @@ def get_plugin(package_name='package', package_version='0.1'):
     )
 
 
-def get_interface_template(operation_name, operation_kwargs=None, interface_kwargs=None):
-    operation_template = model.OperationTemplate(
+def create_interface_template(operation_name, operation_kwargs=None, interface_kwargs=None):
+    operation_template = models.OperationTemplate(
         name=operation_name,
         **(operation_kwargs or {})
 
     )
-    return model.InterfaceTemplate(
-        operation_templates=[operation_template],
+    return models.InterfaceTemplate(
+        operation_templates=_dictify(operation_template),
         name=operation_name.rsplit('.', 1)[0],
         **(interface_kwargs or {})
     )
 
 
-def get_interface(operation_name,
-                  operation_kwargs=None,
-                  interface_kwargs=None,
-                  edge=None):
-    operation = model.Operation(name=operation_name, **(operation_kwargs or {}))
+def create_interface(operation_name,
+                     operation_kwargs=None,
+                     interface_kwargs=None,
+                     edge=None):
+    operation = models.Operation(name=operation_name, **(operation_kwargs or {}))
     interface_name = operation_name.rsplit('.', 1)[0]
-    return model.Interface(operations=[operation],
-                           name=interface_name,
-                           edge=edge,
-                           **(interface_kwargs or {}))
+    return models.Interface(operations=_dictify(operation),
+                            name=interface_name,
+                            edge=edge,
+                            **(interface_kwargs or {}))
+
+
+def _dictify(item):
+    return dict(((item.name, item),))

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/mock/topology.py
----------------------------------------------------------------------
diff --git a/tests/mock/topology.py b/tests/mock/topology.py
index b04fb46..b511ee3 100644
--- a/tests/mock/topology.py
+++ b/tests/mock/topology.py
@@ -13,71 +13,71 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from aria.storage import model
+from aria.modeling import models as aria_models
 
 from . import models
 
 
 def create_simple_topology_single_node(model_storage, create_operation):
-    service_template = models.get_blueprint()
+    service_template = models.create_service_template()
     model_storage.service_template.put(service_template)
 
-    service_instance = models.get_deployment(service_template)
-    model_storage.service_instance.put(service_instance)
+    service = models.create_service(service_template)
+    model_storage.service.put(service)
 
-    node_template = models.get_dependency_node(service_instance)
-    node_template.interface_templates = [models.get_interface_template(
+    node_template = models.create_dependency_node_template(service)
+    node_template.interface_templates = [models.create_interface_template(
         'tosca.interfaces.node.lifecycle.Standard.create',
         operation_kwargs=dict(
             implementation=create_operation,
-            inputs=[model.Parameter(name='key', str_value='create', type='str'),
-                    model.Parameter(name='value', str_value=str(True), type='bool')]
+            inputs=[aria_models.Parameter(name='key', value='create', type_name='string'),
+                    aria_models.Parameter(name='value', value=True, type_name='boolean')]
         )
     )]
     model_storage.node_template.put(node_template)
 
-    node = models.get_dependency_node_instance(node_template, service_instance)
-    node.interfaces = [models.get_interface(
+    node = models.create_dependency_node(node_template, service)
+    node.interfaces = [models.create_interface(
         'tosca.interfaces.node.lifecycle.Standard.create',
         operation_kwargs=dict(
             implementation=create_operation,
-            inputs=[model.Parameter(name='key', str_value='create', type='str'),
-                    model.Parameter(name='value', str_value=str(True), type='bool')])
+            inputs=[aria_models.Parameter(name='key', value='create', type_name='string'),
+                    aria_models.Parameter(name='value', value=True, type_name='boolean')])
     )]
     model_storage.node.put(node)
 
 
 def create_simple_topology_two_nodes(model_storage):
-    blueprint = models.get_blueprint()
+    blueprint = models.create_service_template()
     model_storage.service_template.put(blueprint)
-    deployment = models.get_deployment(blueprint)
-    model_storage.service_instance.put(deployment)
+    deployment = models.create_service(blueprint)
+    model_storage.service.put(deployment)
 
     #################################################################################
     # Creating a simple deployment with node -> node as a graph
 
-    dependency_node = models.get_dependency_node(deployment)
+    dependency_node = models.create_dependency_node_template(deployment)
     model_storage.node_template.put(dependency_node)
     storage_dependency_node = model_storage.node_template.get(dependency_node.id)
 
-    dependency_node_instance = models.get_dependency_node_instance(storage_dependency_node,
+    dependency_node_instance = models.create_dependency_node(storage_dependency_node,
                                                                    deployment)
     model_storage.node.put(dependency_node_instance)
     storage_dependency_node_instance = model_storage.node.get(dependency_node_instance.id)
 
-    req_template, cap_template = models.get_relationship(storage_dependency_node)
+    req_template, cap_template = models.create_requirement(storage_dependency_node)
     model_storage.requirement_template.put(req_template)
     model_storage.capability_template.put(cap_template)
 
-    dependent_node = models.get_dependent_node(deployment, req_template, cap_template)
+    dependent_node = models.create_dependent_node_template(deployment, req_template, cap_template)
     model_storage.node_template.put(dependent_node)
     storage_dependent_node = model_storage.node_template.get(dependent_node.id)
 
-    dependent_node_instance = models.get_dependent_node_instance(storage_dependent_node,
deployment)
+    dependent_node_instance = models.create_dependent_node(storage_dependent_node, deployment)
     model_storage.node.put(dependent_node_instance)
     storage_dependent_node_instance = model_storage.node.get(dependent_node_instance.id)
 
-    relationship_instance = models.get_relationship_instance(
+    relationship_instance = models.create_relationship(
         target_instance=storage_dependency_node_instance,
         source_instance=storage_dependent_node_instance
     )

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/context/test_resource_render.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_resource_render.py b/tests/orchestrator/context/test_resource_render.py
index aef439c..b924909 100644
--- a/tests/orchestrator/context/test_resource_render.py
+++ b/tests/orchestrator/context/test_resource_render.py
@@ -25,7 +25,7 @@ _VARIABLES_TEMPLATE_PATH = 'variables.template'
 
 def test_get_resource_and_render_implicit_ctx_no_variables(ctx):
     content = ctx.get_resource_and_render(_IMPLICIT_CTX_TEMPLATE_PATH)
-    assert content == mock.models.DEPLOYMENT_NAME
+    assert content == mock.models.SERVICE_NAME
 
 
 def test_get_resource_and_render_provided_variables(ctx):
@@ -39,7 +39,7 @@ def test_download_resource_and_render_implicit_ctx_no_variables(tmpdir,
ctx):
     destination = tmpdir.join('destination')
     ctx.download_resource_and_render(destination=str(destination),
                                      path=_IMPLICIT_CTX_TEMPLATE_PATH)
-    assert destination.read() == mock.models.DEPLOYMENT_NAME
+    assert destination.read() == mock.models.SERVICE_NAME
 
 
 def test_download_resource_and_render_provided_variables(tmpdir, ctx):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/context/test_serialize.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_serialize.py b/tests/orchestrator/context/test_serialize.py
index 1fdcb1a..ed6d724 100644
--- a/tests/orchestrator/context/test_serialize.py
+++ b/tests/orchestrator/context/test_serialize.py
@@ -66,7 +66,7 @@ def _mock_operation(ctx):
     assert ctx.name is not None
     assert ctx.name == ctx.task.name
     # a correct ctx.deployment.name tells us we kept the correct deployment_id
-    assert ctx.service_instance.name == mock.models.DEPLOYMENT_NAME
+    assert ctx.service_instance.name == mock.models.SERVICE_NAME
     # Here we test that the resource storage was properly re-created
     test_file_content = ctx.resource.blueprint.read(TEST_FILE_ENTRY_ID, TEST_FILE_NAME)
     assert test_file_content == TEST_FILE_CONTENT

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/context/test_workflow.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_workflow.py b/tests/orchestrator/context/test_workflow.py
index 4e8eca4..049b787 100644
--- a/tests/orchestrator/context/test_workflow.py
+++ b/tests/orchestrator/context/test_workflow.py
@@ -30,10 +30,10 @@ class TestWorkflowContext(object):
         ctx = self._create_ctx(storage)
         execution = storage.execution.get(ctx.execution.id)             # pylint: disable=no-member
         assert execution.service_instance == storage.service_instance.get_by_name(
-            models.DEPLOYMENT_NAME)
+            models.SERVICE_NAME)
         assert execution.workflow_name == models.WORKFLOW_NAME
         assert execution.service_template == storage.service_template.get_by_name(
-            models.BLUEPRINT_NAME)
+            models.SERVICE_TEMPLATE_NAME)
         assert execution.status == storage.execution.model_cls.PENDING
         assert execution.parameters == {}
         assert execution.created_at <= datetime.utcnow()
@@ -53,7 +53,7 @@ class TestWorkflowContext(object):
             name='simple_context',
             model_storage=storage,
             resource_storage=None,
-            service_instance_id=storage.service_instance.get_by_name(models.DEPLOYMENT_NAME).id,
+            service_instance_id=storage.service_instance.get_by_name(models.SERVICE_NAME).id,
             workflow_name=models.WORKFLOW_NAME,
             task_max_attempts=models.TASK_MAX_ATTEMPTS,
             task_retry_interval=models.TASK_RETRY_INTERVAL
@@ -64,8 +64,8 @@ class TestWorkflowContext(object):
 def storage():
     workflow_storage = application_model_storage(
         sql_mapi.SQLAlchemyModelAPI, initiator=test_storage.init_inmemory_model_storage)
-    workflow_storage.service_template.put(models.get_blueprint())
-    blueprint = workflow_storage.service_template.get_by_name(models.BLUEPRINT_NAME)
-    workflow_storage.service_instance.put(models.get_deployment(blueprint))
+    workflow_storage.service_template.put(models.get_service_template())
+    blueprint = workflow_storage.service_template.get_by_name(models.SERVICE_TEMPLATE_NAME)
+    workflow_storage.service_instance.put(models.get_service(blueprint))
     yield workflow_storage
     test_storage.release_sqlite_storage(workflow_storage)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/execution_plugin/test_common.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/execution_plugin/test_common.py b/tests/orchestrator/execution_plugin/test_common.py
index 1048c27..dd1e9fb 100644
--- a/tests/orchestrator/execution_plugin/test_common.py
+++ b/tests/orchestrator/execution_plugin/test_common.py
@@ -18,7 +18,7 @@ from collections import namedtuple
 import requests
 import pytest
 
-from aria.storage import model
+from aria.modeling import models
 from aria.orchestrator import exceptions
 from aria.orchestrator.execution_plugin import common
 
@@ -35,7 +35,7 @@ class TestDownloadScript(object):
 
     def _test_url(self, url):
         class Ctx(object):
-            task = model.Task
+            task = models.Task
 
         script_path = url
         result = common.download_script(Ctx, script_path)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/execution_plugin/test_ssh.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/execution_plugin/test_ssh.py b/tests/orchestrator/execution_plugin/test_ssh.py
index 2e270bb..a65ee34 100644
--- a/tests/orchestrator/execution_plugin/test_ssh.py
+++ b/tests/orchestrator/execution_plugin/test_ssh.py
@@ -24,7 +24,7 @@ import fabric.api
 from fabric.contrib import files
 from fabric import context_managers
 
-from aria.storage import model
+from aria.modeling import models
 from aria.orchestrator import events
 from aria.orchestrator import workflow
 from aria.orchestrator.workflows import api
@@ -222,8 +222,8 @@ class TestWithActualSSHServer(object):
                 op,
                 dict(implementation='{0}.{1}'.format(operations.__name__, operation.__name__))
             )]
-            graph.sequence(*[api.task.OperationTask.node(
-                instance=node,
+            graph.sequence(*[api.task.OperationTask.for_node(
+                node=node,
                 name=op,
                 inputs={
                     'script_path': script_path,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/test_runner.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/test_runner.py b/tests/orchestrator/test_runner.py
index 17230df..2e509b5 100644
--- a/tests/orchestrator/test_runner.py
+++ b/tests/orchestrator/test_runner.py
@@ -49,8 +49,8 @@ def test_runner_tasks():
     def workflow_fn(ctx, graph):
         for node in ctx.model.node:
             graph.add_tasks(
-                OperationTask.node(instance=node,
-                                   name='tosca.interfaces.node.lifecycle.Standard.create'))
+                OperationTask.for_node(node=node,
+                                       name='tosca.interfaces.node.lifecycle.Standard.create'))
 
     _test_runner(workflow_fn)
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/workflows/api/test_task.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/api/test_task.py b/tests/orchestrator/workflows/api/test_task.py
index e1ad8cf..a9b6a7a 100644
--- a/tests/orchestrator/workflows/api/test_task.py
+++ b/tests/orchestrator/workflows/api/test_task.py
@@ -18,7 +18,7 @@ import pytest
 
 from aria.orchestrator import context
 from aria.orchestrator.workflows import api
-from aria.modeling import model
+from aria.modeling import models
 from tests import mock, storage
 
 
@@ -55,9 +55,9 @@ class TestOperationTask(object):
         ignore_failure = True
 
         with context.workflow.current.push(ctx):
-            api_task = api.task.OperationTask.node(
+            api_task = api.task.OperationTask.for_node(
+                node=node,
                 name=operation_name,
-                instance=node,
                 inputs=inputs,
                 max_attempts=max_attempts,
                 retry_interval=retry_interval,
@@ -73,7 +73,7 @@ class TestOperationTask(object):
         assert api_task.plugin == {'name': 'plugin',
                                    'package_name': 'package',
                                    'package_version': '0.1'}
-        assert api_task.runs_on == model.Task.RUNS_ON_NODE_INSTANCE
+        assert api_task.runs_on == models.Task.RUNS_ON_NODE
 
     def test_source_relationship_operation_task_creation(self, ctx):
         operation_name = 'aria.interfaces.relationship_lifecycle.preconfigure'
@@ -94,9 +94,9 @@ class TestOperationTask(object):
         retry_interval = 10
 
         with context.workflow.current.push(ctx):
-            api_task = api.task.OperationTask.relationship(
+            api_task = api.task.OperationTask.for_relationship(
+                relationship=relationship,
                 name=operation_name,
-                instance=relationship,
                 edge='source',
                 inputs=inputs,
                 max_attempts=max_attempts,
@@ -111,7 +111,7 @@ class TestOperationTask(object):
         assert api_task.plugin == {'name': 'plugin',
                                    'package_name': 'package',
                                    'package_version': '0.1'}
-        assert api_task.runs_on == model.Task.RUNS_ON_SOURCE
+        assert api_task.runs_on == models.Task.RUNS_ON_SOURCE
 
     def test_target_relationship_operation_task_creation(self, ctx):
         operation_name = 'aria.interfaces.relationship_lifecycle.preconfigure'
@@ -131,9 +131,9 @@ class TestOperationTask(object):
         retry_interval = 10
 
         with context.workflow.current.push(ctx):
-            api_task = api.task.OperationTask.relationship(
+            api_task = api.task.OperationTask.for_relationship(
+                relationship=relationship,
                 name=operation_name,
-                instance=relationship,
                 edge='target',
                 inputs=inputs,
                 max_attempts=max_attempts,
@@ -148,7 +148,7 @@ class TestOperationTask(object):
         assert api_task.plugin == {'name': 'plugin',
                                    'package_name': 'package',
                                    'package_version': '0.1'}
-        assert api_task.runs_on == model.Task.RUNS_ON_TARGET
+        assert api_task.runs_on == models.Task.RUNS_ON_TARGET
 
     def test_operation_task_default_values(self, ctx):
         dependency_node_instance = ctx.model.node.get_by_name(

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/workflows/core/test_engine.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/core/test_engine.py b/tests/orchestrator/workflows/core/test_engine.py
index b0a1474..8c5511a 100644
--- a/tests/orchestrator/workflows/core/test_engine.py
+++ b/tests/orchestrator/workflows/core/test_engine.py
@@ -23,7 +23,7 @@ from aria.orchestrator import (
     workflow,
     operation,
 )
-from aria.modeling import model
+from aria.modeling import models
 from aria.orchestrator.workflows import (
     api,
     exceptions,
@@ -66,8 +66,8 @@ class BaseTest(object):
             operation_kwargs=dict(implementation='{name}.{func.__name__}'.format(name=__name__,
                                                                                  func=func))
         )]
-        return api.task.OperationTask.node(
-            instance=node,
+        return api.task.OperationTask.for_node(
+            node=node,
             name='aria.interfaces.lifecycle.create',
             inputs=inputs,
             max_attempts=max_attempts,
@@ -147,7 +147,7 @@ class TestEngine(BaseTest):
         execution = workflow_context.execution
         assert execution.started_at <= execution.ended_at <= datetime.utcnow()
         assert execution.error is None
-        assert execution.status == model.Execution.TERMINATED
+        assert execution.status == models.Execution.TERMINATED
 
     def test_single_task_successful_execution(self, workflow_context, executor):
         @workflow
@@ -176,7 +176,7 @@ class TestEngine(BaseTest):
         execution = workflow_context.execution
         assert execution.started_at <= execution.ended_at <= datetime.utcnow()
         assert execution.error is not None
-        assert execution.status == model.Execution.FAILED
+        assert execution.status == models.Execution.FAILED
 
     def test_two_tasks_execution_order(self, workflow_context, executor):
         @workflow
@@ -241,7 +241,7 @@ class TestCancel(BaseTest):
         execution = workflow_context.execution
         assert execution.started_at <= execution.ended_at <= datetime.utcnow()
         assert execution.error is None
-        assert execution.status == model.Execution.CANCELLED
+        assert execution.status == models.Execution.CANCELLED
 
     def test_cancel_pending_execution(self, workflow_context, executor):
         @workflow
@@ -252,7 +252,7 @@ class TestCancel(BaseTest):
                            executor=executor)
         eng.cancel_execution()
         execution = workflow_context.execution
-        assert execution.status == model.Execution.CANCELLED
+        assert execution.status == models.Execution.CANCELLED
 
 
 class TestRetries(BaseTest):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/workflows/executor/test_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_executor.py b/tests/orchestrator/workflows/executor/test_executor.py
index 568ab7e..2421fa9 100644
--- a/tests/orchestrator/workflows/executor/test_executor.py
+++ b/tests/orchestrator/workflows/executor/test_executor.py
@@ -28,7 +28,7 @@ except ImportError:
     _celery = None
     app = None
 
-from aria.modeling import model
+from aria.modeling import models
 from aria.orchestrator import events
 from aria.orchestrator.workflows.executor import (
     thread,
@@ -98,7 +98,7 @@ class MockContext(object):
 
 class MockTask(object):
 
-    INFINITE_RETRIES = model.Task.INFINITE_RETRIES
+    INFINITE_RETRIES = models.Task.INFINITE_RETRIES
 
     def __init__(self, func, inputs=None):
         self.states = []
@@ -117,7 +117,7 @@ class MockTask(object):
         self.plugin_fk = None
         self.ignore_failure = False
 
-        for state in model.Task.STATES:
+        for state in models.Task.STATES:
             setattr(self, state.upper(), state)
 
     @contextmanager

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/orchestrator/workflows/executor/test_process_executor.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py
index e904eb3..ffb2b15 100644
--- a/tests/orchestrator/workflows/executor/test_process_executor.py
+++ b/tests/orchestrator/workflows/executor/test_process_executor.py
@@ -22,10 +22,8 @@ from contextlib import contextmanager
 import pytest
 
 from aria import application_model_storage
-from aria.storage import (
-    model as aria_model,
-    sql_mapi
-)
+from aria.modeling import models as aria_models
+from aria.storage import sql_mapi
 from aria.orchestrator import (
     events,
     plugin
@@ -129,7 +127,7 @@ class MockContext(object):
 
 class MockTask(object):
 
-    INFINITE_RETRIES = aria_model.Task.INFINITE_RETRIES
+    INFINITE_RETRIES = aria_models.Task.INFINITE_RETRIES
 
     def __init__(self, plugin, implementation):
         self.id = str(uuid.uuid4())
@@ -144,7 +142,7 @@ class MockTask(object):
         self.plugin = plugin
         self.ignore_failure = False
 
-        for state in aria_model.Task.STATES:
+        for state in aria_models.Task.STATES:
             setattr(self, state.upper(), state)
 
     @contextmanager

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py
----------------------------------------------------------------------
diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py
index fff78bf..4f73c50 100644
--- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py
+++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py
@@ -1,6 +1,12 @@
 
 from aria import workflow
 from aria.orchestrator.workflows.api.task import OperationTask
+from aria.orchestrator.workflows.exceptions import TaskException
+
+
+INTERFACE_NAME = 'Maintenance'
+ENABLE_OPERATION_NAME = 'enable'
+DISABLE_OPERATION_NAME = 'disable'
 
 
 @workflow
@@ -9,8 +15,12 @@ def maintenance(ctx, graph, enabled):
     Custom workflow to call the operations on the Maintenance interface.
     """
 
-    operation = 'Maintenance.enable' if enabled else 'Maintenance.disable'
-
     for node in ctx.model.node.iter():
-        for interface in node.interfaces.filter_by(name='Maintenance', type_name='Maintenance'):
-            graph.add_tasks(OperationTask.node(instance=node, name=operation))
+        try:
+            graph.add_tasks(OperationTask.for_node(node=node,
+                                                   interface_name=INTERFACE_NAME,
+                                                   operation_name=ENABLE_OPERATION_NAME if
enabled
+                                                   else DISABLE_OPERATION_NAME,
+                                                   dry=True))
+        except TaskException:
+            pass

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/storage/test_models.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_models.py b/tests/storage/test_models.py
index b186509..45324dc 100644
--- a/tests/storage/test_models.py
+++ b/tests/storage/test_models.py
@@ -59,15 +59,15 @@ def _empty_storage():
 
 def _service_template_storage():
     storage = _empty_storage()
-    service_template = mock.models.get_blueprint()
+    service_template = mock.models.get_service_template()
     storage.service_template.put(service_template)
     return storage
 
 
 def _service_instance_storage():
     storage = _service_template_storage()
-    service_instance = mock.models.get_deployment(
-        storage.service_template.get_by_name(mock.models.BLUEPRINT_NAME))
+    service_instance = mock.models.get_service(
+        storage.service_template.get_by_name(mock.models.SERVICE_TEMPLATE_NAME))
     storage.service_instance.put(service_instance)
     return storage
 
@@ -85,19 +85,19 @@ def _service_instance_update_storage():
 
 def _node_template_storage():
     storage = _service_instance_storage()
-    node_template = mock.models.get_dependency_node(storage.service_instance.list()[0])
+    node_template = mock.models.get_dependency_node_template(storage.service_instance.list()[0])
     storage.node_template.put(node_template)
     return storage
 
 
 def _nodes_storage():
     storage = _nodes_storage()
-    service_instance = storage.service_instance.get_by_name(mock.models.DEPLOYMENT_NAME)
+    service_instance = storage.service_instance.get_by_name(mock.models.SERVICE_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,
+    dependency_node = mock.models.get_dependency_node(dependency_node_template,
                                                                service_instance)
-    dependent_node = mock.models.get_dependent_node_instance(dependent_node_template,
+    dependent_node = mock.models.get_dependent_node(dependent_node_template,
                                                              service_instance)
     storage.node.put(dependency_node)
     storage.node.put(dependent_node)
@@ -172,23 +172,23 @@ def _test_model(is_valid, storage, model_cls, model_kwargs):
 class TestServiceTemplate(object):
 
     @pytest.mark.parametrize(
-        'is_valid, plan, description, created_at, updated_at, main_file_name',
+        'is_valid, description, created_at, updated_at, main_file_name',
         [
-            (False, None, 'description', now, now, '/path'),
-            (False, {}, {}, now, now, '/path'),
-            (False, {}, 'description', 'error', now, '/path'),
-            (False, {}, 'description', now, 'error', '/path'),
-            (False, {}, 'description', now, now, {}),
-            (True, {}, 'description', now, now, '/path'),
+            (False, 'description', now, now, '/path'),
+            (False, {}, now, now, '/path'),
+            (False, 'description', 'error', now, '/path'),
+            (False, 'description', now, 'error', '/path'),
+            (False, 'description', now, now, {}),
+            (True, 'description', now, now, '/path'),
         ]
     )
-    def test_blueprint_model_creation(self, empty_storage, is_valid, plan, description, created_at,
+
+    def test_blueprint_model_creation(self, empty_storage, is_valid, description, created_at,
                                       updated_at, main_file_name):
         _test_model(is_valid=is_valid,
                     storage=empty_storage,
                     model_cls=ServiceTemplate,
                     model_kwargs=dict(
-                        plan=plan,
                         description=description,
                         created_at=created_at,
                         updated_at=updated_at,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/36eb2d24/tests/storage/test_structures.py
----------------------------------------------------------------------
diff --git a/tests/storage/test_structures.py b/tests/storage/test_structures.py
index 77e997c..67510ad 100644
--- a/tests/storage/test_structures.py
+++ b/tests/storage/test_structures.py
@@ -112,7 +112,7 @@ def test_model_to_dict(context):
 
 
 def test_relationship_model_ordering(context):
-    service_instance = context.model.service_instance.get_by_name(models.DEPLOYMENT_NAME)
+    service_instance = context.model.service_instance.get_by_name(models.SERVICE_NAME)
     source_node = context.model.node.get_by_name(models.DEPENDENT_NODE_INSTANCE_NAME)
     target_node = context.model.node.get_by_name(models.DEPENDENCY_NODE_INSTANCE_NAME)
     new_node_template = modeling.models.NodeTemplate(



Mime
View raw message