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/04/06 12:57:14 UTC

[7/8] incubator-ariatosca git commit: Add test for non `unique name` exception from service-templates store

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/7ed0f899
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/7ed0f899
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/7ed0f899

Branch: refs/heads/cli-tests
Commit: 7ed0f8995090d15fa51441a3735f08f8eb208100
Parents: 6e30d8a
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Thu Apr 6 15:02:18 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Thu Apr 6 15:56:55 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/7ed0f899/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/7ed0f899/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/7ed0f899/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):