示例#1
0
def search_users(dbsrv=dbsrv):
    """A GET request to /users will do a search."""
    try:
        query = request.args.get('query')
    except:
        raise err.JSONParseError("JSON Parsing failed.")
    users = dbsrv.search_users(query)
    userlist = []
    for user in users:
        userdict = {"id": user.id,
                    "name": user.name,
                    "email": user.email,
                    "groups": [g.id for g in user.groups]}
        userlist.append(userdict)
    return jsonify({"users": userlist})
示例#2
0
 def test_finds_nothing(self):
     result = dbsrv.search_users("z")
     assert result == set([])
示例#3
0
 def test_succeeds_normally(self):
     result = dbsrv.search_users("j")
     assert self.james in result
     assert self.john in result