Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3F740200C64 for ; Thu, 13 Apr 2017 16:16:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3E61B160B8B; Thu, 13 Apr 2017 14:16:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3431A160BA7 for ; Thu, 13 Apr 2017 16:16:19 +0200 (CEST) Received: (qmail 43522 invoked by uid 500); 13 Apr 2017 14:16:18 -0000 Mailing-List: contact dev-help@ariatosca.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ariatosca.incubator.apache.org Delivered-To: mailing list dev@ariatosca.incubator.apache.org Received: (qmail 43423 invoked by uid 99); 13 Apr 2017 14:16:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Apr 2017 14:16:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 6EB0D1A03CA for ; Thu, 13 Apr 2017 14:16:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.221 X-Spam-Level: X-Spam-Status: No, score=-4.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Ebd5mgXOZD73 for ; Thu, 13 Apr 2017 14:16:15 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 6BB8B60D87 for ; Thu, 13 Apr 2017 14:16:11 +0000 (UTC) Received: (qmail 43217 invoked by uid 99); 13 Apr 2017 14:16:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Apr 2017 14:16:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7F0A1E2F41; Thu, 13 Apr 2017 14:16:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: avia@apache.org To: dev@ariatosca.incubator.apache.org Date: Thu, 13 Apr 2017 14:16:23 -0000 Message-Id: <8b51e0bb76f94d529f1099fae9b717e7@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [14/14] incubator-ariatosca git commit: Add tests for services inputs archived-at: Thu, 13 Apr 2017 14:16:20 -0000 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/a9488507 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/a9488507 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/a9488507 Branch: refs/heads/cli-tests Commit: a948850791b2660d4ecfd2ac1803e1518289b382 Parents: d9c520e Author: Avia Efrat Authored: Thu Apr 13 12:12:22 2017 +0300 Committer: Avia Efrat Committed: Thu Apr 13 17:15: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/a9488507/tests/cli/test_service_templates.py ---------------------------------------------------------------------- diff --git a/tests/cli/test_service_templates.py b/tests/cli/test_service_templates.py index 46ba2ac..500124c 100644 --- a/tests/cli/test_service_templates.py +++ b/tests/cli/test_service_templates.py @@ -53,7 +53,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/a9488507/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/a9488507/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