def _login_user(context, username, password, facility=None):
 data = {'username': username, 'password': password}
 if facility:
  data['facility'] = facility
  context.facility = facility
 data = json.dumps(data)
 url = (reverse('api_dispatch_list', kwargs={'resource_name': 'user'}) + 'login/')
 resp = post(context, url, data)
 context.user = username
 assert resp, ('Login failed. url: %s\ndata: %s' % (url, data))

def _login_user ( context , username , password , facility = None ) : data = { 'username' : username , 'password' : password } if facility : data [ 'facility' ] = facility context . facility = facility data = json . dumps ( data ) url = ( reverse ( 'api_dispatch_list' , kwargs = { 'resource_name' : 'user' } ) + 'login/' ) resp = post ( context , url , data ) context . user = username assert resp , ( 'Login failed. url: %s\ndata: %s' % ( url , data ) )
logs a user in with an api endpoint .