def create_detail(self, request): """ Implements the Create Detail (create an object) maps to POST /api/objects/ in rest semantics :param request: rip.Request :return: rip.Response """ pipeline = crud_pipeline_factory.create_detail_pipeline( configuration=self.configuration) return pipeline(request=request)
def test_create_detail_pipeline_has_all_steps_in_the_right_order(self, compose_pipeline): entity_actions = MagicMock() entity_actions.create_detail = create_detail = MagicMock() authentication = MagicMock() authentication.authenticate = MagicMock() authorization = MagicMock() authorization.authorize_create_detail = authorize_create_detail = MagicMock() schema_validation = MagicMock() schema_validation.validate_request_data = validate_request_data = MagicMock() schema = MagicMock() serializer = MagicMock() serializer.serialize_detail = serialize_detail = MagicMock() data_cleaner = MagicMock() data_cleaner.clean_data_for_create_detail = clean_data_for_create_detail = MagicMock() post_action_hooks = MagicMock() post_action_hooks.create_detail_hook = create_detail_hook = MagicMock() response_converter = MagicMock() response_converter.convert_serialized_data_to_response = convert_serialized_data_to_response = MagicMock() configuration = { "entity_actions": entity_actions, "authentication": authentication, "authorization": authorization, "schema": schema, "schema_validation": schema_validation, "serializer": serializer, "data_cleaner": data_cleaner, "post_action_hooks": post_action_hooks, "response_converter": response_converter, } compose_pipeline.return_value = expected_pipeline = MagicMock() pipeline = crud_pipeline_factory.create_detail_pipeline(configuration) assert_that(pipeline, equal_to(expected_pipeline)) compose_pipeline.assert_called_once_with( name=CrudActions.CREATE_DETAIL, pipeline=[ authentication.authenticate, clean_data_for_create_detail, validate_request_data, authorize_create_detail, create_detail, serialize_detail, create_detail_hook, convert_serialized_data_to_response, ], )
def test_create_detail_pipeline_has_all_steps_in_the_right_order( self, compose_pipeline): entity_actions = MagicMock() entity_actions.create_detail = create_detail = MagicMock() authentication = MagicMock() authentication.authenticate = MagicMock() authorization = MagicMock() authorization.authorize_create_detail = \ authorize_create_detail = MagicMock() schema_validation = MagicMock() schema_validation.validate_request_data = \ validate_request_data = MagicMock() schema = MagicMock() serializer = MagicMock() serializer.serialize_detail = serialize_detail = MagicMock() data_cleaner = MagicMock() data_cleaner.clean_data_for_create_detail = \ clean_data_for_create_detail = MagicMock() post_action_hooks = MagicMock() post_action_hooks.create_detail_hook = create_detail_hook = MagicMock() response_converter = MagicMock() response_converter.convert_serialized_data_to_response = \ convert_serialized_data_to_response = MagicMock() configuration = { 'entity_actions': entity_actions, 'authentication': authentication, 'authorization': authorization, 'schema': schema, 'schema_validation': schema_validation, 'serializer': serializer, 'data_cleaner': data_cleaner, 'post_action_hooks': post_action_hooks, 'response_converter': response_converter } compose_pipeline.return_value = expected_pipeline = MagicMock() pipeline = crud_pipeline_factory.create_detail_pipeline(configuration) assert_that(pipeline, equal_to(expected_pipeline)) compose_pipeline.assert_called_once_with( name=CrudActions.CREATE_DETAIL, pipeline=[ authentication.authenticate, clean_data_for_create_detail, validate_request_data, authorize_create_detail, create_detail, serialize_detail, create_detail_hook, convert_serialized_data_to_response ])