def weixin_unbind_success(self):
        '''解绑成功'''

        params_dict = dict(self.initparams)
        #1、先向插入customer_third_wechat
        #1.1获取一个未绑定的custid
        sql = 'select cust_id from customer where cust_id not in (select cust_id from customer_third_wechat) and cust_id>0 limit 1;'

        custid = PyMySQL().mysqlget(sql)

        #1.2插入数据

        localtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

        sql = 'insert into customer_third_wechat(cust_id,wx_union_id,cust_bind_type,wx_use_status,cust_status,creation_date,last_changed_date) ' \
              'values({},{},{},{},{},{},{});'.format(int(custid),'"fake1230900000000"',1,1,1,\
                                                                                  '"'+localtime+'"','"'+localtime+'"')

        PyMySQL().mysqlinsert(sql)

        params_dict['custid'] = custid
        status_error_code = WeixinUnbindDeleteReturnCodeEnum.SUCCESS.value

        return params_dict, status_error_code

        pass
Exemplo n.º 2
0
def teardown_module():
    '''用例结果数据销毁'''

    #删除customer表
    PyMySQL().mysqldel('customer', 'cust_mobile',
                       WeixinRegister.initparams['mobilephone'])

    #删除customer_third_wechat表
    PyMySQL().mysqldel('customer_third_wechat', 'wx_union_id',
                       WeixinRegister.initparams['union_id'])
Exemplo n.º 3
0
    def custid_parent_already_bind_qq(self):
        '''父账号已绑定qq'''
        request_data = dict(self.initparams)
        thirdid = 6  #qq
        sql = "select cust_id from customer where cust_id in (" \
              " select cust_id from customer_third where third_id=6) and cust_mobile<>'' limit 1"
        request_data['custid_parent'] = PyMySQL().mysqlget(sql)

        sql = "select cust_id from customer where cust_id in (" \
              " select cust_id from customer_third where third_id=6) and cust_mobile='' limit 1"
        request_data['custid_child'] = PyMySQL().mysqlget(sql)

        status_error_code = CombineReturnCodeEnum.CUSTID_ALREADY_BIND_WEIXIN.value

        return request_data, status_error_code
Exemplo n.º 4
0
    def custid_parent_already_bind_wechat(self):
        '''父账号已绑定微信'''
        request_data = dict(self.initparams)
        #从customer_combine中选择一个cust_id
        sql = "select cust_id from customer where cust_id in (" \
              " select cust_id from customer_third_wechat where cust_bind_type=2) and cust_mobile<>'' limit 1"
        request_data['custid_parent'] = PyMySQL().mysqlget(sql)

        #未绑定微信的cust_id
        sql="select cust_id from customer where cust_id in (select cust_id from " \
            "customer_third_wechat where cust_bind_type=1)  and cust_mobile='' limit 1"
        request_data['custid_child'] = PyMySQL().mysqlget(sql)

        status_error_code = CombineReturnCodeEnum.CUSTID_ALREADY_BIND_WEIXIN.value

        return request_data, status_error_code
Exemplo n.º 5
0
def teardown_module():
    '''用例结果数据销毁'''
    combine = Combine()
    custidlist = [combine.custid, combine.custid_no_phone]
    for custid in custidlist:
        data = {'cust_id': custid}
        PyMySQL().mysqldel('customer_combine', data)
Exemplo n.º 6
0
    def __init__(self):

        #custid
        sql="select cust_id,combine_cust_id from customer_combine where cust_id in (" \
            "select combine_cust_id from customer_combine) and combine_relation_type=1"

        custid, custid_child = PyMySQL().mysqlget(sql)

        self.initparams['custid'] = custid
        self.initparams['custid_child'] = custid_child

        #没有绑定的cust_id
        sql="select cust_id,combine_cust_id from customer_combine where cust_id not in (" \
            "select combine_cust_id from customer_combine) and combine_relation_type=1"

        self.custid_unbind, self.custid_child_inbind = PyMySQL().mysqlget(sql)
Exemplo n.º 7
0
def teardown_module():
    '''用例结果数据销毁'''
    data = {
        'cust_id': SetCombineResult.initparams['custid'],
        'combine_cust_id': SetCombineResult.initparams['custid_child']
    }
    # print(data)
    PyMySQL().mysqldel('customer_combine_process', data)
