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 <[email protected]> Authored: Thu Apr 13 17:59:04 2017 +0300 Committer: Avia Efrat <[email protected]> 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
