ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [10/10] incubator-ariatosca git commit: Add test for non `unique name` exception from service-templates store
Date Thu, 06 Apr 2017 14:30:24 GMT
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/fe6ee154
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/fe6ee154
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/fe6ee154

Branch: refs/heads/cli-tests
Commit: fe6ee154be942b51eec7d86e5e849290846848cb
Parents: 81f8894
Author: Avia Efrat <avia@gigaspaces.com>
Authored: Thu Apr 6 15:02:18 2017 +0300
Committer: Avia Efrat <avia@gigaspaces.com>
Committed: Thu Apr 6 17:29:56 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/fe6ee154/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/fe6ee154/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/fe6ee154/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):
 


Mime
View raw message