Пример #1
0
 def test_deployments_outputs_json(self):
     outputs = deployments.DeploymentOutputs({
         'deployment_id': 'dep1',
         'outputs': {
             'port': 8080
         }
     })
     deployment = deployments.Deployment({
         'outputs': {
             'port': {
                 'description': 'Webserver port.',
                 'value': '...'
             }
         }
     })
     self.client.deployments.get = MagicMock(return_value=deployment)
     self.client.deployments.outputs.get = MagicMock(return_value=outputs)
     outcome = self.invoke('cfy deployments outputs dep1 --json')
     parsed = json.loads(outcome.output)
     self.assertEqual(
         parsed,
         {'port': {
             'value': 8080,
             'description': 'Webserver port.'
         }})
Пример #2
0
    def test_workflows_get(self):
        deployment = deployments.Deployment({
            'blueprint_id':
            'mock_blueprint_id',
            'workflows': [{
                'created_at': None,
                'name': 'mock_workflow',
                'parameters': {
                    'test-key': {
                        'default': 'test-value'
                    },
                    'test-mandatory-key': {},
                    'test-nested-key': {
                        'default': {
                            'key': 'nested value'
                        }
                    }
                }
            }]
        })

        self.client.deployments.get = MagicMock(return_value=deployment)
        outcome = self.invoke('workflows get mock_workflow -d dep_id')
        self.assertIn('test-mandatory-key', outcome.output)
        self.assertIn('nested value', outcome.output)
Пример #3
0
 def test_deployment_create_without_skip_plugins_validation_flag(self):
     deployment = deployments.Deployment({'deployment_id': 'deployment_id'})
     self.client.deployments.create = MagicMock(return_value=deployment)
     self.invoke('cfy deployments create deployment -b aa')
     call_args = list(self.client.deployments.create.call_args)
     self.assertIn('skip_plugins_validation', call_args[1])
     self.assertEqual(call_args[1]['skip_plugins_validation'], False)
Пример #4
0
    def test_workflows_get_json(self):
        deployment = deployments.Deployment({
            'blueprint_id':
            'mock_blueprint_id',
            'workflows': [{
                'created_at': None,
                'name': 'mock_workflow',
                'parameters': {
                    'test-key': {
                        'default': 'test-value'
                    },
                    'test-mandatory-key': {},
                    'test-nested-key': {
                        'default': {
                            'key': 'nested value'
                        }
                    }
                }
            }]
        })

        self.client.deployments.get = MagicMock(return_value=deployment)
        outcome = self.invoke('workflows get mock_workflow -d dep_id --json')
        parsed = json.loads(outcome.output)
        self.assertEqual(deployment.workflows[0]['parameters'],
                         parsed['parameters'])
Пример #5
0
    def test_workflows_get_nonexistent_workflow(self):

        expected_message = 'Workflow nonexistent_workflow not found'
        deployment = deployments.Deployment({
            'blueprint_id':
            'mock_blueprint_id',
            'workflows': [{
                'created_at': None,
                'name': 'mock_workflow',
                'parameters': {
                    'test-key': {
                        'default': 'test-value'
                    },
                    'test-mandatory-key': {},
                    'test-nested-key': {
                        'default': {
                            'key': 'val'
                        }
                    }
                }
            }]
        })

        self.client.deployments.get = MagicMock(return_value=deployment)
        self.invoke('cfy workflows get nonexistent_workflow -d dep_id',
                    expected_message)
Пример #6
0
    def test_deployment_create(self):

        deployment = deployments.Deployment({'deployment_id': 'deployment_id'})

        self.client.deployments.create = MagicMock(return_value=deployment)
        cli_runner.run_cli('cfy deployments create -b '
                           'a-blueprint-id -d deployment')
Пример #7
0
    def test_deployment_create(self):

        deployment = deployments.Deployment({
            'deployment_id': 'deployment_id'
        })

        self.client.deployments.create = MagicMock(return_value=deployment)
        self.invoke(
            'cfy deployments create deployment -b a-blueprint-id')
