You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by av...@apache.org on 2017/06/04 11:39:12 UTC
incubator-ariatosca git commit: After Maxim's review
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-180-convert-parameter-to-one-to-many 798e5583e -> cf68ce5be
After Maxim's review
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/cf68ce5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/cf68ce5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/cf68ce5b
Branch: refs/heads/ARIA-180-convert-parameter-to-one-to-many
Commit: cf68ce5be4165de6c6deb20ae9a3e1703c6f2dae
Parents: 798e558
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Sun Jun 4 14:38:56 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Sun Jun 4 14:38:56 2017 +0300
----------------------------------------------------------------------
aria/modeling/mixins.py | 2 +-
aria/modeling/service_common.py | 10 +++--
aria/orchestrator/workflows/executor/dry.py | 2 +-
.../simple_v1_0/modeling/__init__.py | 42 +++++++++++---------
tests/mock/models.py | 9 ++---
tests/modeling/test_models.py | 42 ++++++++++++++++++++
tox.ini | 2 -
7 files changed, 77 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cf68ce5b/aria/modeling/mixins.py
----------------------------------------------------------------------
diff --git a/aria/modeling/mixins.py b/aria/modeling/mixins.py
index 9a88f81..c98a866 100644
--- a/aria/modeling/mixins.py
+++ b/aria/modeling/mixins.py
@@ -146,7 +146,7 @@ class TemplateModelMixin(InstanceModelMixin):
raise NotImplementedError
-class ParameterMixin(TemplateModelMixin, caching.HasCachedMethods):
+class ParameterMixin(TemplateModelMixin, caching.HasCachedMethods): #pylint: disable=abstract-method
"""
Represents a typed value. The value can contain nested intrinsic functions.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cf68ce5b/aria/modeling/service_common.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index d305f7a..272dfd7 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -22,11 +22,13 @@ from sqlalchemy import (
from sqlalchemy.ext.declarative import declared_attr
from ..parser.consumption import ConsumptionContext
-from ..utils import (collections, formatting, console)
-from .mixins import (InstanceModelMixin, TemplateModelMixin, ParameterMixin)
-from . import (
- relationship,
+from ..utils import (
+ collections,
+ formatting,
+ console,
)
+from .mixins import InstanceModelMixin, TemplateModelMixin, ParameterMixin
+from . import relationship
class OutputBase(ParameterMixin):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cf68ce5b/aria/orchestrator/workflows/executor/dry.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/dry.py b/aria/orchestrator/workflows/executor/dry.py
index 8848df8..72080b4 100644
--- a/aria/orchestrator/workflows/executor/dry.py
+++ b/aria/orchestrator/workflows/executor/dry.py
@@ -45,7 +45,7 @@ class DryExecutor(BaseExecutor):
logger(dry_msg.format(name=name, task=task, suffix='started...'))
logger(dry_msg.format(name=name, task=task, suffix='successful'))
else:
- logger(dry_msg.format(name=name, task=task, suffix='has no function'))
+ logger(dry_msg.format(name=name, task=task, suffix='has no implementation'))
# updating the task manually instead of calling self._task_succeeded(task),
# to avoid any side effects raising that event might cause
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cf68ce5b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
index 2d50ad5..5813ccf 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
@@ -96,10 +96,10 @@ def create_service_template_model(context): # pylint: disable=too-many-locals,to
if topology_template is not None:
create_parameter_models_from_values(model.inputs,
topology_template._get_input_values(context),
- model_class=Input)
+ model_cls=Input)
create_parameter_models_from_values(model.outputs,
topology_template._get_output_values(context),
- model_class=Output)
+ model_cls=Output)
# Plugin specifications
policies = context.presentation.get('service_template', 'topology_template', 'policies')
@@ -176,10 +176,10 @@ def create_node_template_model(context, service_template, node_template):
create_parameter_models_from_values(model.properties,
node_template._get_property_values(context),
- model_class=Property)
+ model_cls=Property)
create_parameter_models_from_values(model.attributes,
node_template._get_attribute_default_values(context),
- model_class=Attribute)
+ model_cls=Attribute)
create_interface_template_models(context, service_template, model.interface_templates,
node_template._get_interfaces(context))
@@ -225,7 +225,7 @@ def create_group_template_model(context, service_template, group):
model.description = group.description.value
create_parameter_models_from_values(model.properties, group._get_property_values(context),
- model_class=Property)
+ model_cls=Property)
create_interface_template_models(context, service_template, model.interface_templates,
group._get_interfaces(context))
@@ -249,7 +249,7 @@ def create_policy_template_model(context, service_template, policy):
model.description = policy.description.value
create_parameter_models_from_values(model.properties, policy._get_property_values(context),
- model_class=Property)
+ model_cls=Property)
node_templates, groups = policy._get_targets(context)
if node_templates:
@@ -318,7 +318,9 @@ def create_relationship_template_model(context, service_template, relationship):
if relationship_template.description:
model.description = relationship_template.description.value
- create_parameter_models_from_assignments(model.properties, relationship.properties)
+ create_parameter_models_from_assignments(model.properties,
+ relationship.properties,
+ model_cls=Property)
create_interface_template_models(context, service_template, model.interface_templates,
relationship.interfaces)
@@ -347,7 +349,9 @@ def create_capability_template_model(context, service_template, capability):
node_type = service_template.node_types.get_descendant(valid_source_type)
model.valid_source_node_types.append(node_type)
- create_parameter_models_from_assignments(model.properties, capability.properties)
+ create_parameter_models_from_assignments(model.properties,
+ capability.properties,
+ model_cls=Property)
return model
@@ -462,7 +466,7 @@ def create_artifact_template_model(context, service_template, artifact):
model.repository_credential[k] = v
create_parameter_models_from_values(model.properties, artifact._get_property_values(context),
- model_class=Property)
+ model_cls=Property)
return model
@@ -578,23 +582,23 @@ def create_types(context, root, types):
container.children.append(model)
-def create_parameter_models_from_values(properties, source_properties, model_class=None):
+def create_parameter_models_from_values(properties, source_properties, model_cls):
if source_properties:
for property_name, prop in source_properties.iteritems():
- properties[property_name] = model_class(name=property_name, # pylint: disable=unexpected-keyword-arg
- type_name=prop.type,
- value=prop.value,
- description=prop.description)
+ properties[property_name] = model_cls(name=property_name, # pylint: disable=unexpected-keyword-arg
+ type_name=prop.type,
+ value=prop.value,
+ description=prop.description)
-def create_parameter_models_from_assignments(properties, source_properties):
+def create_parameter_models_from_assignments(properties, source_properties, model_cls):
if source_properties:
for property_name, prop in source_properties.iteritems():
- properties[property_name] = Property(name=property_name, # pylint: disable=unexpected-keyword-arg
- type_name=prop.value.type,
- value=prop.value.value,
- description=prop.value.description)
+ properties[property_name] = model_cls(name=property_name, # pylint: disable=unexpected-keyword-arg
+ type_name=prop.value.type,
+ value=prop.value.value,
+ description=prop.value.description)
def create_interface_template_models(context, service_template, interfaces, source_interfaces):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cf68ce5b/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index f7f95b8..56a6e3e 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -278,17 +278,16 @@ def create_plugin_specification(name='test_plugin', version='0.1'):
)
-def _create_parameter(name, value, model_class):
- p = model_class()
- return p.wrap(name, value)
+def _create_parameter(name, value, model_cls):
+ return model_cls.wrap(name, value)
def create_property(name, value):
- return _create_parameter(name, value, model_class=models.Property)
+ return _create_parameter(name, value, model_cls=models.Property)
def create_input(name, value):
- return _create_parameter(name, value, model_class=models.Input)
+ return _create_parameter(name, value, model_cls=models.Input)
def _dictify(item):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cf68ce5b/tests/modeling/test_models.py
----------------------------------------------------------------------
diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py
index f2acc73..abe7338 100644
--- a/tests/modeling/test_models.py
+++ b/tests/modeling/test_models.py
@@ -36,8 +36,12 @@ from aria.modeling.models import (
Relationship,
NodeTemplate,
Node,
+ Input,
+ Output,
Property,
Attribute,
+ Configuration,
+ Argument,
Type
)
@@ -840,3 +844,41 @@ class TestType(object):
assert super_type.hierarchy == [super_type, additional_type]
assert sub_type.hierarchy == [sub_type, super_type, additional_type]
+
+
+class TestParameter(object):
+
+ MODELS_DERIVED_FROM_PARAMETER = (Input, Output, Property, Attribute, Configuration, Argument)
+
+ @pytest.mark.parametrize(
+ 'is_valid, name, type_name, description',
+ [
+ (False, 'name', 'int', []),
+ (False, 'name', [], 'desc'),
+ (False, [], 'type_name', 'desc'),
+ (True, 'name', 'type_name', 'desc'),
+ ]
+ )
+ def test_dervied_from_parameter_model_creation(self, empty_storage, is_valid, name, type_name,
+ description):
+
+ for model_cls in self.MODELS_DERIVED_FROM_PARAMETER:
+ _test_model(is_valid=is_valid,
+ storage=empty_storage,
+ model_cls=model_cls,
+ model_kwargs=dict(
+ name=name,
+ type_name=type_name,
+ description=description,
+ _value={})
+ )
+
+ def test_as_argument(self):
+
+ for model_cls in self.MODELS_DERIVED_FROM_PARAMETER:
+ model = model_cls(name='name',
+ type_name='type_name',
+ description='description',
+ _value={})
+ argument = model.as_argument()
+ assert type(argument) is Argument
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/cf68ce5b/tox.ini
----------------------------------------------------------------------
diff --git a/tox.ini b/tox.ini
index 6ab97cb..58e62c3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -19,8 +19,6 @@ passenv =
PYTHON
PYTHON_VERSION
PYTHON_ARCH
-setenv =
- INSTALL_CTX=1
deps =
-rrequirements.txt
-rtests/requirements.txt