def test_bind_card_mobile_error(self): """ 测试绑定银行卡绑定手机号不正确 :return: """ mobile = '13511114758' image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi() sms_code_api.get({ 'mobile': mobile, 'type': 'tj_sms_code', 'imgCode': image_code }) sms_code = Redis().get_sms_code(mobile, type='tj') bind_card_api = BindCardApi() bind_card_api.get({ 'bindingType': 1, 'cardNum': '6228480018373695875', 'bankId': 2, 'mobile': mobile, 'verCode': sms_code, 'type': 'tj_sms_code' }) self.assertEqual(bind_card_api.get_resp_code(), 414) self.assertEqual(bind_card_api.get_resp_message(), '手机号码错误,请使用尾号: 7762的手机号进行验证!')
def test_withdraw_apply_amount_max_than_5000(self): """ 测试提现额度不足 :return: """ Redis().fix_user_withdraw_money_today(self.auth_id, 500) Redis().fix_user_withdraw_times(self.auth_id, 1) MysqlHelper().fix_user_money(balance=500000) image_code_api = ImageCodeApi() image_code_api.get({'mobile': self.mobile}) image_code = Redis().get_image_code(self.mobile) sms_code_api = LoginSendMessageApi() sms_code_api.get({ 'mobile': self.mobile, 'type': 'tx_sms_code', 'imgCode': image_code }) sms_code = Redis().get_sms_code(self.mobile, type='tx') withdraw_api = WithdrawApplyApi() withdraw_api.get({ 'amount': 500000, 'source': 1, 'mobile': self.mobile, 'verCode': sms_code, 'type': 'tx_sms_code', 'bindingId': 2 }) self.assertEqual(withdraw_api.get_resp_code(), 423) self.assertEqual(withdraw_api.get_resp_message(), u'当天剩余提现额度为: 499500元,请修改后重试!')
def test_withdraw_apply_amount_less(self): """ 测试账户剩余提现额度不足时申请提现 :return: """ image_code_api = ImageCodeApi() image_code_api.get({'mobile': self.mobile}) image_code = Redis().get_image_code(self.mobile) sms_code_api = LoginSendMessageApi() sms_code_api.get({ 'mobile': self.mobile, 'type': 'tx_sms_code', 'imgCode': image_code }) sms_code = Redis().get_sms_code(self.mobile, type='tx') withdraw_api = WithdrawApplyApi() withdraw_api.get({ 'amount': 500, 'source': 1, 'mobile': self.mobile, 'verCode': sms_code, 'type': 'tx_sms_code', 'bindingId': 2 }) self.assertEqual(withdraw_api.get_resp_code(), 422) self.assertEqual(withdraw_api.get_resp_message(), u'账户剩余提现额度不足,请查看后重试!')
def test_real_name_auth_again(self): """ 测试重复认证 :return: """ union_id = '05' + str(random.randint(1111111, 9999999)) mobile = '1351166' + str(random.randint(1111, 9999)) nickname = 'ceshi000006' image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) sms_code_api.get({ 'mobile': mobile, 'type': 'rz_sms_code', 'imgCode': image_code }) self.assertEqual(sms_code_api.get_resp_code(), 200) sms_code = Redis().get_sms_code(mobile, type='rz') real_name_api = RealNameAuthApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) real_name_api.get({ 'realName': self.real_name, 'mobile': mobile, 'cardNo': self.card_number, 'cardType': 1, 'verCode': sms_code, 'type': 'rz_sms_code' }) self.assertEqual(real_name_api.get_resp_code(), 200) self.assertEqual(real_name_api.get_resp_message(), "恭喜您!认证成功,可以正常购买彩票啦!") real_name_api = RealNameAuthApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) real_name_api.get({ 'realName': self.real_name, 'mobile': mobile, 'cardNo': self.card_number, 'cardType': 1, 'verCode': sms_code, 'type': 'rz_sms_code' }) self.assertEqual(real_name_api.get_resp_code(), 412) self.assertEqual(real_name_api.get_resp_message(), "已经认证,请勿重复认证!")
def test_bind_card_not_auth(self): """ 测试未实名认证绑定银行卡 :return: """ mobile = '1870000' + str(random.randint(1111, 9999)) image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi( union_id=self.not_authentication_union_id, nickname=self.not_authentication_nickname, source=1, head_pic=self.not_authentication_head_pic) sms_code_api.get({ 'mobile': mobile, 'type': 'tj_sms_code', 'imgCode': image_code }) self.assertEqual(sms_code_api.get_resp_code(), 200) sms_code = Redis().get_sms_code(mobile, type='tj') bind_card_api = BindCardApi(union_id=self.not_authentication_union_id, nickname=self.not_authentication_nickname, source=1, head_pic=self.not_authentication_head_pic) bind_card_api.get({ 'bindingType': 1, 'cardNum': '6228480018373695875', 'bankId': 2, 'mobile': mobile, 'verCode': sms_code, 'type': 'tj_sms_code' }) self.assertEqual(bind_card_api.get_resp_code(), 415) self.assertEqual(bind_card_api.get_resp_message(), u'未实名认证,请先实名认证再绑定!') # 获取绑定列表 bind_list_api = BindingListApi( union_id=self.not_authentication_union_id, nickname=self.not_authentication_nickname, source=1, head_pic=self.not_authentication_head_pic) bind_list_api.get() self.assertEqual(bind_list_api.get_resp_code(), 200) self.assertEqual(bind_list_api.get_resp_message(), u'ok') self.assertEqual(bind_list_api.get_resp_result(), [])
def test_bind_card_again(self): """ 测试绑定银行卡重复绑定 :return: """ mobile = '13501077762' image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi() sms_code_api.get({ 'mobile': mobile, 'type': 'tj_sms_code', 'imgCode': image_code }) sms_code = Redis().get_sms_code(mobile, type='tj') bind_card_api = BindCardApi() bind_card_api.get({ 'bindingType': 1, 'cardNum': '6228480018373695875', 'bankId': 2, 'mobile': mobile, 'verCode': sms_code, 'type': 'tj_sms_code' }) self.assertEqual(bind_card_api.get_resp_code(), 200) image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi() sms_code_api.get({ 'mobile': mobile, 'type': 'tj_sms_code', 'imgCode': image_code }) sms_code = Redis().get_sms_code(mobile, type='tj') bind_card_api = BindCardApi() bind_card_api.get({ 'bindingType': 1, 'cardNum': '6228480018373695875', 'bankId': 2, 'mobile': mobile, 'verCode': sms_code, 'type': 'tj_sms_code' }) self.assertEqual(bind_card_api.get_resp_code(), 407) self.assertEqual(bind_card_api.get_resp_message(), u'已绑定,无需再次绑定!')
def test_real_name_is_exits(self): """ 测试绑定已经绑定的身份证号 :return: """ union_id = '07' + str(random.randint(1111111, 9999999)) mobile = '1351188' + str(random.randint(1111, 9999)) nickname = 'ceshi000008' image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) sms_code_api.get({ 'mobile': mobile, 'type': 'rz_sms_code', 'imgCode': image_code }) self.assertEqual(sms_code_api.get_resp_code(), 200) sms_code = Redis().get_sms_code(mobile, type='rz') real_name_api = RealNameAuthApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) real_name_api.get({ 'realName': '高英龙', 'mobile': mobile, 'cardNo': '370105199512046531', 'cardType': 1, 'verCode': sms_code, 'type': 'rz_sms_code' }) self.assertEqual(real_name_api.get_resp_code(), 425) self.assertEqual(real_name_api.get_resp_message(), "输入的身份证号已绑定其他账号,请更换一个新的身份证号!")
def test_withdraw_apply_not_cre(self): """ 测试未实名用户请求提现 :return: """ union_id = '10' + str(random.randint(1111111, 9999999)) mobile = '1311112' + str(random.randint(1111, 9999)) nickname = 'ceshi100001' image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) sms_code_api.get({ 'mobile': mobile, 'type': 'tx_sms_code', 'imgCode': image_code }) self.assertEqual(sms_code_api.get_resp_code(), 200) sms_code = Redis().get_sms_code(mobile, type='tx') withdraw_api = WithdrawApplyApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) withdraw_api.get({ 'amount': 500, 'source': 1, 'mobile': mobile, 'verCode': sms_code, 'type': 'tx_sms_code', 'bindingId': 2 }) self.assertEqual(withdraw_api.get_resp_code(), 415) self.assertEqual(withdraw_api.get_resp_message(), u'未实名认证,请先实名认证再绑定!')
def test_real_name_auth_not_18(self): """ 测试未满18岁 :return: """ union_id = '06' + str(random.randint(1111111, 9999999)) mobile = '1351177' + str(random.randint(1111, 9999)) nickname = 'ceshi000007' image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) sms_code_api.get({ 'mobile': mobile, 'type': 'rz_sms_code', 'imgCode': image_code }) self.assertEqual(sms_code_api.get_resp_code(), 200) sms_code = Redis().get_sms_code(mobile, type='rz') real_name_api = RealNameAuthApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) real_name_api.get({ 'realName': self.real_name, 'mobile': mobile, 'cardNo': '410223200202102231', 'cardType': 1, 'verCode': sms_code, 'type': 'rz_sms_code' }) self.assertEqual(real_name_api.get_resp_code(), 418) self.assertEqual(real_name_api.get_resp_message(), "未成年人不可购买彩票!")
def test_real_name_auth_card_num_error(self): """ 测试绑定不存在的身份证 :return: """ union_id = '03' + str(random.randint(1111111, 9999999)) mobile = '1351144' + str(random.randint(1111, 9999)) nickname = 'ceshi000004' image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) sms_code_api.get({ 'mobile': mobile, 'type': 'rz_sms_code', 'imgCode': image_code }) self.assertEqual(sms_code_api.get_resp_code(), 200) sms_code = Redis().get_sms_code(mobile, type='rz') real_name_api = RealNameAuthApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) real_name_api.get({ 'realName': self.real_name, 'mobile': mobile, 'cardNo': '370481200602058511', 'cardType': 1, 'verCode': sms_code, 'type': 'rz_sms_code' }) self.assertEqual(real_name_api.get_resp_code(), 419) self.assertEqual(real_name_api.get_resp_message(), "身份证号码格式有误!")
def test_bind_card_success(self): """ 测试绑定银行卡成功 :return: """ mobile = '13501077762' image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi() sms_code_api.get({ 'mobile': mobile, 'type': 'tj_sms_code', 'imgCode': image_code }) sms_code = Redis().get_sms_code(mobile, type='tj') bind_card_api = BindCardApi() bind_card_api.get({ 'bindingType': 1, 'cardNum': '6228480018373695875', 'bankId': 2, 'mobile': mobile, 'verCode': sms_code, 'type': 'tj_sms_code' }) self.assertEqual(bind_card_api.get_resp_code(), 200) # 获取绑定列表 bind_list_api = BindingListApi() bind_list_api.get() self.assertEqual(bind_list_api.get_resp_code(), 200) self.assertEqual(bind_list_api.get_resp_message(), u'ok') result = bind_list_api.get_resp_result()[0] self.assertEqual(result['bankId'], 2) self.assertEqual(result['bindingType'], 1) self.assertEqual(result['cardNum'], u'6228480018373695875') self.assertEqual(result['bankName'], u'农业银行')
def test_withdraw_apply_amount_success_first(self): """ 测试当天首次申请提现100元成功 :return: """ Redis().fix_user_withdraw_times(self.auth_id, 0) MysqlHelper().fix_user_money(balance=100) image_code_api = ImageCodeApi() image_code_api.get({'mobile': self.mobile}) image_code = Redis().get_image_code(self.mobile) sms_code_api = LoginSendMessageApi() sms_code_api.get({ 'mobile': self.mobile, 'type': 'tx_sms_code', 'imgCode': image_code }) sms_code = Redis().get_sms_code(self.mobile, type='tx') withdraw_api = WithdrawApplyApi() withdraw_api.get({ 'amount': 100, 'source': 1, 'mobile': self.mobile, 'verCode': sms_code, 'type': 'tx_sms_code', 'bindingId': 2 }) self.assertEqual(withdraw_api.get_resp_code(), 200) self.assertEqual(withdraw_api.get_resp_message(), u'提现申请成功,请等待管理员审核!') # 提现记录 my_precent_api = MyPrecentApi() my_precent_api.get() self.assertEqual(my_precent_api.get_resp_code(), 200) self.assertEqual(my_precent_api.get_resp_message(), u'success') result = my_precent_api.get_resp_result() self.assertEqual(len(result), 1) self.assertIsNotNone(result[0]['presentRecordNo']) self.assertEqual(result[0]['authId'], self.auth_id) self.assertEqual(result[0]['amount'], 100.0) self.assertEqual(result[0]['actualAmount'], 100.0) self.assertIsNone(result[0]['amountOfCash']) self.assertEqual(result[0]['tip'], 0.0) self.assertEqual(result[0]['presentRecordStatus'], 0) self.assertIsNone(result[0]['presentRecordStatusPre']) self.assertEqual(result[0]['debitStatus'], u'1') self.assertEqual(result[0]['source'], 1) self.assertEqual(result[0]['notify'], 9) self.assertIsNone(result[0]['bak']) self.assertEqual(result[0]['realName'], u'高英龙') self.assertEqual(result[0]['mobile'], self.mobile) self.assertEqual(result[0]['bindingId'], 2) # 账户变动记录 my_ac_det_api = MyAcDetApi() my_ac_det_api.get({ 'unionId': MysqlHelper().get_user_details()['union_id'], 'source': 1 }) self.assertEqual(my_ac_det_api.get_resp_code(), 200) self.assertEqual(my_ac_det_api.get_resp_message(), u'success') result = my_ac_det_api.get_resp_result() self.assertEqual(len(result), 1) self.assertEqual(result[0]['user_id'], MysqlHelper().get_user_details()['id']) self.assertEqual(result[0]['tradeType'], 3) self.assertEqual(result[0]['amountS'], -100.0)
def test_real_name_auth_success(self): """ 测试正常实名认证成功 :return: """ union_id = '00' + str(random.randint(1111111, 9999999)) mobile = '1351112' + str(random.randint(1111, 9999)) nickname = 'ceshi000001' # 实名认证前获取用户信息 user_info_api = GetUserInfo(union_id, nickname=nickname, head_pic=self.head_pic, source=1) user_info_api.get({"unionId": union_id, "source": 1}) self.assertEqual(user_info_api.get_resp_code(), 200) result = user_info_api.get_resp_result() self.assertIsNotNone(result['userName']) self.assertEqual(result['userStatus'], 1) self.assertIsNone(result['password']) self.assertIsNone(result['email']) self.assertEqual(result['unionId'], union_id) self.assertEqual(result['nickname'], nickname) self.assertEqual(result['headPic'], self.head_pic) self.assertEqual(result['platformId'], 1) self.assertIsNone(result['authId']) # 实名认证流程 image_code_api = ImageCodeApi() image_code_api.get({'mobile': mobile}) image_code = Redis().get_image_code(mobile) sms_code_api = LoginSendMessageApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) sms_code_api.get({ 'mobile': mobile, 'type': 'rz_sms_code', 'imgCode': image_code }) self.assertEqual(sms_code_api.get_resp_code(), 200) sms_code = Redis().get_sms_code(mobile, type='rz') real_name_api = RealNameAuthApi(union_id, nickname=nickname, head_pic=self.head_pic, source=1) real_name_api.get({ 'realName': self.real_name, 'mobile': mobile, 'cardNo': self.card_number, 'cardType': 1, 'verCode': sms_code, 'type': 'rz_sms_code' }) self.assertEqual(real_name_api.get_resp_code(), 200) self.assertEqual(real_name_api.get_resp_message(), "恭喜您!认证成功,可以正常购买彩票啦!") # 实名认证后获取用户信息 user_info_api = GetUserInfo(union_id, nickname=nickname, head_pic=self.head_pic, source=1) user_info_api.get({"unionId": union_id, "source": 1}) self.assertEqual(user_info_api.get_resp_code(), 200) result = user_info_api.get_resp_result() self.assertIsNotNone(result['userName']) self.assertEqual(result['userStatus'], 1) self.assertIsNone(result['password']) self.assertIsNone(result['email']) self.assertEqual(result['unionId'], union_id) self.assertEqual(result['nickname'], nickname) self.assertEqual(result['headPic'], self.head_pic) self.assertEqual(result['platformId'], 1) self.assertIsNotNone(result['authId'])