def get_aggregates(self, request): """ Implements the Get aggregates (total number of objects filtered) maps to PATCH /api/object_name/get_aggregates/ in rest semantics :param request: rip.Request :return: rip.Response """ pipeline = crud_pipeline_factory.get_aggregates_pipeline( configuration=self.configuration) return pipeline(request=request)
def test_get_aggregates_pipeline_has_all_steps_in_the_right_order( self, compose_pipeline): entity_actions = MagicMock() entity_actions.get_aggregates = get_aggregates = 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_get_aggregates = \ clean_data_for_get_aggregates = MagicMock() serializer = MagicMock() serializer.serialize_entity_aggregates = \ serialize_entity_aggregates = MagicMock() response_converter = MagicMock() response_converter.convert_serialized_data_to_response = \ convert_serialized_data_to_response = MagicMock() post_action_hooks = MagicMock() post_action_hooks \ .get_aggregates_hook = get_aggregates_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.get_aggregates_pipeline(configuration) assert_that(pipeline, equal_to(expected_pipeline)) compose_pipeline.assert_called_once_with( name=CrudActions.GET_AGGREGATES, pipeline=[ authentication.authenticate, validate_request_params, clean_data_for_get_aggregates, add_read_list_filters, get_aggregates, serialize_entity_aggregates, get_aggregates_hook, convert_serialized_data_to_response ])
def test_get_aggregates_pipeline_has_all_steps_in_the_right_order(self, compose_pipeline): entity_actions = MagicMock() entity_actions.get_aggregates = get_aggregates = 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_get_aggregates = clean_data_for_get_aggregates = MagicMock() serializer = MagicMock() serializer.serialize_entity_aggregates = serialize_entity_aggregates = MagicMock() response_converter = MagicMock() response_converter.convert_serialized_data_to_response = convert_serialized_data_to_response = MagicMock() post_action_hooks = MagicMock() post_action_hooks.get_aggregates_hook = get_aggregates_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.get_aggregates_pipeline(configuration) assert_that(pipeline, equal_to(expected_pipeline)) compose_pipeline.assert_called_once_with( name=CrudActions.GET_AGGREGATES, pipeline=[ authentication.authenticate, validate_request_params, clean_data_for_get_aggregates, add_read_list_filters, get_aggregates, serialize_entity_aggregates, get_aggregates_hook, convert_serialized_data_to_response, ], )