Beispiel #1
0
    def test_cert_success(self):
        """
        绑卡成功:前提条件-我的银行卡没有银行卡,四要素认证成功
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {2: "绑卡成功:前提条件-我的银行卡没有银行卡,四要素认证成功"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value,
                           self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(
                    key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError(
                    "TestCase {}'s instruction is not Equal to CaseNum.".
                    format(key - 1))

            sql_data = self.filecontent.get_sqldata(serial=key - 1)
            if len(SqlOperation().select_data(sql_data['select'])) == 1:
                SqlOperation().delete_data(sql_data['delete'])

            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)

            expectresult = self.filecontent.get_expectresult(serial=key - 1)
            self.verify.verify_code_200(response=response)

            print("api verify is beginning...")
            self.verify.verify_api(expectresult=expectresult,
                                   result=json_result)
            print("api verify is success.")

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult,
                                    result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult,
                                       result=json_result)
            print("message verify is success.")

            print("data verify is beginning...")
            self.verify.verify_data(expectresult=expectresult,
                                    result=json_result)
            print("data verify is success.")

            print("reason verify is begining...")
            self.verify_reason(serial=key - 1, result=json_result)
            print("reason verify is success.")

            print("success verify is begining...")
            self.verify_reason(serial=key - 1, result=json_result)
            print("success verify is success.")

            print("ALL END!!")
    def test_evaluate_success(self):
        """
        小程序端经纪人佣金订单评价成功
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {1: "小程序端经纪人佣金订单评价成功"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError("TestCase {}'s instruction is not Equal to CaseNum.".format(key - 1))

            sql_data = self.filecontent.get_sqldata(serial=key-1)
            if sql_data['select'] is not None:
                SqlOperation().update_data(sql_data['update'])

            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)
            self.verify.verify_code_200(response=response)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)
            print("message verify is success.")

            print("ALL END!!")
    def test_status_ing(self):
        """
        认证中状态
        校验点:1、从数据库获取对应userid的auth_status=3
               2、message:返回值 获取认证信息成功
               3、data返回的内容
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {4: "认证中状态"}
        for key, value in casenum.items():
            # print(value, self.filecontent.get_instruction(serial=key-1))
            if operator.eq(value,
                           self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(
                    key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError(
                    "用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum."
                    .format(key))

            sql_data = self.filecontent.get_sqldata(serial=key - 1)
            if SqlOperation().select_data(sql_data['select']) is None:
                SqlOperation().insert_data(sql_data['insert'])

            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult,
                                    result=json_result)

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult,
                                       result=json_result)

            print("data verify is beginning...")
            self.verify.verify_data(expectresult=expectresult,
                                    result=json_result)

            print("authStatus verify is begining...")
            self.verify_auth_status(serial=key - 1, result=json_result)

            print("ALL END!!")
Beispiel #4
0
 def verify_formid_sql(self, serial):
     """
     校验请求后数据库是否有生成对应的formId记录
     :return: 
     """
     select_sql = self.filecontent.get_sqldata(serial)['select']
     self.assertEqual(SqlOperation().select_data(select_sql)[0], self.filecontent.get_reqparams(serial)['formId'],
                      msg="check sql db is Error.")
Beispiel #5
0
 def verify_received_mysql(self, serial):
     """
     校验数据库收到了验证码,只判断了最近的一条记录是发送的号码(号码从case获取)
     :param serial
     :return: 
     """
     sql = "SELECT * FROM auto.sms WHERE phone='{}' AND smstype='brokerUserLoginCode'"\
         .format(self.filecontent.get_reqparams(serial)['phone'])
     self.assertIsNotNone(SqlOperation().select_data(sql))
Beispiel #6
0
    def test_get_success(self):
        """
        经纪人客服申诉成功
        校验点:1、message:返回值 success
               2、申述成功后,trans.trade_oper_log多了一条记录,oper_step_desc=经纪人申请申诉
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {1: "经纪人客服申诉成功"}
        for key, value in casenum.items():
            # print(value, self.filecontent.get_instruction(serial=key-1))
            if operator.eq(value,
                           self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(
                    key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError(
                    "用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum."
                    .format(key))
            """
            判断trans.trade_order_broker表订单车商是否申请退款refund_status=1,如果不是,则删除重新插入车商申请退款的订单;
            再判断trans.trade_oper_log表oper_step_desc是否存在“经纪人申请申诉”,如果有的话则删除,防止重复用此订单出现多个申述记录
            """
            sql_data = self.filecontent.get_sqldata(serial=key - 1)
            if SqlOperation().select_data(sql_data['select_broker']) is None:
                SqlOperation().delete_data(sql_data['delete_broker'])
                SqlOperation().insert_data(sql_data['insert'])
            if SqlOperation().select_data(sql_data['select_oper']) is not None:
                SqlOperation().delete_data(sql_data['delete_oper'])
            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult,
                                    result=json_result)

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult,
                                       result=json_result)

            self.verify_oper_step_sql(serial=key - 1)

            print("ALL END!!")
    def test_delete_success(self):
        """
        删除搜索记录成功
        校验点:1、message:返回值 删除搜索日志成功
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {1: "删除搜索记录成功"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError("用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum.".format(key))

            """
            判断搜索记录是否存在于数据库中,如果不在则插入,
            如果在,判断status是否为0,如果不等于0,改成0即状态置为显示在搜索列表中
            """
            sql_data = self.filecontent.get_sqldata(serial=key - 1)
            if SqlOperation().select_data(sql_data['select']) is not None:
                SqlOperation().insert_data(sql_data['insert'])
            else:
                if SqlOperation().select_data(sql_data['select'])[0] != 0:
                    SqlOperation().select_data('update')

            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)
            print("message verify is success.")

            print("data verify is beginning...")
            self.verify.verify_data(expectresult=expectresult, result=json_result)
            print("data verify is success.")

            print("ALL END!!")
Beispiel #8
0
 def verify_oper_step_sql(self, serial):
     """
     校验oper_step_desc=经纪人申请申诉
     :param serial: 
     :return: 
     """
     select_sql = self.filecontent.get_sqldata(serial)['select_oper']
     oper_step_desc = SqlOperation().select_data(select_sql)
     self.assertIsNotNone(
         oper_step_desc,
         msg="经纪人申请申述后,trans.trade_oper_log表中oper_step_desc!='经纪人申请申诉'")
    def test_confirm_success(self):
        """
        确认成交成功,购车证明和到店证明都上传图片
        校验点:1、data返回true
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {1: "确认成交成功,购车证明和到店证明都上传图片"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError("用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum.".format(key))
            # 造数据,如果数据库中有这个单子,则删除后重新插入,用于确认成交
            sql_data = self.filecontent.get_sqldata(serial=key-1)
            if SqlOperation().select_data(sql_data['select_broker']) is not None:
                SqlOperation().delete_data(sql_data['delete_broker'])
            if SqlOperation().select_data(sql_data['select_oper']) is not None:
                SqlOperation().delete_data(sql_data['delete_oper'])
            SqlOperation().insert_data(sql_data['insert'])

            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)
            print("message verify is success.")

            print("data verify is beginning...")
            self.verify.verify_data(expectresult=expectresult, result=json_result)
            print("data verify is success.")

            print("ALL END!!")
