def test_given_order_parameter_then_extracts_order_parameter(self): expected_result = {'order': 'column_name'} args = {'order': 'column_name'} parameters = extract_search_parameters(args) assert_that(parameters, equal_to(expected_result))
def test_given_search_parameter_then_extracts_search_term(self): expected_result = {'search': 'abcd'} args = {'search': 'abcd'} parameters = extract_search_parameters(args) assert_that(parameters, equal_to(expected_result))
def test_given_direction_parameter_then_extracts_direction(self): expected_result = {'direction': 'asc'} args = {'direction': 'asc'} parameters = extract_search_parameters(args) assert_that(parameters, equal_to(expected_result))
def test_given_limit_parameter_then_extracts_limit(self): expected_result = {'limit': 532} args = {'limit': '532'} parameters = extract_search_parameters(args) assert_that(parameters, equal_to(expected_result))
def test_given_extra_parameters_then_extracts_extra_parameters(self): expected_result = {'extra': 'extravalue'} args = {'extra': 'extravalue'} extra_parameters = ['extra'] parameters = extract_search_parameters(args, extra=extra_parameters) assert_that(parameters, equal_to(expected_result))
def list(): if 'q' in request.args: items = user_services.find_all_by_fullname(request.args['q']) total = len(items) else: parameters = extract_search_parameters(request.args) search_result = user_services.search(**parameters) items = search_result.items total = search_result.total result = formatter.list_to_api(items, total) return make_response(result, 200)
def test_given_all_search_parameters_then_extracts_all_parameters(self): expected_result = { 'skip': 532, 'limit': 5432, 'order': 'toto', 'direction': 'asc', 'search': 'abcd' } args = { 'skip': '532', 'limit': '5432', 'order': 'toto', 'direction': 'asc', 'search': 'abcd' } parameters = extract_search_parameters(args) assert_that(parameters, equal_to(expected_result))
def list(): parameters = extract_search_parameters(request.args, extra_parameters) search_result = extension_services.search(**parameters) result = formatter.list_to_api(search_result.items, search_result.total) return make_response(result, 200)
def list(): search_parameters = extract_search_parameters(request.args) search_result = voicemail_services.search(**search_parameters) result = formatter.list_to_api(search_result.items, search_result.total) return make_response(result, 200)