def test_missing_workflow_implementation(service, request): # validating a proper error is raised when the workflow code path does not exist workflow = models.Operation(name='test_workflow', service=service, function='nonexistent.workflow.implementation') service.workflows['test_workflow'] = workflow with pytest.raises(exceptions.WorkflowImplementationNotFoundError): _get_preparer(request, 'test_workflow').prepare()
def create_operation(operation_name, operation_kwargs=None): if operation_kwargs and operation_kwargs.get('arguments'): operation_kwargs['arguments'] = dict( (argument_name, models.Argument.wrap(argument_name, argument_value)) for argument_name, argument_value in operation_kwargs['arguments'].iteritems() if argument_value is not None) return models.Operation(name=operation_name, **(operation_kwargs or {}))
def get_standard_interface(service): the_type = service.service_template.interface_types.get_descendant('test_interface_type') ops = dict( (op_name, models.Operation( name=op_name, implementation='{0}.{1}'.format(__file__, mock_operation.__name__))) for op_name in (NORMATIVE_CREATE, NORMATIVE_CONFIGURE, NORMATIVE_START, NORMATIVE_STOP, NORMATIVE_DELETE) ) return { NORMATIVE_STANDARD_INTERFACE: models.Interface(name=NORMATIVE_STANDARD_INTERFACE, operations=ops, type=the_type) }
def _setup_mock_workflow_in_service(request, inputs=None): # sets up a mock workflow as part of the service, including uploading # the workflow code to the service's dir on the resource storage service = request.getfixturevalue('service') resource = request.getfixturevalue('resource') source = tests_mock.workflow.__file__ resource.service_template.upload(str(service.service_template.id), source) mock_workflow_name = 'test_workflow' arguments = {} if inputs: for input in inputs.itervalues(): arguments[input.name] = input.as_argument() workflow = models.Operation(name=mock_workflow_name, service=service, function='workflow.mock_workflow', inputs=inputs or {}, arguments=arguments) service.workflows[mock_workflow_name] = workflow return mock_workflow_name
def get_configure_interfaces(service): the_type = service.service_template.interface_types.get_descendant('test_interface_type') operations = dict( (op_name, models.Operation( name=op_name, implementation='{0}.{1}'.format(__file__, mock_operation.__name__))) for op_name in (NORMATIVE_PRE_CONFIGURE_SOURCE, NORMATIVE_POST_CONFIGURE_SOURCE, NORMATIVE_ADD_SOURCE, NORMATIVE_REMOVE_SOURCE, NORMATIVE_PRE_CONFIGURE_TARGET, NORMATIVE_POST_CONFIGURE_TARGET, NORMATIVE_ADD_TARGET, NORMATIVE_REMOVE_TARGET) ) interface = { NORMATIVE_CONFIGURE_INTERFACE: models.Interface( name=NORMATIVE_CONFIGURE_INTERFACE, operations=operations, type=the_type) } return interface
def create_interface(service, interface_name, operation_name, operation_kwargs=None, interface_kwargs=None): the_type = service.service_template.interface_types.get_descendant( 'test_interface_type') if operation_kwargs and operation_kwargs.get('arguments'): operation_kwargs['arguments'] = dict( (argument_name, models.Argument.wrap(argument_name, argument_value)) for argument_name, argument_value in operation_kwargs['arguments'].iteritems() if argument_value is not None) operation = models.Operation(name=operation_name, **(operation_kwargs or {})) return models.Interface(type=the_type, operations=_dictify(operation), name=interface_name, **(interface_kwargs or {}))