Beispiel #10
0
 def get_verify_code(self):
     time.sleep(60)
     self.sendvaliddatacode()
     sql = """
             SELECT code FROM auto.sms WHERE phone='18867520068' AND smstype='brokerUserLoginCode' 
             ORDER BY sendtime DESC LIMIT 1
         """
     code = SqlOperation().select_data(sql=sql)[0]
     if len(code) == 6:
         print("get verify code is ", code)
         return code
     else:
         raise ValueError("The verify code is Error. Please check the sendvalidatacode api is OK.", code)
    def get_response(self, serial):
        """

        :param serial:
        :return: 获取接口返回
        """
        if 'sql' in self.filecontent.get_caselist()[serial]:
            SqlOperation().insert_data(self.json_converto_sql(serial))
        url = Request().get_url(serial=serial,
                                filename=self.filename,
                                apiname=self.apiname)
        response = requests.post(url)
        return response
    def test_confirm_success_nopic(self):
        """
        确认成交成功,未上传图片
        校验点:1、message:返回值 没有附件信息,请重新上传
        :return: 
        """
        time.sleep(2)
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {2: "确认成交成功,不上传图片"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError("用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum.".format(key))
            sql_data = self.filecontent.get_sqldata(serial=key - 1)
            if SqlOperation().select_data(sql_data['select_broker']) is not None:
                SqlOperation().delete_data(sql_data['delete_broker'])
            if SqlOperation().select_data(sql_data['select_oper']) is not None:
                SqlOperation().delete_data(sql_data['delete_oper'])
            SqlOperation().insert_data(sql_data['insert'])

            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print(json_result)
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)
            print("message verify is success.")

            print("ALL END!!")
