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/05 13:58:19 UTC
[03/17] incubator-ariatosca git commit: Add test for trying to show a
service template with an invalid id
Add test for trying to show a service template with an invalid id
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/530cfce0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/530cfce0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/530cfce0
Branch: refs/heads/cli-tests
Commit: 530cfce0db91f6148d8d41591d004077d049c2ae
Parents: 7759b51
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Wed Apr 5 13:00:14 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Wed Apr 5 16:49:57 2017 +0300
----------------------------------------------------------------------
tests/cli/base_test.py | 5 +++++
tests/cli/test_service_templates.py | 14 +++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/530cfce0/tests/cli/base_test.py
----------------------------------------------------------------------
diff --git a/tests/cli/base_test.py b/tests/cli/base_test.py
index 3b7e746..d77260e 100644
--- a/tests/cli/base_test.py
+++ b/tests/cli/base_test.py
@@ -16,3 +16,8 @@ class TestCliBase(object):
@property
def logger_output_string(self):
return self._logger_output.getvalue()
+
+
+def assert_exception_raised(outcome, expected_exception, expected_msg):
+ assert isinstance(outcome.exception, expected_exception)
+ assert expected_msg == str(outcome.exception)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/530cfce0/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py
index 91ddd92..900b8a4 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -1,7 +1,7 @@
from aria.cli.env import Environment
-from base_test import TestCliBase
+from base_test import TestCliBase, assert_exception_raised
from aria.modeling.models import ServiceTemplate, Service
-
+from aria.storage import exceptions as storage_exceptions
class MockStorage(object):
@@ -63,4 +63,12 @@ class TestServiceTemplatesShow(TestCliBase):
self.invoke('service_templates show 4')
assert 'Description:' not in self.logger_output_string
- assert "Existing services:\n['test_s']" in self.logger_output_string
\ No newline at end of file
+ assert "Existing services:\n['test_s']" in self.logger_output_string
+
+ def test_show_exception_raise_when_no_service_template_with_given_id(self):
+
+ outcome = self.invoke('service_templates show 5')
+ assert_exception_raised(
+ outcome,
+ expected_exception=storage_exceptions.NotFoundError,
+ expected_msg='Requested `ServiceTemplate` with ID `5` was not found')