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})
def test_finds_nothing(self): result = dbsrv.search_users("z") assert result == set([])
def test_succeeds_normally(self): result = dbsrv.search_users("j") assert self.james in result assert self.john in result