Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-48-aria-cli e17916e19 -> 195597dba
fixed imports style and added licenses to cli tests Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/195597db Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/195597db Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/195597db Branch: refs/heads/ARIA-48-aria-cli Commit: 195597dba119fb693693ca6dd8aee9db8e46ecef Parents: e17916e Author: Ran Ziv <[email protected]> Authored: Wed Apr 19 15:54:54 2017 +0300 Committer: Ran Ziv <[email protected]> Committed: Wed Apr 19 15:54:54 2017 +0300 ---------------------------------------------------------------------- tests/cli/base_test.py | 35 +++++++++++----- tests/cli/runner.py | 18 ++++++++- tests/cli/test_node_templates.py | 62 +++++++++++++++++++---------- tests/cli/test_nodes.py | 30 +++++++++++--- tests/cli/test_service_templates.py | 68 +++++++++++++++++++++----------- tests/cli/test_services.py | 56 ++++++++++++++++++-------- tests/cli/utils.py | 18 ++++++++- 7 files changed, 210 insertions(+), 77 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/base_test.py ---------------------------------------------------------------------- diff --git a/tests/cli/base_test.py b/tests/cli/base_test.py index 9268f71..4a1d4ab 100644 --- a/tests/cli/base_test.py +++ b/tests/cli/base_test.py @@ -1,15 +1,30 @@ -from StringIO import StringIO +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import logging +from StringIO import StringIO import pytest -import tests.cli.runner as runner -from tests.cli.utils import setup_logger, MockStorage +from . import runner +from . import utils @pytest.fixture def mock_storage(): - return MockStorage() + return utils.MockStorage() @pytest.mark.usefixtures("redirect_logger") @@ -19,13 +34,13 @@ class TestCliBase(object): @pytest.fixture(scope="class") def redirect_logger(): - setup_logger(logger_name='aria.cli.main', - handlers=[logging.StreamHandler(TestCliBase._logger_output)], - logger_format='%(message)s') + utils.setup_logger(logger_name='aria.cli.main', + handlers=[logging.StreamHandler(TestCliBase._logger_output)], + logger_format='%(message)s') yield - setup_logger(logger_name='aria.cli.main', - handlers=_default_logger_config['handlers'], - level=_default_logger_config['level']) + utils.setup_logger(logger_name='aria.cli.main', + handlers=_default_logger_config['handlers'], + level=_default_logger_config['level']) _logger_output = StringIO() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/runner.py ---------------------------------------------------------------------- diff --git a/tests/cli/runner.py b/tests/cli/runner.py index 1682f95..7e4243b 100644 --- a/tests/cli/runner.py +++ b/tests/cli/runner.py @@ -1,6 +1,22 @@ -import aria.cli.commands as commands +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import click.testing +import aria.cli.commands as commands + def invoke(command_string): command_list = command_string.split() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/test_node_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_node_templates.py b/tests/cli/test_node_templates.py index 931c0a4..76f8820 100644 --- a/tests/cli/test_node_templates.py +++ b/tests/cli/test_node_templates.py @@ -1,10 +1,28 @@ -from mock import ANY, MagicMock +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import pytest +from mock import ANY, MagicMock from aria.cli.env import _Environment -from tests.cli.base_test import TestCliBase, mock_storage # pylint: disable=unused-import -from tests.mock.models import create_node_template_with_dependencies, NODE_NAME, \ - SERVICE_TEMPLATE_NAME, NODE_TEMPLATE_NAME + +from .base_test import ( + TestCliBase, + mock_storage # pylint: disable=unused-import +) +from ..mock import models as mock_models class TestNodeTemplatesShow(TestCliBase): @@ -25,42 +43,44 @@ class TestNodeTemplatesShow(TestCliBase): assert 'prop1' not in self.logger_output_string assert 'value1' not in self.logger_output_string assert 'No nodes' in self.logger_output_string - assert NODE_NAME not in self.logger_output_string + assert mock_models.NODE_NAME not in self.logger_output_string def test_one_property_no_nodes(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - m = MagicMock(return_value=create_node_template_with_dependencies(include_property=True)) + m = MagicMock(return_value=mock_models.create_node_template_with_dependencies( + include_property=True)) monkeypatch.setattr(mock_storage.node_template, 'get', m) self.invoke('node_templates show 2') assert 'No properties' not in self.logger_output_string assert 'prop1' in self.logger_output_string and 'value1' in self.logger_output_string assert 'No nodes' in self.logger_output_string - assert NODE_NAME not in self.logger_output_string + assert mock_models.NODE_NAME not in self.logger_output_string def test_no_properties_one_node(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - m = MagicMock(return_value=create_node_template_with_dependencies(include_node=True)) + m = MagicMock(return_value=mock_models.create_node_template_with_dependencies( + include_node=True)) monkeypatch.setattr(mock_storage.node_template, 'get', m) self.invoke('node_templates show 3') assert 'No properties' in self.logger_output_string assert 'prop1' not in self.logger_output_string assert 'value1' not in self.logger_output_string assert 'No nodes' not in self.logger_output_string - assert NODE_NAME in self.logger_output_string + assert mock_models.NODE_NAME in self.logger_output_string def test_one_property_one_node(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - m = MagicMock(return_value=create_node_template_with_dependencies(include_node=True, - include_property=True)) + m = MagicMock(return_value=mock_models.create_node_template_with_dependencies( + include_node=True, include_property=True)) monkeypatch.setattr(mock_storage.node_template, 'get', m) self.invoke('node_templates show 4') assert 'No properties' not in self.logger_output_string assert 'prop1' in self.logger_output_string and 'value1' in self.logger_output_string assert 'No nodes' not in self.logger_output_string - assert NODE_NAME in self.logger_output_string + assert mock_models.NODE_NAME in self.logger_output_string class TestNodeTemplatesList(TestCliBase): @@ -76,19 +96,19 @@ class TestNodeTemplatesList(TestCliBase): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) self.invoke('node_templates list -t {service_template_name}{sort_by}{order}' - .format(service_template_name=SERVICE_TEMPLATE_NAME, + .format(service_template_name=mock_models.SERVICE_TEMPLATE_NAME, sort_by=sort_by, order=order)) - assert 'Listing node templates for service template ' \ - '{name}...'.format(name=SERVICE_TEMPLATE_NAME) in self.logger_output_string + assert 'Listing node templates for service template {name}...'\ + .format(name=mock_models.SERVICE_TEMPLATE_NAME) in self.logger_output_string assert 'Listing all node templates...' not in self.logger_output_string node_templates_list = mock_storage.node_template.list node_templates_list.assert_called_once_with(sort={sort_by_in_output: order_in_output}, filters={'service_template': ANY}) assert 'Node templates:' in self.logger_output_string - assert SERVICE_TEMPLATE_NAME in self.logger_output_string - assert NODE_TEMPLATE_NAME in self.logger_output_string + assert mock_models.SERVICE_TEMPLATE_NAME in self.logger_output_string + assert mock_models.NODE_TEMPLATE_NAME in self.logger_output_string @pytest.mark.parametrize('sort_by, order, sort_by_in_output, order_in_output', [ ('', '', 'service_template_name', 'asc'), @@ -102,12 +122,12 @@ class TestNodeTemplatesList(TestCliBase): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) self.invoke('node_templates list{sort_by}{order}'.format(sort_by=sort_by, order=order)) assert 'Listing all node templates...' in self.logger_output_string - assert 'Listing node templates for service template ' \ - '{name}...'.format(name=SERVICE_TEMPLATE_NAME) not in self.logger_output_string + assert 'Listing node templates for service template {name}...'\ + .format(name=mock_models.SERVICE_TEMPLATE_NAME) not in self.logger_output_string node_templates_list = mock_storage.node_template.list node_templates_list.assert_called_once_with(sort={sort_by_in_output: order_in_output}, filters={}) assert 'Node templates:' in self.logger_output_string - assert SERVICE_TEMPLATE_NAME in self.logger_output_string - assert NODE_TEMPLATE_NAME in self.logger_output_string + assert mock_models.SERVICE_TEMPLATE_NAME in self.logger_output_string + assert mock_models.NODE_TEMPLATE_NAME in self.logger_output_string http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/test_nodes.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_nodes.py b/tests/cli/test_nodes.py index e5a081c..fbeb9dd 100644 --- a/tests/cli/test_nodes.py +++ b/tests/cli/test_nodes.py @@ -1,9 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import pytest -from mock import ANY, MagicMock +import mock from aria.cli.env import _Environment -from tests.cli.base_test import TestCliBase, mock_storage # pylint: disable=unused-import -from tests.mock.models import create_node_with_dependencies + +from .base_test import ( + TestCliBase, + mock_storage # pylint: disable=unused-import +) +from ..mock import models as mock_models class TestNodesShow(TestCliBase): @@ -26,7 +45,8 @@ class TestNodesShow(TestCliBase): def test_one_attribute(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - m = MagicMock(return_value=create_node_with_dependencies(include_attribute=True)) + m = mock.MagicMock( + return_value=mock_models.create_node_with_dependencies(include_attribute=True)) monkeypatch.setattr(mock_storage.node, 'get', m) self.invoke('nodes show 3') assert 'No attributes' not in self.logger_output_string @@ -53,7 +73,7 @@ class TestNodesList(TestCliBase): nodes_list = mock_storage.node.list nodes_list.assert_called_once_with(sort={sort_by_in_output: order_in_output}, - filters={'service': ANY}) + filters={'service': mock.ANY}) assert 'Nodes:' in self.logger_output_string assert 'test_s' in self.logger_output_string assert 'test_n' in self.logger_output_string http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/test_service_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py index 67ba567..11bcf97 100644 --- a/tests/cli/test_service_templates.py +++ b/tests/cli/test_service_templates.py @@ -1,5 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import pytest -from mock import MagicMock +import mock from aria.cli import service_template_utils, csar from aria.cli.env import _Environment @@ -7,9 +22,14 @@ from aria.cli.exceptions import AriaCliError from aria.core import Core from aria.exceptions import AriaException from aria.storage import exceptions as storage_exceptions -from tests.cli.base_test import TestCliBase, assert_exception_raised, raise_exception, mock_storage # pylint: disable=unused-import -from tests.mock.models import create_service_template, create_service, create_parameter, \ - SERVICE_TEMPLATE_NAME, SERVICE_NAME + +from .base_test import ( + TestCliBase, + assert_exception_raised, + raise_exception, + mock_storage # pylint: disable=unused-import +) +from ..mock import models as mock_models class TestServiceTemplatesShow(TestCliBase): @@ -31,9 +51,9 @@ class TestServiceTemplatesShow(TestCliBase): def test_no_services_yes_description(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - st = create_service_template(description='test_description') + st = mock_models.create_service_template(description='test_description') monkeypatch.setattr(mock_storage.service_template, 'get_by_name', - MagicMock(return_value=st)) + mock.MagicMock(return_value=st)) self.invoke('service_templates show test_st') assert 'Description:' in self.logger_output_string @@ -43,24 +63,24 @@ class TestServiceTemplatesShow(TestCliBase): def test_one_service_no_description(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - st = create_service_template() - st.services = [create_service(st)] + st = mock_models.create_service_template() + st.services = [mock_models.create_service(st)] monkeypatch.setattr(mock_storage.service_template, 'get_by_name', - MagicMock(return_value=st)) + mock.MagicMock(return_value=st)) self.invoke('service_templates show test_st') assert 'Description:' not in self.logger_output_string assert 'Existing services:' in self.logger_output_string - assert SERVICE_NAME in self.logger_output_string + assert mock_models.SERVICE_NAME in self.logger_output_string def test_one_service_yes_description(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - st = create_service_template(description='test_description') - st.services = [create_service(st)] + st = mock_models.create_service_template(description='test_description') + st.services = [mock_models.create_service(st)] monkeypatch.setattr(mock_storage.service_template, 'get_by_name', - MagicMock(return_value=st)) + mock.MagicMock(return_value=st)) self.invoke('service_templates show test_st') @@ -92,7 +112,7 @@ class TestServiceTemplatesList(TestCliBase): mock_storage.service_template.list.assert_called_with( sort={sort_by_in_output: order_in_output}) - assert SERVICE_TEMPLATE_NAME in self.logger_output_string + assert mock_models.SERVICE_TEMPLATE_NAME in self.logger_output_string class TestServiceTemplatesStore(TestCliBase): @@ -107,9 +127,10 @@ class TestServiceTemplatesStore(TestCliBase): monkeypatch.setattr(Core, 'create_service_template', mock_object) monkeypatch.setattr(service_template_utils, 'get', mock_object) - self.invoke('service_templates store stubpath {name}'.format(name=SERVICE_TEMPLATE_NAME)) - assert 'Service template {name} stored'.format(name=SERVICE_TEMPLATE_NAME) \ - in self.logger_output_string + self.invoke('service_templates store stubpath {name}'.format( + name=mock_models.SERVICE_TEMPLATE_NAME)) + assert 'Service template {name} stored'.format( + name=mock_models.SERVICE_TEMPLATE_NAME) in self.logger_output_string def test_store_raises_exception_resulting_from_name_uniqueness(self, monkeypatch, mock_object): @@ -149,9 +170,10 @@ class TestServiceTemplatesDelete(TestCliBase): monkeypatch.setattr(_Environment, 'model_storage', mock_object) monkeypatch.setattr(Core, 'delete_service_template', mock_object) - self.invoke('service_templates delete {name}'.format(name=SERVICE_TEMPLATE_NAME)) - assert 'Service template {name} deleted'.format(name=SERVICE_TEMPLATE_NAME) \ - in self.logger_output_string + self.invoke('service_templates delete {name}'.format( + name=mock_models.SERVICE_TEMPLATE_NAME)) + assert 'Service template {name} deleted'.format( + name=mock_models.SERVICE_TEMPLATE_NAME) in self.logger_output_string def test_delete_raises_exception(self, monkeypatch, mock_object): @@ -176,10 +198,10 @@ class TestServiceTemplatesInputs(TestCliBase): def test_inputs_existing_inputs(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - input = create_parameter(name='input1', value='value1') - st = create_service_template(inputs={'input1': input}) + input = mock_models.create_parameter(name='input1', value='value1') + st = mock_models.create_service_template(inputs={'input1': input}) monkeypatch.setattr(mock_storage.service_template, 'get_by_name', - MagicMock(return_value=st)) + mock.MagicMock(return_value=st)) self.invoke('service_templates inputs with_inputs') assert 'input1' in self.logger_output_string and 'value1' in self.logger_output_string http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/test_services.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py index 7e48593..2f87e04 100644 --- a/tests/cli/test_services.py +++ b/tests/cli/test_services.py @@ -1,13 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import pytest -from mock import ANY, MagicMock -from aria.cli.exceptions import AriaCliError +import mock + from aria.cli.env import _Environment +from aria.cli.exceptions import AriaCliError from aria.core import Core from aria.exceptions import (AriaException, DependentActiveExecutionsError, DependentAvailableNodesError) from aria.storage import exceptions as storage_exceptions -from tests.cli.base_test import TestCliBase, raise_exception, assert_exception_raised, mock_storage #pylint: disable=unused-import -from tests.mock.models import create_service_with_dependencies, SERVICE_TEMPLATE_NAME, SERVICE_NAME + +from .base_test import ( + TestCliBase, + raise_exception, + assert_exception_raised, + mock_storage #pylint: disable=unused-import +) +from ..mock import models as mock_models class TestServicesList(TestCliBase): @@ -29,8 +51,8 @@ class TestServicesList(TestCliBase): mock_storage.service.list.assert_called_once_with(sort={sort_by_in_output: order_in_output}, filters={}) assert 'Services:' in self.logger_output_string - assert SERVICE_TEMPLATE_NAME in self.logger_output_string - assert SERVICE_NAME in self.logger_output_string + assert mock_models.SERVICE_TEMPLATE_NAME in self.logger_output_string + assert mock_models.SERVICE_NAME in self.logger_output_string @pytest.mark.parametrize('sort_by, order, sort_by_in_output, order_in_output', [ ('', '', 'created_at', 'asc'), @@ -47,10 +69,10 @@ class TestServicesList(TestCliBase): assert 'Listing all services...' not in self.logger_output_string mock_storage.service.list.assert_called_once_with(sort={sort_by_in_output: order_in_output}, - filters={'service_template': ANY}) + filters={'service_template': mock.ANY}) assert 'Services:' in self.logger_output_string - assert SERVICE_TEMPLATE_NAME in self.logger_output_string - assert SERVICE_NAME in self.logger_output_string + assert mock_models.SERVICE_TEMPLATE_NAME in self.logger_output_string + assert mock_models.SERVICE_NAME in self.logger_output_string class TestServicesCreate(TestCliBase): @@ -64,7 +86,7 @@ class TestServicesCreate(TestCliBase): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - m = MagicMock(return_value=create_service_with_dependencies()) + m = mock.MagicMock(return_value=mock_models.create_service_with_dependencies()) monkeypatch.setattr(Core, 'create_service', m) self.invoke('services create -t test_st test_s') assert "Service created. The service's name is test_s" in self.logger_output_string @@ -128,13 +150,15 @@ class TestServicesDelete(TestCliBase): def test_delete_active_execution_error(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) mock_service_with_execution = \ - MagicMock(return_value=create_service_with_dependencies(include_execution=True)) + mock.MagicMock(return_value=mock_models.create_service_with_dependencies( + include_execution=True)) monkeypatch.setattr(mock_storage.service, 'get', mock_service_with_execution) assert_exception_raised( self.invoke('services delete test_s'), expected_exception=DependentActiveExecutionsError, expected_msg="Can't delete service {name} - there is an active execution " - "for this service. Active execution id: 1".format(name=SERVICE_NAME)) + "for this service. Active execution id: 1" + .format(name=mock_models.SERVICE_NAME)) def test_delete_available_nodes_error(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) @@ -142,8 +166,8 @@ class TestServicesDelete(TestCliBase): self.invoke('services delete test_s'), expected_exception=DependentAvailableNodesError, expected_msg="Can't delete service {name} - there are available nodes " - "for this service. Available node ids: 1".format(name=SERVICE_NAME) - ) + "for this service. Available node ids: 1" + .format(name=mock_models.SERVICE_NAME)) def test_delete_available_nodes_error_with_force(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) @@ -175,8 +199,8 @@ class TestServicesInputs(TestCliBase): def test_inputs_one_input(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) - s = create_service_with_dependencies(include_input=True) - monkeypatch.setattr(mock_storage.service, 'get_by_name', MagicMock(return_value=s)) + s = mock_models.create_service_with_dependencies(include_input=True) + monkeypatch.setattr(mock_storage.service, 'get_by_name', mock.MagicMock(return_value=s)) self.invoke('services inputs test_s') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/utils.py ---------------------------------------------------------------------- diff --git a/tests/cli/utils.py b/tests/cli/utils.py index e33203e..a1e0c9a 100644 --- a/tests/cli/utils.py +++ b/tests/cli/utils.py @@ -1,7 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import logging + from mock import MagicMock -from tests.mock import models as mock_models +from ..mock import models as mock_models def setup_logger(logger_name,
