def regist_and_login(phone,clear=False,wait_time=3,*args): api = UserRequest(mode) dc_old = api.vcode(phone) api.dc=dc_old dc = dc_old.split('#')[0] sleep(int(wait_time)) vcode = api.get_vcode_by_redis(phone,dc) print 'get vcode:',vcode userinfo = api.login(phone,vcode,*args) print userinfo if clear==True or clear == 'True': clear_result = user_clear(userinfo) assert clear_result return userinfo
def regist_and_login_with_args(phone,ak,clear=False,wait_time=3,*args): db = DbLib() secret = db.get_secret_by_ak(ak) api = UserRequest(mode,secret=secret) dc_old = api.vcode(phone,'hd_ak='+str(ak)) api.dc=dc_old dc = dc_old.split('#')[0] sleep(int(wait_time)) vcode = api.get_vcode_by_redis(phone,dc) print 'get vcode:',vcode userinfo = api.login(phone,vcode,'hd_ak='+str(ak),*args) print userinfo if clear==True or clear == 'True': clear_result = user_clear(userinfo) assert clear_result return userinfo
def regist_and_login_2(phone,sid,appid='900001',clear=False,wait_time=3): api = UserRequest(mode) dc_old = api.vcode(phone) api.dc=dc_old dc = dc_old.split('#')[0] sleep(wait_time) vcode = api.get_vcode_by_redis(phone,dc) print 'get vcode:',vcode if sid!='' and appid!='': d = ['sid='+str(sid),'appid='+str(appid)] userinfo = api.login(phone,vcode,*d) print 'login:result:',userinfo else: userinfo = api.login(phone,vcode) if clear: clear_result = user_clear(userinfo) assert clear_result return userinfo