def teardown_module():
    '''用例结果数据销毁'''

    #删除customer_third_wechat表
    PyMySQL().mysqldel('customer_third_wechat', 'wx_union_id',
                       Weixin_Bind_Custid.initparams['union_id'])

    #to do,其他表
    pass
Exemplo n.º 9
0
    def custid_parent_nophone(self):
        '''父账号未绑定手机'''
        request_data = dict(self.initparams)

        sql = "select cust_id from customer where cust_id>0 and cust_mobile='' limit 1"
        request_data['custid_parent'] = PyMySQL().mysqlget(sql)
        status_error_code = CombineReturnCodeEnum.CUSTID_NOT_BIND_MOBILE.value

        return request_data, status_error_code
Exemplo n.º 10
0
    def weixin_binded(self):
        '''当前微信曾绑定过其它custid'''
        params_dict = dict(self.initparams)

        #1.从库里选择一个未绑定过微信的custid
        sql = 'select cust_id from customer where cust_id not in (select cust_id from customer_third_wechat) and cust_id>0 limit 1;'
        custid = PyMySQL().mysqlget(sql)

        #2.从库里选择一个微信union_id(该union_id必被绑定过)
        sql = 'select wx_union_id from customer_third_wechat where cust_bind_type=2 limit 1; '
        unionid = PyMySQL().mysqlget(sql)

        #3.更新组合参数
        params_dict['custid'] = custid
        params_dict['union_id'] = unionid

        status_error_code = WeixinBindCustidReturnCodeEnum.WEIXIN_BINDED.value

        return params_dict, status_error_code
Exemplo n.º 11
0
    def unionid_exist_and_active(self):
        '''union_id存在,且已激活'''
        params_dict = dict(self.initparams)
        sql = "select wx_union_id from customer_third_wechat where " \
              "cust_status = 1 and wx_use_status = 1 and cust_bind_type!='' and wx_union_id !='' limit 1"

        params_dict['union_id'] = PyMySQL().mysqlget(sql)
        status_error_code = WeixinLoginReturnCodeEnum.LOGIN_STATUS_CODE_SUCCESS.value

        return params_dict, status_error_code
Exemplo n.º 12
0
def teardown_module():
    '''用例结果数据销毁'''

    #改回原来数据库的值
    PyMySQL().mysqldel('customer_verify_email',{
        'cust_id':Check_Email_Vcode.initparams['custid'],
                       'verify_email':Check_Email_Vcode.initparams['email']})

    #to do,其他表
    pass
Exemplo n.º 13
0
    def unionid_custid_cancel(self):
        '''union_id对应的cust_id注销'''
        params_dict = dict(self.initparams)
        sql ="select cust_id from customer where cust_id in(select cust_id from customer_third_wechat" \
             " where cust_status = 1 and cust_bind_type !='' and wx_union_id !='') and cust_status=-1 limit 1"

        params_dict['union_id'] = PyMySQL().mysqlget(sql)
        status_error_code = WeixinLoginReturnCodeEnum.LOGIN_STATUS_CODE_CUST_NOT_EXISTS.value

        return params_dict, status_error_code
    def newemail_exist(self):
        '''新邮箱已存在'''
        params_dict = dict(self.initparams)
        params_dict['newPassword'] = ''  #密码置空

        sql = " select cust_email from customer where cust_email!='' limit 1"
        email = PyMySQL().mysqlget(sql)
        params_dict['newEmail'] = email

        status_error_code = ChangeEmailorPasswordReturnCodeEnum.EMAIL_EXISTS.value
        return params_dict, status_error_code
Exemplo n.º 15
0
    def custid_child_bindphone(self):
        '''子账号已绑定手机'''
        request_data = dict(self.initparams)

        sql = "select cust_id from customer where cust_id>0 and cust_mobile<>'' limit 5,1"
        request_data['custid_child'] = PyMySQL().mysqlget(sql)
        request_data['custid_parent'] = self.custid

        status_error_code = CombineReturnCodeEnum.CUSTID_ALREADY_BIND_MOBILE.value

        return request_data, status_error_code
