def test_deployments_execute(self): execute_response = executions.Execution({'status': 'started'}) get_execution_response = executions.Execution({ 'status': 'terminated', 'workflow_id': 'mock_wf', 'deployment_id': 'deployment-id', 'blueprint_id': 'blueprint-id', 'error': '', 'id': 'id', 'created_at': datetime.datetime.now(), 'parameters': {} }) success_event = { 'event_type': 'workflow_succeeded', 'type': 'foo', 'timestamp': '12345678', 'message': 'workflow execution succeeded', 'error_causes': '<error_causes>', 'deployment_id': 'deployment-id', 'execution_id': '<execution_id>', 'source_id': None, 'target_id': None, 'node_name': '<node_name>', 'operation': '<operation>', 'workflow_id': '<workflow_id>', 'node_instance_id': '<node_instance_id>', } get_events_response = MockListResponse([success_event], 1) self.client.executions.start = MagicMock( return_value=execute_response) self.client.executions.get = MagicMock( return_value=get_execution_response) self.client.events.list = MagicMock(return_value=get_events_response) self.invoke('cfy executions start install -d a-deployment-id')
def _mock_executions_get(self, execution_id): self.update_execution_status() if self.executions_status != executions.Execution.TERMINATED: execution = executions.Execution( {'id': 'execution_id', 'status': executions.Execution.STARTED}) else: execution = executions.Execution( {'id': 'execution_id', 'status': executions.Execution.TERMINATED}) return execution
def test_snapshots_create(self): self.client.snapshots.create = MagicMock( return_value=executions.Execution({'id': 'some_id'})) self.invoke('cfy snapshots create a-snapshot-id')