Add test for non `unique name` exception from service-templates store
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/286ce4bd Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/286ce4bd Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/286ce4bd Branch: refs/heads/cli-tests Commit: 286ce4bd953ab8fe24058edf2c39425d75251468 Parents: 5555642 Author: Avia Efrat <[email protected]> Authored: Thu Apr 6 15:02:18 2017 +0300 Committer: Avia Efrat <[email protected]> Committed: Thu Apr 6 15:02:18 2017 +0300 ---------------------------------------------------------------------- aria/cli/utils.py | 2 +- tests/cli/base_test.py | 2 +- tests/cli/test_service_templates.py | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/286ce4bd/aria/cli/utils.py ---------------------------------------------------------------------- diff --git a/aria/cli/utils.py b/aria/cli/utils.py index 99315c4..44358ec 100644 --- a/aria/cli/utils.py +++ b/aria/cli/utils.py @@ -158,4 +158,4 @@ def handle_storage_exception(e, model_class, name): 'There already a exists a {model_class} with the same name' \ .format(model_class=model_class, name=name) raise AriaCliError(msg) - raise + raise AriaCliError() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/286ce4bd/tests/cli/base_test.py ---------------------------------------------------------------------- diff --git a/tests/cli/base_test.py b/tests/cli/base_test.py index d5db9c2..1dae957 100644 --- a/tests/cli/base_test.py +++ b/tests/cli/base_test.py @@ -18,7 +18,7 @@ class TestCliBase(object): return self._logger_output.getvalue() -def assert_exception_raised(outcome, expected_exception, expected_msg): +def assert_exception_raised(outcome, expected_exception, expected_msg=''): assert isinstance(outcome.exception, expected_exception) assert expected_msg == str(outcome.exception) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/286ce4bd/tests/cli/test_service_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py index 9d210c1..c98bc7e 100644 --- a/tests/cli/test_service_templates.py +++ b/tests/cli/test_service_templates.py @@ -127,7 +127,7 @@ class TestServiceTemplatesStore(TestCliBase): self.invoke('service_templates store stubpath test_st') assert 'Service template test_st stored' in self.logger_output_string - def test_store_raises_exception(self, monkeypatch, mock_object): + def test_store_raises_exception_resulting_from_name_uniqueness(self, monkeypatch, mock_object): monkeypatch.setattr(service_template_utils, 'get', mock_object) monkeypatch.setattr(Core, @@ -142,6 +142,18 @@ class TestServiceTemplatesStore(TestCliBase): expected_msg='Could not store service template `test_st`\n' 'There already a exists a service template with the same name') + def test_store_raises_exception(self, monkeypatch, mock_object): + + monkeypatch.setattr(service_template_utils, 'get', mock_object) + monkeypatch.setattr(Core, + 'create_service_template', + raise_exception(storage_exceptions.NotFoundError)) + + outcome = self.invoke('service_templates store stubpath test_st') + assert_exception_raised( + outcome, + expected_exception=AriaCliError) + class TestServiceTemplatesDelete(TestCliBase):