Beispiel #13
0
    def test_get_success(self):
        """
        小程序表单提交--保存form_id
        校验点:1、message:返回值 success
               2、请求后与数据库生成的记录做对比,form_id与请求参数的form_id保持一致
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {1: "form_id保存成功"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError("用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum.".format(key))

            sql_data = self.filecontent.get_sqldata(serial=key - 1)
            if SqlOperation().select_data(sql_data['select']) is not None:
                SqlOperation().delete_data(sql_data['delete'])

            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)
            print("message verify is success.")

            self.verify_formid_sql(serial=key - 1)

            print("ALL END!!")
    def test_broker_to_confirm(self):
        """
        待经纪人确认订单列表
        校验点:1、校验datalist列表长度<=pagesize的值
               2、校验datalist所有订单的status=1
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {2: "待经纪人确认订单列表"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError("TestCase {}'s instruction is not Equal to CaseNum.".format(key - 1))
            sql_data = self.filecontent.get_sqldata(serial=key - 1)
            if SqlOperation().select_data(sql_data['select']) != 0:
                SqlOperation().delete_data(sql_data['delete'])
            SqlOperation().insert_data(sql_data['insert'])
            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)
            print("message verify is success.")

            self.verify_datalist_number(serial=key - 1, result=json_result)
            self.verify_status(serial=key - 1, result=json_result)

            print("ALL END!!")
 def verify_data_sql(self, serial, result):
     """
     data:从数据库取query_value值用于校验
     :param serial
     :param result
     :return: 
     """
     select_sql = self.filecontent.get_sqldata(serial)['select']
     select_result = SqlOperation().select_data_all(select_sql)
     verify_data = []
     if select_result is None:
         self.assertIsNone(result['data'], msg="result data is not NULL.")
     else:
         for data in select_result:
             verify_data.append(data[0])
         self.assertEqual(sorted(verify_data), sorted(result['data']))
    def setUp(self):
        self.filename = Request().dirname(
        ) + "/Document/Wechat_Applet/getVirtualOrderList.json"

        self.filecontent = FileContent(self.filename)
        self.apiname = self.filecontent.get_apiname()  # 获取apiname用于获得url
        self.api = self.filecontent.get_api()  # 获取api用于校验
        self.caselist = self.filecontent.get_caselist(
        )  # 获取caselist列表,包括"reqParams"和"expectResult"
        # self.casenumber = self.filecontent.get_casenumber()       # 获取case数量

        self.verify = Verify()
        self.verificationErrors = []

        delete_sql = "DELETE FROM trans.trade_announcement_order"
        SqlOperation().delete_data(delete_sql)
