def cancel_trade(self, symbol, rate, type, amount, tradePassword, source, user_id, asset, table): try: old_asset = DB.DB().get_balance(user_id, asset) trade_price = round(DB.DB().get_current_price(symbol) * rate, 8) response_trade = Service.Service().trade(trade_price, amount, type, tradePassword, symbol, source) allm = response_trade['data']['allMoney'] order_id = response_trade['data']['id'] new_lock_asset = DB.DB().get_balance(user_id, asset)[1] if type == 1: self.assertEqual(float(allm), round(new_lock_asset - old_asset[1], 8), msg="冻结金额错误。") else: self.assertEqual(amount, round(new_lock_asset - old_asset[1], 8), msg="冻结金额错误。。") time.sleep(1) response = Service.Service().cancel_buyorder( order_id, symbol, source) print(response) Common.search_str(str(response), [self.SUCCESS_RESULT]) order = DB.DB().get_order(table, order_id) self.assertEqual(order[2], -1, msg="订单信息错误") self.assertEqual(DB.DB().get_balance(user_id, asset)[1], old_asset[1], msg="冻结金额未解冻") self.assertEqual(DB.DB().get_balance(user_id, asset)[0], old_asset[0], msg="账户资金错误") except Exception as ex: raise ex
def test109_login_by_phone(self): '''使用手机登录''' try: print('test_login_by_phone') response = ComMeth.ComMeth().login('13866666666') Common.search_str(str(response), [self.SUCCESS_RESULT]) except Exception as ex: raise ex
def test204_address(self): '''地址管理''' print('address') try: response = Service.Service().get_address(1) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test201_finance(self): '''账户资产''' print('finance') try: response = Service.Service().get_finance(1) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test212_finance_limit(self): '''获取提现额度''' print('finance_limit') try: response = Service.Service().get_finance_limit() Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test207_get_recharge_record(self): '''获取充值记录''' print('get_recharge_record') try: response = Service.Service().get_recharge_recorde( 58, '2018-01-01 00:00:00', '2018-08-14 00:00:00', 1, 100) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test205_disable_address(self): '''删除地址''' print('disable_address') try: response = Service.Service().disable_coin_address( DB.DB().get_address(354558, 1)[0]) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test202_account_record(self): '''资金流水''' print('account_record') try: response = Service.Service().get_account_recorde( -1, -1, '2018-5-01', '2018-5-31', 1, 10) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test208_get_withdraw_record(self): '''提现记录''' print('get_withdraw_record') try: response = Service.Service().get_withdraw_recorde( 58, '2018-01-01 00:00:00', '2018-05-01 00:00:00', 1, 100) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test206_makeCoinAddress(self): '''生成火币地址''' try: print('makeCoinAddress') response = Service.Service().get_coin_address( Common.Aliyun_list[0].strip('\n'), Common.Aliyun_list[1].strip('\n'), Common.Aliyun_list[2].strip('\n'), 'register', 73) print(response) Common.search_str(str(response), [self.SUCCESS_RESULT]) except Exception as ex: raise ex
def test203_add_address(self): '''添加地址''' print('add_address') try: response = Service.Service().add_address( '19kAqGjL8qQeoXJw6xQ6KSCMKoVDnJeeeo', 1, 'coinfex', 'false', Common.pwdTwo, Common.generate_otp('ZMUMVRAY6XEBGSOB'), ComMeth.ComMeth().get_code(13866666666, 24), 24) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test210_cancel_withdraw(self): '''取消提现''' print('cancle_withdraw') try: response = Service.Service().cancel_withdraw( 1, DB.DB().get_withdraw_record('out_coin_transaction', 354558, 1, 1)[0]) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def test209_apply_withdraw(self): '''申请提现''' print('apply_withdraw') try: response = Service.Service().apply_withdraw( 1, 6264, 0.001, 0.01, 0, Common.generate_otp('HZTERXEO7C2655JP'), ComMeth.ComMeth().get_code_noali(1, 13866666666), 1, Common.pwdTwo) Common.search_str(str(response), [self.SUCCESS_RESULT]) print(response) except Exception as ex: raise ex
def trade(self, symbol, rate, type, amount, tradePassword, source, user_id, symbol_asset, base_asset, table, tabel_pending=None, flag=None): try: old_balance_symbol = DB.DB().get_balance(user_id, symbol_asset)[0] old_balance_base = DB.DB().get_balance(user_id, base_asset)[0] trade_price = round(DB.DB().get_current_price(symbol) * rate, 8) response = Service.Service().trade(trade_price, amount, type, tradePassword, symbol, source) print(response) Common.search_str(str(response), [self.SUCCESS_RESULT]) order_id = response['data']['id'] order = DB.DB().get_order(table, order_id) self.assertEqual(order[2], 2, msg="订单信息错误") new_balance_symbol = DB.DB().get_balance(user_id, symbol_asset)[0] new_balance_base = DB.DB().get_balance(user_id, base_asset)[0] amount_record_base = DB.DB().get_balance_flow( order_id, base_asset, user_id, tabel_pending) amount_record_symbol = DB.DB().get_balance_flow( order_id, symbol_asset, user_id, tabel_pending) if type == 1: if flag != 'option': self.assertEqual(abs(amount_record_symbol[1]), round(DB.DB().get_fee(symbol) * amount, 8), msg="手续费错误") self.assertEqual(new_balance_symbol, old_balance_symbol + order[1] - abs(amount_record_symbol[1]), msg="账户资产错误。") self.assertEqual(new_balance_base, round(old_balance_base - order[0], 11), msg="账户资产错误。。") elif type == 2: self.assertEqual(abs(amount_record_base[1]), round(DB.DB().get_fee(symbol) * order[0], 8), msg="手续费错误") self.assertEqual(new_balance_symbol, old_balance_symbol - order[1], msg="账户资产错误。") self.assertEqual(new_balance_base, old_balance_base + order[0] - abs(amount_record_base[1]), msg="账户资产错误。。") self.assertEqual(round( amount_record_symbol[0] - amount_record_symbol[2], 8), abs(amount_record_symbol[1]), msg="资金流水错误。") self.assertEqual(round( amount_record_base[0] - amount_record_base[2], 8), abs(amount_record_base[1]), msg="资金流水错误。。") except Exception as ex: raise ex