Пример #8
0
 def create_deployments_in_tenant(deps_list, num_of_deps, tenant,
                                  start_index):
     for i in range(num_of_deps):
         deps_list.append(
             deployments.Deployment({
                 'id': 'dep{0}'.format(start_index),
                 'tenant_name': tenant['name']
             }))
         start_index += 1
     return start_index
Пример #9
0
    def test_deployments_inputs_json(self):
        deployment = deployments.Deployment({
            'deployment_id': 'deployment_id',
            'inputs': {'key1': 'val1', 'key2': 'val2'}
        })

        self.client.deployments.get = MagicMock(return_value=deployment)
        outcome = self.invoke('cfy deployments inputs deployment_id --json')
        parsed = json.loads(outcome.output)
        self.assertEqual(parsed, {'key1': 'val1', 'key2': 'val2'})
Пример #10
0
    def test_deployments_outputs(self):

        outputs = deployments.DeploymentOutputs({
            'deployment_id': 'dep1',
            'outputs': {
                'port': 8080
            }
        })
        deployment = deployments.Deployment({
            'outputs': {
                'port': {
                    'description': 'Webserver port.',
                    'value': '...'
                }
            }
        })
        self.client.deployments.get = MagicMock(return_value=deployment)
        self.client.deployments.outputs.get = MagicMock(return_value=outputs)
        self.invoke('cfy deployments outputs dep1')
Пример #11
0
    def test_workflows_sort_list(self):

        deployment = deployments.Deployment({
            'blueprint_id':
            'mock_blueprint_id',
            'workflows': [{
                'created_at': None,
                'name': 'my_workflow_1',
                'parameters': {
                    'test-key': {
                        'default': 'test-value'
                    },
                    'test-mandatory-key': {},
                    'test-nested-key': {
                        'default': {
                            'key': 'val'
                        }
                    }
                }
            }, {
                'created_at': None,
                'name': 'my_workflow_0',
                'parameters': {
                    'test-key': {
                        'default': 'test-value'
                    },
                    'test-mandatory-key': {},
                    'test-nested-key': {
                        'default': {
                            'key': 'val'
                        }
                    }
                }
            }]
        })

        self.client.deployments.get = MagicMock(return_value=deployment)

        output = self.invoke('cfy workflows list -d a-deployment-id').output
        first = output.find('my_workflow_0')
        second = output.find('my_workflow_1')
        self.assertTrue(0 < first < second)
Пример #12
0
    def test_deployments_inputs(self):
        deployment = deployments.Deployment({
            'deployment_id': 'deployment_id',
            'inputs': {'key1': 'val1', 'key2': 'val2'}
        })

        expected_outputs = [
            'Retrieving inputs for deployment deployment_id...',
            '- "key1":',
            'Value: val1',
            '- "key2":',
            'Value: val2',
        ]

        self.client.deployments.get = MagicMock(return_value=deployment)
        outcome = self.invoke('cfy deployments inputs deployment_id')
        outcome = [o.strip() for o in outcome.logs.split('\n')]

        for output in expected_outputs:
            self.assertIn(output, outcome)
Пример #13
0
    def test_workflows_list(self):
        deployment = deployments.Deployment({
            'blueprint_id':
            'mock_blueprint_id',
            'workflows': [{
                'created_at': None,
                'name': 'mock_workflow',
                'parameters': {
                    'test-key': {
                        'default': 'test-value'
                    },
                    'test-mandatory-key': {},
                    'test-nested-key': {
                        'default': {
                            'key': 'val'
                        }
                    }
                }
            }]
        })

        self.client.deployments.get = MagicMock(return_value=deployment)
        self.invoke('cfy workflows list -d a-deployment-id')
Пример #14
0
 def test_deployment_create_without_site_name(self):
     deployment = deployments.Deployment({'deployment_id': 'deployment_id'})
     self.client.deployments.create = MagicMock(return_value=deployment)
     self.invoke('cfy deployments create deployment -b a')
     call_args = list(self.client.deployments.create.call_args)
     self.assertIsNone(call_args[1]['site_name'])
Пример #15
0
 def mock_deployments_get(*args, **kwargs):
     return deployments.Deployment({'blueprint_id': 'bid'})
Пример #16
0
 def _mock_deployments_get(self, deployment_id):
     return deployments.Deployment({'id': deployment_id})