Beispiel #17
0
    def test_send_success(self):
        """
        成功发送验证码
        校验点:1、message:返回验证码已发送
               2、数据库收到了验证码
        :return: 
        """
        time.sleep(60)
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {1: "验证码已发送,成功发送验证码"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value,
                           self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(
                    key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError(
                    "TestCase {}'s instruction is not Equal to CaseNum.".
                    format(key - 1))

            delete_sql = """
                                    DELETE FROM auto.sms WHERE phone='{}'
                            """.format(
                self.filecontent.get_reqparams(serial=key - 1)['phone'])
            SqlOperation().delete_data(sql=delete_sql)
            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult,
                                    result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult,
                                       result=json_result)
            print("message verify is success.")

            self.verify_received_mysql(serial=key - 1)

            print("ALL END!!")
Beispiel #18
0
    def test_login_fail(self):
        """
        登陆失败,验证码过期
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {2: "登陆失败,验证码过期/错误"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key-1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key-1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key-1)))
            else:
                raise ValueError("用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum.".format(key))

            delete_sql = """
                                                DELETE FROM auto.sms WHERE phone='{}'
                                        """.format(self.filecontent.get_reqparams(serial=key - 1)['phone'])
            SqlOperation().delete_data(sql=delete_sql)

            response = self.get_response(serial=key-1)
            self.verify.verify_code_200(response=response)
            print(response.content)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key-1)

            print("api verify is beginning...")
            self.verify.verify_api(expectresult=expectresult, result=json_result)
            print("api verify is success.")

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)
            print("message verify is success.")

            print("ALL END!!")
Beispiel #19
0
    def test_offer_expired(self):
        """
        报价已过期状态查询成功
        校验点:1、message:返回值 查询成功
               2、data不为空
               3、status=2
        :return: 
        """
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {2: "报价已过期状态查询成功"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError("用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum.".format(key))

            # 更新数据库auto.company_search_car的search_status、is_valid和auto.company_quote的status、is_valid状态
            sql = self.filecontent.get_sqldata(serial=key - 1)
            for sql_update in sql['update']:
                SqlOperation().update_data(sql_update)

            response = self.get_response(serial=key - 1)
            self.verify.verify_code_200(response=response)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)

            self.verify.verify_data_isNotNull(result=json_result)
            self.verify_status(serial=key-1, result=json_result)

            print("ALL END!!")
    def test_order_status_changed(self):
        """
        当提交成交确认时,订单状态发生变更,message提示
        校验点:1、message:返回值 订单状态已变更,请刷新后重试
        :return: 
        """
        # 设置等待时间,防止并发访问接口
        time.sleep(4)
        # casenum = {serial: instruction}, 如果与json文档不一致的话就会报错
        casenum = {3: "订单状态发生变更,提示信息"}
        for key, value in casenum.items():
            print(value, self.filecontent.get_instruction(serial=key - 1))
            if operator.eq(value, self.filecontent.get_instruction(serial=key - 1)):
                print("TestCase {}: {}".format(key, self.filecontent.get_instruction(serial=key - 1)))
            else:
                raise ValueError("用例匹配失败:TestCase {}'s instruction is not Equal to CaseNum.".format(key))
            sql_data = self.filecontent.get_sqldata(serial=key-1)
            """
            if SqlOperation().select_data(sql_data['select']) == 0:
                SqlOperation().insert_data(sql_data['insert'])
            """
            SqlOperation().update_data(sql_data['update'])
            response = self.get_response(serial=key - 1)
            json_result = response.json()
            print("response content: ", json_result)
            expectresult = self.filecontent.get_expectresult(serial=key - 1)

            print("code verify is beginning...")
            self.verify.verify_code(expectresult=expectresult, result=json_result)
            print("code verify is success.")

            print("message verify is beginning...")
            self.verify.verify_message(expectresult=expectresult, result=json_result)
            print("message verify is success.")

            print("ALL END!!")
Beispiel #21
0
 def tearDown(self):
     SqlOperation().close()