Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-48-aria-cli c16166c12 -> 8a4665a8f
Fix 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/8a4665a8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8a4665a8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8a4665a8 Branch: refs/heads/ARIA-48-aria-cli Commit: 8a4665a8fc570c1bf88f958d65c410575b05c268 Parents: c16166c Author: Avia Efrat <[email protected]> Authored: Wed Apr 19 16:15:57 2017 +0300 Committer: Avia Efrat <[email protected]> Committed: Wed Apr 19 16:15:57 2017 +0300 ---------------------------------------------------------------------- aria/cli/commands/node_templates.py | 2 +- aria/cli/commands/nodes.py | 4 ++-- aria/cli/commands/services.py | 2 +- tests/cli/base_test.py | 2 +- tests/cli/test_service_templates.py | 13 ++++++------- tests/cli/test_services.py | 16 +++++++--------- 6 files changed, 18 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/aria/cli/commands/node_templates.py ---------------------------------------------------------------------- diff --git a/aria/cli/commands/node_templates.py b/aria/cli/commands/node_templates.py index 4d53f54..50c755e 100644 --- a/aria/cli/commands/node_templates.py +++ b/aria/cli/commands/node_templates.py @@ -88,6 +88,6 @@ def list(service_template_name, sort_by, descending, model_storage, logger): node_templates_list = model_storage.node_template.list( filters=filters, - sort=utils.storage_sort_param(sort_by, descending)).items + sort=utils.storage_sort_param(sort_by, descending)) table.print_data(NODE_TEMPLATE_COLUMNS, node_templates_list, 'Node templates:') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/aria/cli/commands/nodes.py ---------------------------------------------------------------------- diff --git a/aria/cli/commands/nodes.py b/aria/cli/commands/nodes.py index eeab338..e43493f 100644 --- a/aria/cli/commands/nodes.py +++ b/aria/cli/commands/nodes.py @@ -43,7 +43,7 @@ def show(node_id, model_storage, logger): logger.info('Showing node {0}'.format(node_id)) node = model_storage.node.get(node_id) - table.print_data(NODE_COLUMNS, node, 'Node:', 50) + table.print_data(NODE_COLUMNS, node, 'Node:', col_max_width=50) # print node attributes logger.info('Node attributes:') @@ -82,6 +82,6 @@ def list(service_name, nodes_list = model_storage.node.list( filters=filters, - sort=utils.storage_sort_param(sort_by, descending)).items + sort=utils.storage_sort_param(sort_by, descending)) table.print_data(NODE_COLUMNS, nodes_list, 'Nodes:') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/aria/cli/commands/services.py ---------------------------------------------------------------------- diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py index 1aa99f3..50b530a 100644 --- a/aria/cli/commands/services.py +++ b/aria/cli/commands/services.py @@ -66,7 +66,7 @@ def list(service_template_name, services_list = model_storage.service.list( sort=utils.storage_sort_param(sort_by=sort_by, descending=descending), - filters=filters).items + filters=filters) table.print_data(SERVICE_COLUMNS, services_list, 'Services:') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/tests/cli/base_test.py ---------------------------------------------------------------------- diff --git a/tests/cli/base_test.py b/tests/cli/base_test.py index 4a1d4ab..da9d72c 100644 --- a/tests/cli/base_test.py +++ b/tests/cli/base_test.py @@ -55,7 +55,7 @@ class TestCliBase(object): def assert_exception_raised(outcome, expected_exception, expected_msg=''): assert isinstance(outcome.exception, expected_exception) - assert expected_msg == str(outcome.exception) + assert expected_msg in str(outcome.exception) # This exists as I wanted to mocked a function using monkeypatch to return a function that raises an http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/tests/cli/test_service_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py index 058853f..1512b7d 100644 --- a/tests/cli/test_service_templates.py +++ b/tests/cli/test_service_templates.py @@ -142,9 +142,8 @@ class TestServiceTemplatesStore(TestCliBase): assert_exception_raised( self.invoke('service_templates store stubpath test_st'), - expected_exception=AriaCliError, - expected_msg='Could not store service template `test_st`\n' - 'There already a exists a service template with the same name') + expected_exception=storage_exceptions.NotFoundError, + expected_msg='There already a exists a service template with the same name') def test_store_raises_exception(self, monkeypatch, mock_object): @@ -155,7 +154,7 @@ class TestServiceTemplatesStore(TestCliBase): assert_exception_raised( self.invoke('service_templates store stubpath test_st'), - expected_exception=AriaCliError) + expected_exception=storage_exceptions.StorageError) class TestServiceTemplatesDelete(TestCliBase): @@ -180,11 +179,11 @@ class TestServiceTemplatesDelete(TestCliBase): monkeypatch.setattr(_Environment, 'model_storage', mock_object) monkeypatch.setattr(Core, 'delete_service_template', - raise_exception(storage_exceptions.NotFoundError)) + raise_exception(storage_exceptions.StorageError)) assert_exception_raised( self.invoke('service_templates delete test_st'), - expected_exception=AriaCliError, + expected_exception=storage_exceptions.StorageError, expected_msg='') @@ -231,7 +230,7 @@ class TestServiceTemplatesValidate(TestCliBase): monkeypatch.setattr(service_template_utils, 'get', mock_object) assert_exception_raised( self.invoke('service_templates validate stubpath'), - expected_exception=AriaCliError) + expected_exception=AriaException) class TestServiceTemplatesCreateArchive(TestCliBase): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/tests/cli/test_services.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py index d3da130..3f5c3cd 100644 --- a/tests/cli/test_services.py +++ b/tests/cli/test_services.py @@ -21,6 +21,7 @@ from aria.cli.exceptions import AriaCliError from aria.core import Core from aria.exceptions import (AriaException, DependentActiveExecutionsError, DependentAvailableNodesError) +from aria.modeling.exceptions import InputsException from aria.storage import exceptions as storage_exceptions from .base_test import ( # pylint: disable=unused-import @@ -100,9 +101,8 @@ class TestServicesCreate(TestCliBase): msg='UNIQUE constraint failed')) assert_exception_raised( self.invoke('services create -t test_st test_s'), - expected_exception=AriaCliError, - expected_msg='Could not store service `test_s`\n' - 'There already a exists a service with the same name') + expected_exception=storage_exceptions.NotFoundError, + expected_msg='There already a exists a service with the same name') assert "Service created. The service's name is test_s" not in self.logger_output_string @@ -114,22 +114,20 @@ class TestServicesCreate(TestCliBase): assert_exception_raised( self.invoke('services create -t test_st test_s'), - expected_exception=AriaCliError) + expected_exception=storage_exceptions.NotFoundError) assert "Service created. The service's name is test_s" not in self.logger_output_string - def test_raises_aria_exception(self, monkeypatch, mock_storage): + def test_raises_inputs_exception(self, monkeypatch, mock_storage): monkeypatch.setattr(_Environment, 'model_storage', mock_storage) monkeypatch.setattr(Core, 'create_service', - raise_exception(AriaException, msg='error creating service `test_s`')) + raise_exception(InputsException)) assert_exception_raised( self.invoke('services create -t with_inputs test_s'), - expected_exception=AriaCliError, - expected_msg='error creating service `test_s`') + expected_exception=InputsException) - assert 'error creating service `test_s`' in self.logger_output_string assert "Service created. The service's name is test_s" not in self.logger_output_string
