예제 #1
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)
예제 #2
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)
예제 #3
0
    def test_search(self, user_dao_search):
        search_result = user_dao_search.return_value = Mock(SearchResult)

        result = user_services.search(search='toto',
                                      order='firstname',
                                      direction='desc',
                                      limit=1,
                                      skip=2)

        assert_that(result, equal_to(search_result))
        user_dao_search.assert_called_once_with(search='toto',
                                                order='firstname',
                                                direction='desc',
                                                limit=1,
                                                skip=2)
예제 #4
0
    def test_search(self, user_dao_search):
        search_result = user_dao_search.return_value = Mock(SearchResult)

        result = user_services.search(search='toto',
                                      order='firstname',
                                      direction='desc',
                                      limit=1,
                                      skip=2)

        assert_that(result, equal_to(search_result))
        user_dao_search.assert_called_once_with(search='toto',
                                                order='firstname',
                                                direction='desc',
                                                limit=1,
                                                skip=2)