コード例 #1
0
    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元,请修改后重试!')
コード例 #2
0
    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的手机号进行验证!')
コード例 #3
0
    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'账户剩余提现额度不足,请查看后重试!')
コード例 #4
0
    def test_edit_mobile_old_mobile_error(self):
        """
        测试请求接口原手机号错误
        :return:
        """
        new_mobile = '1581111' + str(random.randint(2222, 9999))

        image_code_api = ImageCodeApi()
        image_code_api.get({'mobile': new_mobile})

        image_code = Redis().get_image_code(new_mobile)
        sms_code_api = SendMessageApi()
        sms_code_api.get({
            'mobile': new_mobile,
            'type': 'xg_sms_code',
            'imgCode': image_code
        })

        self.assertEqual(sms_code_api.get_resp_code(), 200)
        sms_code = Redis().get_sms_code(new_mobile, type='xg')

        edit_mobile_api = EditMobileApi()
        edit_mobile_api.get({
            'mobile': new_mobile,
            'verCode': sms_code,
            'type': 'xg_sms_code'
        })

        self.assertEqual(edit_mobile_api.get_resp_code(), 414)
        self.assertEqual(edit_mobile_api.get_resp_message(), u'原手机号错误,请重新填写!')
コード例 #5
0
    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(), "已经认证,请勿重复认证!")
コード例 #6
0
    def test_get_image_code_success(self):
        """
        测试获取图形验证码成功
        :return:
        """
        image_code_api = ImageCodeApi()
        image_code_api.get({'mobile': self.mobile})

        image_code = Redis().get_image_code(self.mobile)
        self.assertEqual(len(image_code), 4)
コード例 #7
0
    def test_get_image_code_mobile_error(self):
        """
        测试请求接口手机号格式不对可以获取成功
        :return:
        """
        image_code_api = ImageCodeApi()
        image_code_api.get({'mobile': '99999999999'})

        image_code = Redis().get_image_code('99999999999')
        self.assertEqual(len(image_code), 4)
コード例 #8
0
    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(), [])
コード例 #9
0
    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'已绑定,无需再次绑定!')
コード例 #10
0
    def test_edit_mobile_success(self):
        """
        测试修改绑定手机号成功
        :return:
        """
        new_mobile = '1581111' + str(random.randint(2222, 9999))
        # 验证原手机号
        image_code_api = ImageCodeApi()
        image_code_api.get({'mobile': self.old_mobile})

        image_code = Redis().get_image_code(self.old_mobile)
        sms_code_api = SendMessageApi()
        sms_code_api.get({
            'mobile': self.old_mobile,
            'type': 'xg_sms_code',
            'imgCode': image_code
        })
        # self.assertEqual(sms_code_api.get_resp_code(), 200)
        sms_code = Redis().get_sms_code(self.old_mobile, type='xg')

        edit_mobile_api = EditMobileApi()
        edit_mobile_api.get({
            'mobile': self.old_mobile,
            'verCode': sms_code,
            'type': 'xg_sms_code'
        })

        self.assertEqual(edit_mobile_api.get_resp_code(), 200)

        # 绑定新手机号
        image_code_api = ImageCodeApi()
        image_code_api.get({'mobile': new_mobile})

        image_code = Redis().get_image_code(new_mobile)
        sms_code_api = SendMessageApi()
        sms_code_api.get({
            'mobile': new_mobile,
            'type': 'xg_sms_code',
            'imgCode': image_code
        })

        self.assertEqual(sms_code_api.get_resp_code(), 200)
        sms_code = Redis().get_sms_code(new_mobile, type='xg')

        edit_mobile_api = EditMobileApi()
        edit_mobile_api.get({
            'mobile': new_mobile,
            'verCode': sms_code,
            'type': 'xg_sms_code'
        })

        self.assertEqual(edit_mobile_api.get_resp_code(), 200)

        self.assertEqual(new_mobile,
                         mysql().get_user_auth(self.auth_id)['mobile'])
コード例 #11
0
    def test_send_xg_sms_code_mobile_error(self):
        """
        测试请求接口手机号位数不正确
        :return:
        """
        mobile = '1350114'
        image_code_api = ImageCodeApi()
        image_code_api.get({'mobile': mobile})

        image_code = Redis().get_image_code(mobile)
        sms_code_api = SendMessageApi()
        sms_code_api.get({
            'mobile': mobile,
            'type': 'xg_sms_code',
            'imgCode': image_code
        })

        self.assertEqual(sms_code_api.get_resp_code(), 424)
        self.assertEqual(sms_code_api.get_resp_message(), u'手机号格式错误!')
コード例 #12
0
    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(),
                         "输入的身份证号已绑定其他账号,请更换一个新的身份证号!")
コード例 #13
0
    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(), "未成年人不可购买彩票!")
コード例 #14
0
    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'未实名认证,请先实名认证再绑定!')
コード例 #15
0
    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(), "身份证号码格式有误!")
コード例 #16
0
    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'农业银行')
コード例 #17
0
    def test_send_xg_sms_code_image_code_upper(self):
        """
        测试图形验证码大写情况下短信发送成功
        :return:
        """
        mobile = '1350114' + 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 = SendMessageApi()
        sms_code_api.get({
            'mobile': mobile,
            'type': 'xg_sms_code',
            'imgCode': image_code.upper()
        })

        self.assertEqual(sms_code_api.get_resp_code(), 200)
        sms_code = Redis().get_sms_code(mobile, type='xg')
        self.assertEqual(len(sms_code), 4)
        self.assertTrue(sms_code.isdigit())
コード例 #18
0
    def test_send_tj_sms_code(self):
        """
        发送绑定银行卡短信验证码
        :return:
        """
        mobile = '1350103' + 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 = SendMessageApi()
        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')
        self.assertEqual(len(sms_code), 4)
        self.assertTrue(sms_code.isdigit())
コード例 #19
0
    def test_send_xg_sms_code_fast(self):
        """
        测试发送验证码成功后,1分钟内不可再次获取
        :return:
        """
        mobile = '1350104' + 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 = SendMessageApi()
        sms_code_api.get({
            'mobile': mobile,
            'type': 'xg_sms_code',
            'imgCode': image_code
        })

        self.assertEqual(sms_code_api.get_resp_code(), 200)

        sms_code = Redis().get_sms_code(mobile, type='xg')
        self.assertEqual(len(sms_code), 4)
        self.assertTrue(sms_code.isdigit())

        image_code_api = ImageCodeApi()
        image_code_api.get({'mobile': mobile})

        image_code = Redis().get_image_code(mobile)
        sms_code_api = SendMessageApi()
        sms_code_api.get({
            'mobile': mobile,
            'type': 'xg_sms_code',
            'imgCode': image_code
        })

        self.assertEqual(sms_code_api.get_resp_code(), 101)
        self.assertEqual(sms_code_api.get_resp_message(),
                         u'短信已发送,请稍等,如未收到,请在1分钟后重新发送!')
コード例 #20
0
    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)
コード例 #21
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'])