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:15 UTC

[8/8] incubator-ariatosca git commit: Add tests for service-templates inputs

Add tests for service-templates inputs


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

Branch: refs/heads/cli-tests
Commit: e5443f2c1451fa049a983ae41a736982d91661a4
Parents: 7ed0f89
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Thu Apr 6 15:54:26 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Thu Apr 6 15:56:55 2017 +0300

----------------------------------------------------------------------
 tests/cli/test_service_templates.py | 23 +++++++++++++++++++++++
 tests/mock/models.py                |  5 +++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e5443f2c/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py
index c98bc7e..3d5a8fb 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -44,6 +44,16 @@ class MockServiceTemplateStorage(object):
             st.services = [service]
         return st
 
+    @staticmethod
+    def get_by_name(name):
+        st = models.create_service_template('test_st')
+        if name == 'with_inputs':
+            input = models.create_input(name='input1', value='value1')
+            st.inputs = {'input1': input}
+        if name == 'without_inputs':
+            st.inputs = {}
+        return st
+
 
 class TestServiceTemplatesShow(TestCliBase):
 
@@ -175,3 +185,16 @@ class TestServiceTemplatesDelete(TestCliBase):
             self.invoke('service_templates delete test_st'),
             expected_exception=AriaCliError,
             expected_msg='')
+
+
+class TestServiceTemplatesInputs(TestCliBase):
+
+    def test_inputs_existing_inputs(self, monkeypatch):
+        monkeypatch.setattr(Environment, 'model_storage', MockStorage())
+        self.invoke('service_templates inputs with_inputs')
+        assert 'input1' in self.logger_output_string and 'value1' in self.logger_output_string
+
+    def test_inputs_no_inputs(self, monkeypatch):
+        monkeypatch.setattr(Environment, 'model_storage', MockStorage())
+        self.invoke('service_templates inputs without_inputs')
+        assert 'No inputs' in self.logger_output_string

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e5443f2c/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 6b7f810..9771fe2 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -221,6 +221,11 @@ def create_plugin_specification(name='test_plugin', version='0.1'):
     )
 
 
+def create_input(name, value):
+    p = models.Parameter()
+    return p.wrap(name, value)
+
+
 def _dictify(item):
     return dict(((item.name, item),))