Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-171-service-template-services-type-inconsistency [created] 4425c1030
ARIA-171 service_template.services type inconsistency As opposed to service_template.node_templates and service.nodes which have a dict interface, service_template.services had a list interface. That seemed as inconsistent, so the former interface was changed to a dict interface as well. Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/4425c103 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/4425c103 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/4425c103 Branch: refs/heads/ARIA-171-service-template-services-type-inconsistency Commit: 4425c10306517cffce930b3f81623f350a116fae Parents: fdd57c4 Author: Avia Efrat <[email protected]> Authored: Mon May 15 14:26:34 2017 +0300 Committer: Avia Efrat <[email protected]> Committed: Mon May 15 14:26:34 2017 +0300 ---------------------------------------------------------------------- aria/cli/commands/service_templates.py | 4 ++-- aria/modeling/service_template.py | 2 +- tests/cli/test_service_templates.py | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4425c103/aria/cli/commands/service_templates.py ---------------------------------------------------------------------- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 0a24907..d139195 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -89,8 +89,8 @@ def show(service_template_name, model_storage, mode_full, mode_types, format_jso if service_template.services: logger.info('Existing services:') - for service in service_template.services: - logger.info('\t{0}'.format(service.name)) + for service_name in service_template.services: + logger.info('\t{0}'.format(service_name)) @service_templates.command(name='list', http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4425c103/aria/modeling/service_template.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py index 7eb35bd..1eb95a3 100644 --- a/aria/modeling/service_template.py +++ b/aria/modeling/service_template.py @@ -208,7 +208,7 @@ class ServiceTemplateBase(TemplateModelMixin): @declared_attr def services(cls): - return relationship.one_to_many(cls, 'service') + return relationship.one_to_many(cls, 'service', dict_key='name') @declared_attr def operation_templates(cls): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/4425c103/tests/cli/test_service_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py index bc3c751..7e86896 100644 --- a/tests/cli/test_service_templates.py +++ b/tests/cli/test_service_templates.py @@ -65,7 +65,8 @@ class TestServiceTemplatesShow(TestCliBase): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) st = mock_models.create_service_template() - st.services = [mock_models.create_service(st)] + s = mock_models.create_service(st) + st.services = {s.name: s} monkeypatch.setattr(mock_storage.service_template, 'get_by_name', mock.MagicMock(return_value=st)) @@ -79,7 +80,8 @@ class TestServiceTemplatesShow(TestCliBase): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) st = mock_models.create_service_template(description='test_description') - st.services = [mock_models.create_service(st)] + s = mock_models.create_service(st) + st.services = {s.name: s} monkeypatch.setattr(mock_storage.service_template, 'get_by_name', mock.MagicMock(return_value=st))
