def test_http_rpc_active_nomal(self): new_id, new_passwd = new_account(can_active=False) active_result = active(MMMDAHttpRpcClt, admin0d_id, admin01_access_token, new_id) print "active_result,", active_result self.assertTrue(active_result == error_code.ERROR_SUCCESS)
def test_http_rpc_unseal_account(self): new_id, new_passwd = new_account() # 登陆成功 login_result = login(MMMDAHttpRpcClt, new_id, new_passwd) print "login_result,", login_result self.assertTrue(login_result['result'] == error_code.ERROR_SUCCESS) # 封号 seal_account_result = seal_account(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, new_id) print "seal_account_result :%s, new_id:%s," % (seal_account_result, new_id) # 登陆失败 # login error on sealed account, 暂时测试是不开启封号的 self.assertRaises(Exception, login, MMMDAHttpRpcClt, new_id, new_passwd) # 解除封号 seal_account_result = unseal_account(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, new_id) print "seal_account_result :%s, new_id:%s," % (seal_account_result, new_id) # 登陆成功 login_result = login(MMMDAHttpRpcClt, new_id, new_passwd) print "login_result,", login_result self.assertTrue(login_result['result'] == error_code.ERROR_SUCCESS)
def test_http_rpc_gm_view_account(self): new_id, new_passwd = new_account() print "new_id,", new_id view_result = view_account(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, new_id) print "view_result,", view_result self.assertTrue(str(view_result['id']) == str(new_id)) self.assertTrue(view_result['passwd'] == new_passwd)
def test_http_rpc_gm_login(self): # gm 可以登陆 login_result = gm_login(MMMDAHttpRpcClt, admin0d_id, admin01_passwd) print "login_result,", login_result self.assertTrue(login_result['result'] == error_code.ERROR_SUCCESS) # 其他账号不可以登陆 new_id, new_passwd = new_account() self.assertRaises(Exception, gm_login, MMMDAHttpRpcClt, new_id, new_passwd)
def test_http_rpc_reset_login_info_nomal(self): new_id, new_passwd = new_account() login_result = login(MMMDAHttpRpcClt, new_id, new_passwd) print "login_result,", login_result self.assertTrue(login_result['result'] == error_code.ERROR_SUCCESS) last_minutes = random.randint(1, 36000) login_count = login_info(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, last_minutes) self.assertTrue(login_count > 0)
def test_http_rpc_get_account_infos_nomal(self): new_id, new_passwd = new_account() new_token = new_access_token(new_id, new_passwd) view_id = 18888 view_account_result = account(MMMDAHttpRpcClt, new_id, new_token, view_id) print "view_account_result,", view_account_result self.assertTrue( view_account_result['result'] == error_code.ERROR_SUCCESS) self.assertTrue("passwd" not in view_account_result['account_info'])
def test_http_rpc_add_active_coin(self): adding_account, new_passwd = new_account() add_coin_result = add_active_coin(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, adding_account, 11) cur_active_coin = add_coin_result['active_coin'] adding_active_coin = random.randint(1, 1000) add_coin_result = add_active_coin(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, adding_account, adding_active_coin) self.assertTrue(add_coin_result['active_coin'] == cur_active_coin + adding_active_coin)
def test_http_rpc_active_coin_transfer_nomal(self): user1, passwd1 = new_account() token1 = new_access_token(user1, passwd1) # admin before transfer view_account_result1 = account(MMMDAHttpRpcClt, admin0d_id, admin01_access_token, admin0d_id) self.assertTrue( view_account_result1['result'] == error_code.ERROR_SUCCESS) adm_bf_active_coin = view_account_result1['account_info'][ 'active_coin'] print "adm_bf_active_coin,", adm_bf_active_coin # user before transfer view_account_result2 = account(MMMDAHttpRpcClt, user1, token1, user1) self.assertTrue( view_account_result2['result'] == error_code.ERROR_SUCCESS) user1_bf_active_coin = view_account_result2['account_info'][ 'active_coin'] print "user1_bf_active_coin,", user1_bf_active_coin # transfer transfer_coin = random.randint(1, adm_bf_active_coin) print "transfer_coin,", transfer_coin active_coin_transfer(MMMDAHttpRpcClt, admin0d_id, admin01_access_token, user1, transfer_coin) # admin after transfer view_account_result3 = account(MMMDAHttpRpcClt, admin0d_id, admin01_access_token, admin0d_id) self.assertTrue( view_account_result3['result'] == error_code.ERROR_SUCCESS) adm_aft_active_coin = view_account_result3['account_info'][ 'active_coin'] print "adm_aft_active_coin,", adm_aft_active_coin # user after transfer view_account_result4 = account(MMMDAHttpRpcClt, user1, token1, user1) self.assertTrue( view_account_result4['result'] == error_code.ERROR_SUCCESS) user1_aft_active_coin = view_account_result4['account_info'][ 'active_coin'] print "user1_aft_active_coin,", user1_aft_active_coin # transfter assert self.assertTrue(adm_bf_active_coin == adm_aft_active_coin + transfer_coin) self.assertTrue(user1_bf_active_coin + transfer_coin == user1_aft_active_coin)
def test_http_rpc_system_add_apply_help_normal(self): """ 测试添加流程 :return: """ new_id, new_passwd = new_account() print "new_id,",new_id print "new_passwd,",new_passwd new_token = new_access_token(new_id, new_passwd) add_accept_help_result = add_accept_help(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, new_id, 10000) print "add_accept_help_result,", add_accept_help_result # 申请帮助方:当前接受帮助 cur_accept_help_result = cur_accept_help(MMMDAHttpRpcClt, new_id, new_token) print "cur_accept_help_result,", cur_accept_help_result self.assertTrue(cur_accept_help_result['accept_help'])
def test_http_rpc_gm_active_account(self): new_id, new_passwd = new_account(can_active=False) view_result1 = view_account(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, new_id) print "view_result1,", view_result1, type(view_result1) self.assertTrue(view_result1['stat'] != ACTIVED) active_result = active_account(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, new_id) print self.assertTrue(active_result == error_code.ERROR_SUCCESS) view_result2 = view_account(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, new_id) self.assertTrue(view_result2['stat'] == ACTIVED)
def test_http_rpc_change_passwd_nomal(self): new_id, new_passwd = new_account() new_token = new_access_token(new_id, new_passwd) # change passwd change_paswd = random_str() passwd_change(MMMDAHttpRpcClt, new_id, new_token, new_passwd, change_paswd) # login error on old passwd self.assertRaises(Exception, login, MMMDAHttpRpcClt, new_id, new_passwd) # login success on new passwd login_result = login(MMMDAHttpRpcClt, new_id, change_paswd) print "login_result,", login_result self.assertTrue(login_result['result'] == error_code.ERROR_SUCCESS)
def test_http_rpc_add_match_coin(self): adding_account, new_passwd = new_account() add_coin_result = add_match_coin(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, adding_account, 11) print "add_coin_result,", add_coin_result cur_match_coin = add_coin_result['match_coin'] print "cur_match_coin,", cur_match_coin adding_match_coin = random.randint(1, 1000) print "adding_match_coin,", adding_match_coin add_coin_result = add_match_coin(MMMDAHttpRpcClt, admin0d_id, admin01_passwd, adding_account, adding_match_coin) print "add_coin_result,", add_coin_result self.assertTrue(add_coin_result['match_coin'] == cur_match_coin + adding_match_coin)