def session(request, api_url):
username, password = request.param
with GirderSession(base_url=api_url) as s:
try:
r = s.get('user/authentication', auth=(username, password))
except requests.ConnectionError:
raise Exception(
'Unable to connect to %s.' % api_url)
try:
s.headers['Girder-Token'] = r.json()['authToken']['token']
except KeyError:
raise Exception(
'Unable to login with user "%s", password "%s"' % (username, password))
yield s
# TODO combine with session in some way?
评论列表
文章目录