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/15 12:56:45 UTC
[18/19] incubator-ariatosca git commit: Add tests for services inputs
Add tests for services 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/7be3c645
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/7be3c645
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/7be3c645
Branch: refs/heads/cli-tests
Commit: 7be3c645c415e6eaaf42b2f52fdf52308bfedad4
Parents: b332bcb
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Thu Apr 13 12:12:22 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Sat Apr 15 15:51:54 2017 +0300
----------------------------------------------------------------------
tests/cli/test_service_templates.py | 2 +-
tests/cli/test_services.py | 26 +++++++++++++++++++++++++-
tests/cli/utils.py | 12 +++++++++++-
3 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7be3c645/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py
index d8ea731..45656cd 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -55,7 +55,7 @@ class TestServiceTemplatesShow(TestCliBase):
class TestServiceTemplatesList(TestCliBase):
- def test_list_one_service_template(self, monkeypatch, mock_storage):
+ def test_list_two_service_templates(self, monkeypatch, mock_storage):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates list')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7be3c645/tests/cli/test_services.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py
index af10a45..7538512 100644
--- a/tests/cli/test_services.py
+++ b/tests/cli/test_services.py
@@ -141,7 +141,7 @@ class TestServicesDelete(TestCliBase):
assert_exception_raised(
self.invoke('services delete service_with_available_nodes'),
expected_exception=DependentAvailableNodesError,
- expected_msg="Can't delete service service_with_active_executions - "
+ expected_msg="Can't delete service service_with_available_nodes - "
"there are available nodes for this service. Available node ids: 1"
)
assert 'Deleting service service_with_available_nodes...' in self.logger_output_string
@@ -153,3 +153,27 @@ class TestServicesDelete(TestCliBase):
assert mock_storage.service.delete.call_count == 1
assert 'Deleting service service_with_available_nodes...' in self.logger_output_string
assert 'Service service_with_available_nodes deleted' in self.logger_output_string
+
+class TestServicesOutputs(TestCliBase):
+ # TODO implement this after the `services outputs` command will work
+ pass
+
+
+class TestServicesInputs(TestCliBase):
+
+ def test_inputs_no_inputs(self, monkeypatch, mock_storage):
+ monkeypatch.setattr(Environment, 'model_storage', mock_storage)
+ self.invoke('services inputs service_with_no_inputs')
+
+ assert 'Showing inputs for service service_with_no_inputs...' in self.logger_output_string
+ assert 'No inputs' in self.logger_output_string
+ assert 'input1' not in self.logger_output_string and 'value1' not in self.logger_output_string
+
+ def test_inputs_one_input(self, monkeypatch, mock_storage):
+
+ monkeypatch.setattr(Environment, 'model_storage', mock_storage)
+ self.invoke('services inputs service_with_one_input')
+
+ assert 'Showing inputs for service service_with_one_input...' in self.logger_output_string
+ assert 'input1' in self.logger_output_string and 'value1' in self.logger_output_string
+ assert 'No inputs' not in self.logger_output_string
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7be3c645/tests/cli/utils.py
----------------------------------------------------------------------
diff --git a/tests/cli/utils.py b/tests/cli/utils.py
index 222a225..21047c9 100644
--- a/tests/cli/utils.py
+++ b/tests/cli/utils.py
@@ -99,12 +99,13 @@ class MockServiceStorage(object):
@staticmethod
def get(id):
test_st = mock_models.create_service_template('test_st')
- test_s = mock_models.create_service(test_st, 'service_with_active_executions')
if id == '1':
+ test_s = mock_models.create_service(test_st, 'service_with_active_executions')
execution = mock_models.create_execution(test_s, status=models.Execution.STARTED)
execution.id = '1'
test_s.executions = [execution]
if id == '2':
+ test_s = mock_models.create_service(test_st, 'service_with_available_nodes')
node_template = mock_models.create_node_template(service_template=test_st)
node = mock_models.create_node(name='test_node',
dependency_node_template=node_template,
@@ -115,6 +116,7 @@ class MockServiceStorage(object):
@staticmethod
def get_by_name(name):
+ test_st = mock_models.create_service_template('test_st')
if name == 'service_with_active_executions':
m = MagicMock()
m.id = '1'
@@ -123,3 +125,11 @@ class MockServiceStorage(object):
m = MagicMock()
m.id = '2'
return m
+ if name == 'service_with_no_inputs':
+ test_s = mock_models.create_service(test_st, 'service_with_no_inputs')
+ if name == 'service_with_one_input':
+ test_s = mock_models.create_service(test_st, 'service_with_one_input')
+ input = mock_models.create_input(name='input1', value='value1')
+ test_s.inputs = {'input1': input}
+
+ return test_s