def read_list(self, request): """ Implements the List read (get a list of objects) maps to GET /api/objects/ in rest semantics :param request: rip.Request :return: rip.Response """ pipeline = crud_pipeline_factory.read_list_pipeline( configuration=self.configuration) return pipeline(request=request)
def test_read_list_pipeline_has_all_steps_in_the_right_order( self, compose_pipeline): entity_actions = MagicMock() entity_actions.read_list = read_list = MagicMock() authentication = MagicMock() authentication.authenticate = MagicMock() authorization = MagicMock() authorization \ .add_read_list_filters = add_read_list_filters = MagicMock() request_params_validation = MagicMock() request_params_validation \ .validate_request_params = validate_request_params = \ MagicMock() cleaner = MagicMock() cleaner.clean_data_for_read_list = \ clean_data_for_read_list = MagicMock() serializer = MagicMock() serializer.serialize_list = \ serialize_list = MagicMock() response_converter = MagicMock() response_converter.convert_serialized_data_to_response = \ convert_serialized_data_to_response = MagicMock() post_action_hooks = MagicMock() post_action_hooks.read_list_hook = read_list_hook = MagicMock() compose_pipeline.return_value = expected_pipeline = MagicMock() configuration = { 'entity_actions': entity_actions, 'authentication': authentication, 'request_params_validation': request_params_validation, 'authorization': authorization, 'serializer': serializer, 'data_cleaner': cleaner, 'response_converter': response_converter, 'post_action_hooks': post_action_hooks } pipeline = crud_pipeline_factory.read_list_pipeline(configuration) assert_that(pipeline, equal_to(expected_pipeline)) compose_pipeline.assert_called_once_with( name=CrudActions.READ_LIST, pipeline=[ authentication.authenticate, validate_request_params, clean_data_for_read_list, add_read_list_filters, read_list, serialize_list, read_list_hook, convert_serialized_data_to_response ])
def test_read_list_pipeline_has_all_steps_in_the_right_order(self, compose_pipeline): entity_actions = MagicMock() entity_actions.read_list = read_list = MagicMock() authentication = MagicMock() authentication.authenticate = MagicMock() authorization = MagicMock() authorization.add_read_list_filters = add_read_list_filters = MagicMock() request_params_validation = MagicMock() request_params_validation.validate_request_params = validate_request_params = MagicMock() cleaner = MagicMock() cleaner.clean_data_for_read_list = clean_data_for_read_list = MagicMock() serializer = MagicMock() serializer.serialize_list = serialize_list = MagicMock() response_converter = MagicMock() response_converter.convert_serialized_data_to_response = convert_serialized_data_to_response = MagicMock() post_action_hooks = MagicMock() post_action_hooks.read_list_hook = read_list_hook = MagicMock() compose_pipeline.return_value = expected_pipeline = MagicMock() configuration = { "entity_actions": entity_actions, "authentication": authentication, "request_params_validation": request_params_validation, "authorization": authorization, "serializer": serializer, "data_cleaner": cleaner, "response_converter": response_converter, "post_action_hooks": post_action_hooks, } pipeline = crud_pipeline_factory.read_list_pipeline(configuration) assert_that(pipeline, equal_to(expected_pipeline)) compose_pipeline.assert_called_once_with( name=CrudActions.READ_LIST, pipeline=[ authentication.authenticate, validate_request_params, clean_data_for_read_list, add_read_list_filters, read_list, serialize_list, read_list_hook, convert_serialized_data_to_response, ], )