Exemplo n.º 16
0
    def dbcheckok(self,data):

        #成功,检查customer_login_log
        if data[1][0]==LoginSmsReturnCodeEnum.LOGIN_STATUS_CODE_SUCCESS.value[0]:

            sql="select count(*) from customer_login_log where login_ip={} ".format('"'+data[0]['ip_address']+'"')

            return PyMySQL().mysqlget(sql)>=1


        #不成功,检查
        if data[1][0] in [LoginSmsReturnCodeEnum.LOGIN_STATUS_CODE_CUST_NOT_EXISTS.value[0]] :

            #登录日志
            sql = "select count(*) from customer_login_log where login_ip={} and cust_id={}".format('"' + data[0]['ip_address'] + '"',-1)

            return PyMySQL().mysqlget(sql) >= 1

            pass

        #其他,不检查
        return True
Exemplo n.º 17
0
    def combine_doing(self):
        '''合并进行中'''
        params_dict = dict(self.initparams)

        #用主账号在customer_combine中combine_status=0的微信账号
        sql="select cust_id from customer_third_wechat where cust_id in (" \
            "select cust_id from customer_combine where combine_status=0) and cust_status!=-1 limit 1"

        #
        params_dict['custid'] = PyMySQL().mysqlget(sql)
        status_error_code = CombineStatusReturnCodeEnum.COMBINE_DOING.value

        return params_dict, status_error_code
Exemplo n.º 18
0
    def custid_apply_cancel_deny(self):
        '''提交注销申请的账户不能合并'''
        request_data = dict(self.initparams)

        # 注销申请的cust_id
        sql = "select cust_id from customer where cust_id in (select cust_id from " \
              "customer_cancel_apply where cust_mobile<>'' ) and cust_status!=-1 limit 1"
        request_data['custid_parent'] = PyMySQL().mysqlget(sql)

        request_data['custid_child'] = self.custid_no_phone

        status_error_code = CombineReturnCodeEnum.CUSTID_ALREADY_APPLY_CANCEL.value
        return request_data, status_error_code
Exemplo n.º 19
0
def test_WeixinBindCustid(pyfixture):

    #请求
    url = Weixin_Bind_Custid.url
    data = pyfixture[0]
    res = request(url=url, data=data)
    #print(data)
    assert res['statusCode'] == pyfixture[1][0]

    if res['statusCode'] == WeixinBindCustidReturnCodeEnum.SUCCESS.value[0]:
        assert PyMySQL().checkdbok(
            'customer_third_wechat', 'wx_union_id',
            Weixin_Bind_Custid.initparams['union_id']), '''未写入数据库'''
Exemplo n.º 20
0
    def thirdid_no_customerinfo(self):
        '''third_id对应的cust_id被注销'''
        params_dict = dict(self.initparams)

        sql = "select cust_third_id,third_id from customer_third where cust_status=-1 order by cust_third_id desc limit 1"

        custthird = PyMySQL().mysqlget(sql)
        params_dict['cust_third_id'] = custthird[0]
        params_dict['third_id'] = custthird[1]

        status_error_code = LoginThirdReturnCodeEnum.LOGIN_STATUS_CODE_CUST_NOT_EXISTS.value

        return params_dict, status_error_code
Exemplo n.º 21
0
    def weixin_notbind_custid(self):
        '''未绑定'''
        params_dict = dict(self.initparams)

        #从库里获取一个未绑定的账户
        sql = 'select wx_union_id from customer_third_wechat where cust_bind_type=2 limit 1; '

        unionid = PyMySQL().mysqlget(sql)
        params_dict['unionid'] = unionid

        status_error_code = GetWeixinBindCustidReturnCodeEnum.NOT_COMBINED.value

        return params_dict, status_error_code
Exemplo n.º 22
0
    def custid_child_already_combine(self):
        '''子账号发生过绑定'''
        request_data = dict(self.initparams)

        request_data['custid_parent'] = self.custid
        # 发生过绑定的cust_id
        sql = "select cust_id from customer where cust_id in (select cust_id from " \
              "customer_combine )  and cust_mobile='' limit 1"
        request_data['custid_child'] = PyMySQL().mysqlget(sql)

        status_error_code = CombineReturnCodeEnum.CUSTID_COMBINE_REPEAT_VERIFY_FAIL.value

        return request_data, status_error_code
Exemplo n.º 23
0
    def thirdid_success(self):
        '''三方登录成功'''
        params_dict = dict(self.initparams)

        sql = "select cust_third_id,third_id from customer_third where cust_status=1 and is_valid=1 order by cust_third_id desc limit 1"

        custthird = PyMySQL().mysqlget(sql)
        params_dict['cust_third_id'] = custthird[0]
        params_dict['third_id'] = custthird[1]

        status_error_code = LoginThirdReturnCodeEnum.LOGIN_STATUS_CODE_SUCCESS.value

        return params_dict, status_error_code
