Exemple #1
0
    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))
Exemple #2
0
    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))
Exemple #3
0
 def search(self):
     parameters = extract_search_parameters(request.args,
                                            self.extra_parameters)
     search_result = self.service.search(parameters)
     response = self.converter.encode_list(search_result.items,
                                           search_result.total)
     return build_response(response)
Exemple #4
0
    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))
Exemple #5
0
    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))
Exemple #6
0
    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))
Exemple #7
0
    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))
Exemple #8
0
    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))
Exemple #9
0
    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))
Exemple #10
0
    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))
Exemple #11
0
    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))
Exemple #12
0
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)
Exemple #13
0
    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))
Exemple #14
0
    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))
Exemple #15
0
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)
Exemple #16
0
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)
Exemple #17
0
 def search(self):
     if 'q' in request.args:
         return self.search_by_fullname(request.args['q'])
     else:
         args = extract_search_parameters(request.args, ['view'])
         return self.search_by_view(args)
Exemple #18
0
 def search(self):
     parameters = extract_search_parameters(request.args, self.extra_parameters)
     search_result = self.service.search(parameters)
     response = self.converter.encode_list(search_result.items, search_result.total)
     return build_response(response)