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 14:31:17 UTC

[5/6] incubator-ariatosca git commit: Add tests for service-templates validate

Add tests for service-templates validate


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/314f09e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/314f09e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/314f09e7

Branch: refs/heads/ARIA-48-aria-cli
Commit: 314f09e736cd6824da4f4839ff260ba87699bfa2
Parents: 54f3f52
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Thu Apr 6 16:23:02 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Thu Apr 6 17:29:56 2017 +0300

----------------------------------------------------------------------
 aria/cli/commands/service_templates.py |  3 +--
 tests/cli/test_service_templates.py    | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/314f09e7/aria/cli/commands/service_templates.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py
index 5fcc973..e2e21c7 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -169,8 +169,7 @@ def inputs(service_template_name, model_storage, logger):
 @aria.pass_resource_storage
 @aria.pass_plugin_manager
 @aria.pass_logger
-def validate_service_template(service_template, model_storage, resource_storage, plugin_manager,
-                              logger):
+def validate(service_template, model_storage, resource_storage, plugin_manager, logger):
     """Validate a service template
 
     `SERVICE_TEMPLATE` is the path or url of the service template or archive to validate.

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/314f09e7/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py
index 3d5a8fb..f79b22e 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -2,6 +2,7 @@ from aria.cli import service_template_utils
 from aria.cli.env import Environment
 from aria.cli.exceptions import AriaCliError
 from aria.core import Core
+from aria.exceptions import AriaException
 from aria.storage import exceptions as storage_exceptions
 from tests.cli.base_test import TestCliBase, assert_exception_raised, raise_exception
 from tests.mock import models
@@ -198,3 +199,19 @@ class TestServiceTemplatesInputs(TestCliBase):
         monkeypatch.setattr(Environment, 'model_storage', MockStorage())
         self.invoke('service_templates inputs without_inputs')
         assert 'No inputs' in self.logger_output_string
+
+
+class TestServiceTemplatesValidate(TestCliBase):
+
+    def test_validate_no_exception(self, monkeypatch, mock_object):
+        monkeypatch.setattr(Core, 'validate_service_template', mock_object)
+        monkeypatch.setattr(service_template_utils, 'get', mock_object)
+        self.invoke('service_templates validate stubpath')
+        assert 'Service template validated successfully' in self.logger_output_string
+
+    def test_validate_raises_exception(self, monkeypatch, mock_object):
+        monkeypatch.setattr(Core, 'validate_service_template', raise_exception(AriaException))
+        monkeypatch.setattr(service_template_utils, 'get', mock_object)
+        assert_exception_raised(
+            self.invoke('service_templates validate stubpath'),
+            expected_exception=AriaCliError)