Exemplo n.º 24
0
    def combine_notdo(self):
        '''未合并'''
        params_dict = dict(self.initparams)

        #从customer_third_wechat表中找到一条cust_bind_type=2(微信注册)的custid,该custid作为子账号在customer_combine表不存在
        sql='select cust_id from customer_third_wechat where ' \
            'cust_bind_type=2 and cust_id not in (select cust_id from customer_combine where combine_relation_type=1 ) limit 1'

        custid = PyMySQL().mysqlget(sql)
        params_dict['custid'] = custid

        status_error_code = CombineStatusReturnCodeEnum.NOT_COMBINED.value

        return params_dict, status_error_code
Exemplo n.º 25
0
    def combine_notweixin(self):
        '''非微信账号,即主站账号'''

        params_dict = dict(self.initparams)

        #从库里获取一个主站账户
        sql='select cust_id from customer where cust_id not in (select cust_id from customer_third_wechat union ' \
            ' select cust_id from customer_third) and cust_id>0 limit 1'

        custid = PyMySQL().mysqlget(sql)
        params_dict['custid'] = custid
        status_error_code = CombineStatusReturnCodeEnum.NOT_WEIXIN.value

        return params_dict, status_error_code
Exemplo n.º 26
0
    def weixin_binc_custid_success(self):
        '''绑定成功'''
        params_dict = dict(self.initparams)

        # 1.从库里选择一个未绑定过微信的custid
        sql = 'select cust_id from customer where cust_id not in (select cust_id from customer_third_wechat)  and cust_id>0 limit 1 ;'
        custid = PyMySQL().mysqlget(sql)

        # 2.更新组合参数
        params_dict['custid'] = custid

        status_error_code = WeixinBindCustidReturnCodeEnum.SUCCESS.value

        return params_dict, status_error_code
    def custid_already_combine(self):
        '''账号合并的不允许删除'''

        #1、从customer_combine和customer_third_wechat中找一个custid传参
        sql = 'select combine_cust_id from customer_combine where combine_cust_id in (select cust_id from customer_third_wechat) limit 1;'

        custid_combinded = PyMySQL().mysqlget(sql)

        params_dict = dict(self.initparams)

        params_dict['custid'] = custid_combinded
        status_error_code = WeixinUnbindDeleteReturnCodeEnum.COMBINE_DENY.value

        return params_dict, status_error_code
Exemplo n.º 28
0
    def verify_ok(self):
        '''账号合规'''
        params_dict = dict(self.initparams)

        #从库里选一个微信注册用户
        sql='select cust_id from customer_third_wechat where cust_id in (select cust_id from customer where  cust_mobile="" and ' \
            ' cust_email like "%ddmobile_user.com") ' \
            'and cust_bind_type=2 limit 1;'

        custid = PyMySQL().mysqlget(sql)
        params_dict['custid'] = custid

        status_error_code = WeixinVerifyReturnCodeEnum.SUCCESS.value

        return params_dict, status_error_code
Exemplo n.º 29
0
    def moible_bind_dangdang(self):
        '''mobile 未绑定'''
        params_dict = dict(self.initparams)

        #找一个mobile在customer表但不在customer_third_wechat表中
        sql=" select cust_mobile from customer where cust_id not in (select cust_id from customer_third_wechat ) " \
            " and cust_status!=-1 and length(cust_mobile)=11 limit 1"

        mobile = PyMySQL().mysqlget(sql)

        params_dict['mobile'] = mobile

        status_error_code = EnumMobileBindFlag.CUST_BIND.value

        return params_dict, status_error_code
Exemplo n.º 30
0
def test_SetCombineResult(pyfixture):

    #请求
    url = SetCombineResult.url
    data = pyfixture[0]
    res = request(url=url, data=data)
    #print(data)
    assert res['return_code'] == pyfixture[1][0]
    if res['return_code'] == SetCombineResultReturnCodeEnum.SUCCESS.value[0]:
        #检查数据库日志
        data = {
            'cust_id': SetCombineResult.initparams['custid'],
            'combine_cust_id': SetCombineResult.initparams['custid_child']
        }
        assert PyMySQL().checkdbok('customer_combine_process',
                                   data), '''写入数据库失败'''