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 11:08:03 UTC
[1/5] incubator-ariatosca git commit: Add checking for initial logger
strings for service templates
Repository: incubator-ariatosca
Updated Branches:
refs/heads/cli-tests b0e15483d -> f4a3f5257
Add checking for initial logger strings for service templates
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/115891fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/115891fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/115891fc
Branch: refs/heads/cli-tests
Commit: 115891fc5a11693c0e85e57a1274dd5db48bc7a8
Parents: b0e1548
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Thu Apr 13 17:59:04 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Thu Apr 13 17:59:04 2017 +0300
----------------------------------------------------------------------
tests/cli/test_service_templates.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/115891fc/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py
index 500124c..f1c203f 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -14,6 +14,7 @@ class TestServiceTemplatesShow(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates show 1')
+ assert 'Showing service template 1...' in self.logger_output_string
assert 'Description:' not in self.logger_output_string
assert 'Existing services:\n[]' in self.logger_output_string
@@ -22,6 +23,7 @@ class TestServiceTemplatesShow(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates show 2')
+ assert 'Showing service template 2...' in self.logger_output_string
assert 'Description:\ntest_description' in self.logger_output_string
assert 'Existing services:\n[]' in self.logger_output_string
@@ -30,6 +32,7 @@ class TestServiceTemplatesShow(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates show 3')
+ assert 'Showing service template 3...' in self.logger_output_string
assert 'Description:\ntest_description' in self.logger_output_string
assert "Existing services:\n['test_s']" in self.logger_output_string
@@ -38,6 +41,7 @@ class TestServiceTemplatesShow(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates show 4')
+ assert 'Showing service template 4...' in self.logger_output_string
assert 'Description:' not in self.logger_output_string
assert "Existing services:\n['test_s']" in self.logger_output_string
@@ -50,6 +54,8 @@ class TestServiceTemplatesShow(TestCliBase):
expected_exception=storage_exceptions.NotFoundError,
expected_msg='Requested `ServiceTemplate` with ID `5` was not found')
+ assert 'Showing service template 5...' in self.logger_output_string
+
class TestServiceTemplatesList(TestCliBase):
@@ -57,6 +63,8 @@ class TestServiceTemplatesList(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates list')
+
+ assert 'Listing all service templates...' in self.logger_output_string
assert 'test_st' in self.logger_output_string
assert 'test_st2' in self.logger_output_string
@@ -65,18 +73,21 @@ class TestServiceTemplatesList(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_object)
self.invoke('service_templates list --sort-by name')
mock_object.service_template.list.assert_called_with(sort={'name': 'asc'})
+ assert 'Listing all service templates...' in self.logger_output_string
def test_list_descending(self, monkeypatch, mock_object):
monkeypatch.setattr(Environment, 'model_storage', mock_object)
self.invoke('service_templates list --sort-by name --descending')
mock_object.service_template.list.assert_called_with(sort={'name': 'desc'})
+ assert 'Listing all service templates...' in self.logger_output_string
def test_list_default_sorting(self, monkeypatch, mock_object):
monkeypatch.setattr(Environment, 'model_storage', mock_object)
self.invoke('service_templates list')
mock_object.service_template.list.assert_called_with(sort={'created_at': 'asc'})
+ assert 'Listing all service templates...' in self.logger_output_string
class TestServiceTemplatesStore(TestCliBase):
@@ -86,6 +97,7 @@ class TestServiceTemplatesStore(TestCliBase):
monkeypatch.setattr(Core, 'create_service_template', mock_object)
monkeypatch.setattr(service_template_utils, 'get', mock_object)
self.invoke('service_templates store stubpath test_st')
+ assert 'Storing service template test_st...' in self.logger_output_string
assert 'Service template test_st stored' in self.logger_output_string
def test_store_raises_exception_resulting_from_name_uniqueness(self, monkeypatch, mock_object):
@@ -101,6 +113,7 @@ class TestServiceTemplatesStore(TestCliBase):
expected_exception=AriaCliError,
expected_msg='Could not store service template `test_st`\n'
'There already a exists a service template with the same name')
+ assert 'Storing service template test_st...' in self.logger_output_string
def test_store_raises_exception(self, monkeypatch, mock_object):
@@ -112,6 +125,7 @@ class TestServiceTemplatesStore(TestCliBase):
assert_exception_raised(
self.invoke('service_templates store stubpath test_st'),
expected_exception=AriaCliError)
+ assert 'Storing service template test_st...' in self.logger_output_string
class TestServiceTemplatesDelete(TestCliBase):
@@ -121,6 +135,7 @@ class TestServiceTemplatesDelete(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_object)
monkeypatch.setattr(Core, 'delete_service_template', mock_object)
self.invoke('service_templates delete test_st')
+ assert 'Deleting service template test_st...' in self.logger_output_string
assert 'Service template test_st deleted' in self.logger_output_string
def test_delete_raises_exception(self, monkeypatch, mock_object):
@@ -134,6 +149,7 @@ class TestServiceTemplatesDelete(TestCliBase):
self.invoke('service_templates delete test_st'),
expected_exception=AriaCliError,
expected_msg='')
+ assert 'Deleting service template test_st...' in self.logger_output_string
class TestServiceTemplatesInputs(TestCliBase):
@@ -141,11 +157,13 @@ class TestServiceTemplatesInputs(TestCliBase):
def test_inputs_existing_inputs(self, monkeypatch, mock_storage):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates inputs with_inputs')
+ assert 'Showing inputs for service template with_inputs...' in self.logger_output_string
assert 'input1' in self.logger_output_string and 'value1' in self.logger_output_string
def test_inputs_no_inputs(self, monkeypatch, mock_storage):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates inputs without_inputs')
+ assert 'Showing inputs for service template without_inputs...' in self.logger_output_string
assert 'No inputs' in self.logger_output_string
@@ -155,6 +173,7 @@ class TestServiceTemplatesValidate(TestCliBase):
monkeypatch.setattr(Core, 'validate_service_template', mock_object)
monkeypatch.setattr(service_template_utils, 'get', mock_object)
self.invoke('service_templates validate stubpath')
+ assert 'Validating service template: stubpath' in self.logger_output_string
assert 'Service template validated successfully' in self.logger_output_string
def test_validate_raises_exception(self, monkeypatch, mock_object):
@@ -163,6 +182,7 @@ class TestServiceTemplatesValidate(TestCliBase):
assert_exception_raised(
self.invoke('service_templates validate stubpath'),
expected_exception=AriaCliError)
+ assert 'Validating service template: stubpath' in self.logger_output_string
class TestServiceTemplatesCreateArchive(TestCliBase):
@@ -170,4 +190,5 @@ class TestServiceTemplatesCreateArchive(TestCliBase):
def test_create_archive_successful(self, monkeypatch, mock_object):
monkeypatch.setattr(csar, 'write', mock_object)
self.invoke('service_templates create_archive stubpath stubdest')
+ assert 'Creating a csar archive' in self.logger_output_string
assert 'Csar archive created at stubdest' in self.logger_output_string
[5/5] incubator-ariatosca git commit: Fix tests in nodes list
Posted by av...@apache.org.
Fix tests in nodes list
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/f4a3f525
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/f4a3f525
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/f4a3f525
Branch: refs/heads/cli-tests
Commit: f4a3f5257623e0c732650ebe5f8493610e9f03d5
Parents: b683b33
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Sat Apr 15 14:07:38 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Sat Apr 15 14:07:38 2017 +0300
----------------------------------------------------------------------
tests/cli/test_nodes.py | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f4a3f525/tests/cli/test_nodes.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_nodes.py b/tests/cli/test_nodes.py
index 2313241..69c8827 100644
--- a/tests/cli/test_nodes.py
+++ b/tests/cli/test_nodes.py
@@ -53,24 +53,24 @@ class TestNodesList(TestCliBase):
assert 'test_s' in self.logger_output_string
assert 'test_n' in self.logger_output_string
- # @pytest.mark.parametrize('sort_by, order, sort_by_in_output, order_in_output', [
- # ('', '', 'service_name', 'asc'),
- # ('', ' --descending', 'service_name', 'desc'),
- # (' --sort-by name', '', 'name', 'asc'),
- # (' --sort-by name', ' --descending', 'name', 'desc')
- # ])
- # def test_list_specified_service(self, monkeypatch, mock_storage, sort_by, order,
- # sort_by_in_output, order_in_output):
- #
- # monkeypatch.setattr(Environment, 'model_storage', mock_storage)
- # self.invoke('nodes list{sort_by}{order}'.format(sort_by=sort_by,
- # order=order))
- # assert 'Listing nodes for service test_s...' not in self.logger_output_string
- # assert 'Listing all nodes...' in self.logger_output_string
- #
- # nodes_list = mock_storage.node.list
- # nodes_list.assert_called_once_with(sort={sort_by_in_output: order_in_output},
- # filters={})
- # assert 'Nodes:' in self.logger_output_string
- # assert 'test_s' in self.logger_output_string
- # assert 'test_n' in self.logger_output_string
+ @pytest.mark.parametrize('sort_by, order, sort_by_in_output, order_in_output', [
+ ('', '', 'service_name', 'asc'),
+ ('', ' --descending', 'service_name', 'desc'),
+ (' --sort-by name', '', 'name', 'asc'),
+ (' --sort-by name', ' --descending', 'name', 'desc')
+ ])
+ def test_list_no_specified_service(self, monkeypatch, mock_storage, sort_by, order,
+ sort_by_in_output, order_in_output):
+
+ monkeypatch.setattr(Environment, 'model_storage', mock_storage)
+ self.invoke('nodes list{sort_by}{order}'.format(sort_by=sort_by,
+ order=order))
+ assert 'Listing nodes for service test_s...' not in self.logger_output_string
+ assert 'Listing all nodes...' in self.logger_output_string
+
+ nodes_list = mock_storage.node.list
+ nodes_list.assert_called_once_with(sort={sort_by_in_output: order_in_output},
+ filters={})
+ assert 'Nodes:' in self.logger_output_string
+ assert 'test_s' in self.logger_output_string
+ assert 'test_n' in self.logger_output_string
[4/5] incubator-ariatosca git commit: Fix pylint issues
Posted by av...@apache.org.
Fix pylint issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/b683b333
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/b683b333
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/b683b333
Branch: refs/heads/cli-tests
Commit: b683b333d2cf8b2bdd787071cab4aacbc37180a1
Parents: 64c7368
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Sat Apr 15 14:04:54 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Sat Apr 15 14:04:54 2017 +0300
----------------------------------------------------------------------
tests/cli/runner.py | 1 -
tests/cli/test_node_templates.py | 11 +++++---
tests/cli/test_nodes.py | 47 ++++++++++++++++----------------
tests/cli/test_service_templates.py | 5 ++--
tests/cli/test_services.py | 12 ++++----
tests/mock/models.py | 2 +-
6 files changed, 42 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b683b333/tests/cli/runner.py
----------------------------------------------------------------------
diff --git a/tests/cli/runner.py b/tests/cli/runner.py
index 8b4294a..1682f95 100644
--- a/tests/cli/runner.py
+++ b/tests/cli/runner.py
@@ -3,7 +3,6 @@ import click.testing
def invoke(command_string):
- # TODO handle verbosity and co. later
command_list = command_string.split()
command, sub, args = command_list[0], command_list[1], command_list[2:]
runner = click.testing.CliRunner()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b683b333/tests/cli/test_node_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_node_templates.py b/tests/cli/test_node_templates.py
index aa202d4..090be65 100644
--- a/tests/cli/test_node_templates.py
+++ b/tests/cli/test_node_templates.py
@@ -2,7 +2,7 @@ from mock import ANY
import pytest
from aria.cli.env import Environment
-from tests.cli.base_test import TestCliBase, mock_storage
+from tests.cli.base_test import TestCliBase, mock_storage # pylint: disable=unused-import
class TestNodeTemplatesShow(TestCliBase):
@@ -14,7 +14,8 @@ class TestNodeTemplatesShow(TestCliBase):
assert 'Showing node template 1' in self.logger_output_string
assert 'Node template properties:' in self.logger_output_string
assert 'No properties' in self.logger_output_string
- assert 'prop1' not in self.logger_output_string and 'value1' not in self.logger_output_string
+ assert 'prop1' not in self.logger_output_string
+ assert 'value1' not in self.logger_output_string
assert 'No nodes' in self.logger_output_string
assert 'node1' not in self.logger_output_string
@@ -36,7 +37,8 @@ class TestNodeTemplatesShow(TestCliBase):
assert 'Showing node template 3' in self.logger_output_string
assert 'Node template properties:' in self.logger_output_string
assert 'No properties' in self.logger_output_string
- assert 'prop1' not in self.logger_output_string and 'value1' not in self.logger_output_string
+ assert 'prop1' not in self.logger_output_string
+ assert 'value1' not in self.logger_output_string
assert 'No nodes' not in self.logger_output_string
assert 'node1' in self.logger_output_string
@@ -88,7 +90,8 @@ class TestNodeTemplatesList(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('node_templates list{sort_by}{order}'.format(sort_by=sort_by, order=order))
assert 'Listing all node templates...' in self.logger_output_string
- assert 'Listing node templates for service template test_st...' not in self.logger_output_string
+ assert 'Listing node templates for service template test_st...' not in \
+ self.logger_output_string
node_templates_list = mock_storage.node_template.list
node_templates_list.assert_called_once_with(sort={sort_by_in_output: order_in_output},
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b683b333/tests/cli/test_nodes.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_nodes.py b/tests/cli/test_nodes.py
index 7817e86..2313241 100644
--- a/tests/cli/test_nodes.py
+++ b/tests/cli/test_nodes.py
@@ -2,7 +2,7 @@ import pytest
from mock import ANY
from aria.cli.env import Environment
-from tests.cli.base_test import TestCliBase, mock_storage
+from tests.cli.base_test import TestCliBase, mock_storage # pylint: disable=unused-import
class TestNodesShow(TestCliBase):
@@ -15,7 +15,8 @@ class TestNodesShow(TestCliBase):
assert 'Node:' in self.logger_output_string
assert 'Node attributes:' in self.logger_output_string
assert 'No attributes' in self.logger_output_string
- assert 'attribute1' not in self.logger_output_string and 'value1' not in self.logger_output_string
+ assert 'attribute1' not in self.logger_output_string
+ assert 'value1' not in self.logger_output_string
def test_one_attribute(self, monkeypatch, mock_storage):
@@ -52,24 +53,24 @@ class TestNodesList(TestCliBase):
assert 'test_s' in self.logger_output_string
assert 'test_n' in self.logger_output_string
- @pytest.mark.parametrize('sort_by, order, sort_by_in_output, order_in_output', [
- ('', '', 'service_name', 'asc'),
- ('', ' --descending', 'service_name', 'desc'),
- (' --sort-by name', '', 'name', 'asc'),
- (' --sort-by name', ' --descending', 'name', 'desc')
- ])
- def test_list_specified_service(self, monkeypatch, mock_storage, sort_by, order,
- sort_by_in_output, order_in_output):
-
- monkeypatch.setattr(Environment, 'model_storage', mock_storage)
- self.invoke('nodes list{sort_by}{order}'.format(sort_by=sort_by,
- order=order))
- assert 'Listing nodes for service test_s...' not in self.logger_output_string
- assert 'Listing all nodes...' in self.logger_output_string
-
- nodes_list = mock_storage.node.list
- nodes_list.assert_called_once_with(sort={sort_by_in_output: order_in_output},
- filters={})
- assert 'Nodes:' in self.logger_output_string
- assert 'test_s' in self.logger_output_string
- assert 'test_n' in self.logger_output_string
+ # @pytest.mark.parametrize('sort_by, order, sort_by_in_output, order_in_output', [
+ # ('', '', 'service_name', 'asc'),
+ # ('', ' --descending', 'service_name', 'desc'),
+ # (' --sort-by name', '', 'name', 'asc'),
+ # (' --sort-by name', ' --descending', 'name', 'desc')
+ # ])
+ # def test_list_specified_service(self, monkeypatch, mock_storage, sort_by, order,
+ # sort_by_in_output, order_in_output):
+ #
+ # monkeypatch.setattr(Environment, 'model_storage', mock_storage)
+ # self.invoke('nodes list{sort_by}{order}'.format(sort_by=sort_by,
+ # order=order))
+ # assert 'Listing nodes for service test_s...' not in self.logger_output_string
+ # assert 'Listing all nodes...' in self.logger_output_string
+ #
+ # nodes_list = mock_storage.node.list
+ # nodes_list.assert_called_once_with(sort={sort_by_in_output: order_in_output},
+ # filters={})
+ # assert 'Nodes:' in self.logger_output_string
+ # assert 'test_s' in self.logger_output_string
+ # assert 'test_n' in self.logger_output_string
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b683b333/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py
index 76c6219..987b5ef 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -6,7 +6,7 @@ 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, mock_storage
+from tests.cli.base_test import TestCliBase, assert_exception_raised, raise_exception, mock_storage # pylint: disable=unused-import
class TestServiceTemplatesShow(TestCliBase):
@@ -73,7 +73,8 @@ class TestServiceTemplatesList(TestCliBase):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
self.invoke('service_templates list{sort_by}{order}'.format(sort_by=sort_by, order=order))
- mock_storage.service_template.list.assert_called_with(sort={sort_by_in_output: order_in_output})
+ mock_storage.service_template.list.assert_called_with(
+ sort={sort_by_in_output: order_in_output})
assert 'Listing all service templates...' in self.logger_output_string
assert 'test_st' in self.logger_output_string
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b683b333/tests/cli/test_services.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py
index 38b3348..932c95b 100644
--- a/tests/cli/test_services.py
+++ b/tests/cli/test_services.py
@@ -6,7 +6,7 @@ from aria.core import Core
from aria.exceptions import (AriaException, DependentActiveExecutionsError,
DependentAvailableNodesError)
from aria.storage import exceptions as storage_exceptions
-from tests.cli.base_test import TestCliBase, mock_storage, raise_exception, assert_exception_raised
+from tests.cli.base_test import TestCliBase, raise_exception, assert_exception_raised, mock_storage #pylint: disable=unused-import
from tests.mock.models import create_service, create_service_template
@@ -107,7 +107,8 @@ class TestServicesCreate(TestCliBase):
expected_exception=AriaCliError,
expected_msg='error creating service `test_s`')
- assert 'Creating new service from service template with_inputs...' in self.logger_output_string
+ assert 'Creating new service from service template with_inputs...' in \
+ self.logger_output_string
assert 'error creating service `test_s`' in self.logger_output_string
assert 'input1' in self.logger_output_string and 'value1' in self.logger_output_string
assert "Service created. The service's name is test_s" not in self.logger_output_string
@@ -152,7 +153,6 @@ class TestServicesDelete(TestCliBase):
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
@@ -164,7 +164,8 @@ class TestServicesInputs(TestCliBase):
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
+ assert 'input1' not in self.logger_output_string
+ assert 'value1' not in self.logger_output_string
def test_inputs_one_input(self, monkeypatch, mock_storage):
@@ -172,5 +173,6 @@ class TestServicesInputs(TestCliBase):
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 'input1' in self.logger_output_string
+ assert '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/b683b333/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 2f641ad..90deb82 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -144,7 +144,7 @@ def create_dependent_node_template(
def create_node(name, dependency_node_template, service, state=models.Node.INITIAL,
runtime_properties=None):
runtime_properties = runtime_properties or {}
- tmp_runtime_properties = {'ip': '1.1.1.1'}
+ # tmp_runtime_properties = {'ip': '1.1.1.1'}
node = models.Node(
name=name,
type=dependency_node_template.type,
[2/5] incubator-ariatosca git commit: Parametrize service templates
list tests
Posted by av...@apache.org.
Parametrize service templates list tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/006baa25
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/006baa25
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/006baa25
Branch: refs/heads/cli-tests
Commit: 006baa25d8ddbeae1d91cbf14d97d92e7d783214
Parents: 115891f
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Thu Apr 13 18:29:04 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Thu Apr 13 18:29:04 2017 +0300
----------------------------------------------------------------------
tests/cli/test_service_templates.py | 36 +++++++++++---------------------
tests/cli/test_services.py | 29 +++++++++++++------------
tests/cli/utils.py | 9 ++++----
3 files changed, 30 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/006baa25/tests/cli/test_service_templates.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py
index f1c203f..76c6219 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -1,3 +1,5 @@
+import pytest
+
from aria.cli import service_template_utils, csar
from aria.cli.env import Environment
from aria.cli.exceptions import AriaCliError
@@ -59,35 +61,21 @@ class TestServiceTemplatesShow(TestCliBase):
class TestServiceTemplatesList(TestCliBase):
- def test_list_two_service_templates(self, monkeypatch, mock_storage):
+ @pytest.mark.parametrize('sort_by, order, sort_by_in_output, order_in_output', [
+ ('', '', 'created_at', 'asc'),
+ ('', ' --descending', 'created_at', 'desc'),
+ (' --sort-by name', '', 'name', 'asc'),
+ (' --sort-by name', ' --descending', 'name', 'desc')
+ ])
+ def test_all_sorting_combinations(self, monkeypatch, mock_storage, sort_by, order,
+ sort_by_in_output, order_in_output):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
- self.invoke('service_templates list')
+ self.invoke('service_templates list{sort_by}{order}'.format(sort_by=sort_by, order=order))
+ mock_storage.service_template.list.assert_called_with(sort={sort_by_in_output: order_in_output})
assert 'Listing all service templates...' in self.logger_output_string
assert 'test_st' in self.logger_output_string
- assert 'test_st2' in self.logger_output_string
-
- def test_list_ascending(self, monkeypatch, mock_object):
-
- monkeypatch.setattr(Environment, 'model_storage', mock_object)
- self.invoke('service_templates list --sort-by name')
- mock_object.service_template.list.assert_called_with(sort={'name': 'asc'})
- assert 'Listing all service templates...' in self.logger_output_string
-
- def test_list_descending(self, monkeypatch, mock_object):
-
- monkeypatch.setattr(Environment, 'model_storage', mock_object)
- self.invoke('service_templates list --sort-by name --descending')
- mock_object.service_template.list.assert_called_with(sort={'name': 'desc'})
- assert 'Listing all service templates...' in self.logger_output_string
-
- def test_list_default_sorting(self, monkeypatch, mock_object):
-
- monkeypatch.setattr(Environment, 'model_storage', mock_object)
- self.invoke('service_templates list')
- mock_object.service_template.list.assert_called_with(sort={'created_at': 'asc'})
- assert 'Listing all service templates...' in self.logger_output_string
class TestServiceTemplatesStore(TestCliBase):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/006baa25/tests/cli/test_services.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py
index e23848b..89b3a89 100644
--- a/tests/cli/test_services.py
+++ b/tests/cli/test_services.py
@@ -18,17 +18,16 @@ class TestServicesList(TestCliBase):
(' --sort-by name', '', 'name', 'asc'),
(' --sort-by name', ' --descending', 'name', 'desc')
])
- def test_list_specified_service_template(self, monkeypatch, mock_storage, sort_by, order,
- sort_by_in_output, order_in_output):
+ def test_list_no_specified_service_template(self, monkeypatch, mock_storage, sort_by, order,
+ sort_by_in_output, order_in_output):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
- self.invoke('services list -t test_st{sort_by}{order}'.format(sort_by=sort_by, order=order))
- assert 'Listing services for service template test_st...' in self.logger_output_string
- assert 'Listing all services...' not in self.logger_output_string
+ self.invoke('services list{sort_by}{order}'.format(sort_by=sort_by, order=order))
+ assert 'Listing all services...' in self.logger_output_string
+ assert 'Listing services for service template' not in self.logger_output_string
- services_list = mock_storage.service.list
- services_list.assert_called_once_with(sort={sort_by_in_output: order_in_output},
- filters={'service_template': ANY})
+ mock_storage.service.list.assert_called_once_with(sort={sort_by_in_output: order_in_output},
+ filters={})
assert 'Services:' in self.logger_output_string
assert 'test_st' in self.logger_output_string
assert 'test_s' in self.logger_output_string
@@ -39,16 +38,16 @@ class TestServicesList(TestCliBase):
(' --sort-by name', '', 'name', 'asc'),
(' --sort-by name', ' --descending', 'name', 'desc')
])
- def test_list_no_specified_service_template(self, monkeypatch, mock_storage, sort_by, order,
- sort_by_in_output, order_in_output):
+ def test_list_specified_service_template(self, monkeypatch, mock_storage, sort_by, order,
+ sort_by_in_output, order_in_output):
monkeypatch.setattr(Environment, 'model_storage', mock_storage)
- self.invoke('services list{sort_by}{order}'.format(sort_by=sort_by, order=order))
- assert 'Listing all services...' in self.logger_output_string
- assert 'Listing services for service template' not in self.logger_output_string
+ self.invoke('services list -t test_st{sort_by}{order}'.format(sort_by=sort_by, order=order))
+ assert 'Listing services for service template test_st...' in self.logger_output_string
+ assert 'Listing all services...' not in self.logger_output_string
- services_list = mock_storage.service.list
- services_list.assert_called_once_with(sort={sort_by_in_output: order_in_output}, filters={})
+ mock_storage.service.list.assert_called_once_with(sort={sort_by_in_output: order_in_output},
+ filters={'service_template': ANY})
assert 'Services:' in self.logger_output_string
assert 'test_st' in self.logger_output_string
assert 'test_s' in self.logger_output_string
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/006baa25/tests/cli/utils.py
----------------------------------------------------------------------
diff --git a/tests/cli/utils.py b/tests/cli/utils.py
index a3868ab..94523e2 100644
--- a/tests/cli/utils.py
+++ b/tests/cli/utils.py
@@ -47,7 +47,7 @@ def setup_logger(logger_name,
class MockStorage(object):
def __init__(self):
- self.service_template = MockServiceTemplateStorage
+ self.service_template = MockServiceTemplateStorage()
self.service = MockServiceStorage()
self.node_template = MockNodeTemplateStorage()
self.node = MockNodeStorage()
@@ -55,10 +55,8 @@ class MockStorage(object):
class MockServiceTemplateStorage(object):
- @staticmethod
- def list(**_):
- return [mock_models.create_service_template('test_st'),
- mock_models.create_service_template('test_st2')]
+ def __init__(self):
+ self.list = MagicMock(return_value=[mock_models.create_service_template('test_st')])
@staticmethod
def get(id):
@@ -163,6 +161,7 @@ class MockNodeTemplateStorage(object):
mock_models.create_node('node1', nt, s)
return nt
+
class MockNodeStorage(object):
def __init__(self):
[3/5] incubator-ariatosca git commit: Refactor service names in the
mock storage
Posted by av...@apache.org.
Refactor service names in the mock storage
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/64c7368a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/64c7368a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/64c7368a
Branch: refs/heads/cli-tests
Commit: 64c7368ad61a0d80a88d142b5ac08a84bcdd4f04
Parents: 006baa2
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Thu Apr 13 18:40:17 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Thu Apr 13 18:40:17 2017 +0300
----------------------------------------------------------------------
tests/cli/test_services.py | 4 ++--
tests/cli/utils.py | 6 ++----
2 files changed, 4 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/64c7368a/tests/cli/test_services.py
----------------------------------------------------------------------
diff --git a/tests/cli/test_services.py b/tests/cli/test_services.py
index 89b3a89..38b3348 100644
--- a/tests/cli/test_services.py
+++ b/tests/cli/test_services.py
@@ -128,7 +128,7 @@ class TestServicesDelete(TestCliBase):
assert_exception_raised(
self.invoke('services delete service_with_active_executions'),
expected_exception=DependentActiveExecutionsError,
- expected_msg="Can't delete service service_with_active_executions - there is an active "
+ expected_msg="Can't delete service test_s - there is an active "
"execution for this service. Active execution id: 1"
)
assert 'Deleting service service_with_active_executions...' in self.logger_output_string
@@ -138,7 +138,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_available_nodes - "
+ expected_msg="Can't delete service test_s - "
"there are available nodes for this service. Available node ids: 1"
)
assert 'Deleting service service_with_available_nodes...' in self.logger_output_string
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/64c7368a/tests/cli/utils.py
----------------------------------------------------------------------
diff --git a/tests/cli/utils.py b/tests/cli/utils.py
index 94523e2..499732a 100644
--- a/tests/cli/utils.py
+++ b/tests/cli/utils.py
@@ -99,13 +99,12 @@ class MockServiceStorage(object):
@staticmethod
def get(id):
test_st = mock_models.create_service_template('test_st')
+ test_s = mock_models.create_service(test_st, 'test_s')
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]
elif 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,
@@ -127,9 +126,8 @@ class MockServiceStorage(object):
m.id = '2'
return m
elif name == 'service_with_no_inputs':
- test_s. name = 'service_with_no_inputs'
+ pass
elif name == 'service_with_one_input':
- test_s.name = 'service_with_one_input'
input = mock_models.create_parameter(name='input1', value='value1')
test_s.inputs = {'input1': input}