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 13:26:17 UTC

[1/2] incubator-ariatosca git commit: Add tests for service-templates validate

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/cli-tests e5443f2c1 -> 479a3b10c


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

Branch: refs/heads/cli-tests
Commit: 820902cadb1d3a33d94d1855433577ac0b075221
Parents: e5443f2
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 16:23:02 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/820902ca/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/820902ca/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)


[2/2] incubator-ariatosca git commit: Clean up the code a bit

Posted by av...@apache.org.
Clean up the code a bit


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

Branch: refs/heads/cli-tests
Commit: 479a3b10cf64ff636b27802df008807a2938bbca
Parents: 820902c
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Thu Apr 6 16:25:47 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Thu Apr 6 16:25:47 2017 +0300

----------------------------------------------------------------------
 tests/cli/test_service_templates.py | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/479a3b10/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py
index f79b22e..d357fad 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -94,9 +94,8 @@ class TestServiceTemplatesShow(TestCliBase):
 
         # TODO consider removing as it does not seem to test the cli but rather the message received
         # from the storage
-        outcome = self.invoke('service_templates show 5')
         assert_exception_raised(
-            outcome,
+            self.invoke('service_templates show 5'),
             expected_exception=storage_exceptions.NotFoundError,
             expected_msg='Requested `ServiceTemplate` with ID `5` was not found')
 
@@ -146,9 +145,8 @@ class TestServiceTemplatesStore(TestCliBase):
                             raise_exception(storage_exceptions.NotFoundError,
                                             msg='UNIQUE constraint failed'))
 
-        outcome = self.invoke('service_templates store stubpath test_st')
         assert_exception_raised(
-            outcome,
+            self.invoke('service_templates store stubpath test_st'),
             expected_exception=AriaCliError,
             expected_msg='Could not store service template `test_st`\n'
                          'There already a exists a service template with the same name')
@@ -160,9 +158,8 @@ class TestServiceTemplatesStore(TestCliBase):
                             'create_service_template',
                             raise_exception(storage_exceptions.NotFoundError))
 
-        outcome = self.invoke('service_templates store stubpath test_st')
         assert_exception_raised(
-            outcome,
+            self.invoke('service_templates store stubpath test_st'),
             expected_exception=AriaCliError)