예제 #1
0
    def test_recharge(self, caseInfo):
        headers = caseInfo['requestHeader']
        body = caseInfo['inputParams']
        url = "http://api.lemonban.com/futureloan" + caseInfo['url']
        res = requests.post(url, json=body, headers=headers)

        # 断言
        # 1、响应结果断言
        BaseCase().assert_expected(caseInfo, res)
        # 2、数据库断言
        BaseCase().assert_SQL(caseInfo)
예제 #2
0
    def test_add_loan(self, caseInfo):
        headers = caseInfo['requestHeader']
        body = caseInfo['inputParams']
        url = "http://api.lemonban.com/futureloan" + caseInfo['url']
        res = requests.post(url, json=body, headers=headers)

        # 断言
        # 1、响应结果断言
        BaseCase().assert_expected(caseInfo, res)

        memberId = jmespath.search("data.member_id", res.json())
        if memberId != None:
            loan_id = jmespath.search("data.id", res.json())
            # 2、保存到环境变量中
            GlobalEnvironment().put("loan_id", loan_id)
예제 #3
0
    def test_register(self, caseInfo):
        # 读数据库获取没有注册过的手机号码
        if caseInfo["caseId"] == 1:
            mobile_phone = BaseCase().get_random_phone()
            GlobalEnvironment().put("mobile_phone1", str(mobile_phone + 1))
        elif caseInfo["caseId"] == 2:
            mobile_phone = BaseCase().get_random_phone()
            GlobalEnvironment().put("mobile_phone2", str(mobile_phone + 2))
        elif caseInfo["caseId"] == 3:
            mobile_phone = BaseCase().get_random_phone()
            GlobalEnvironment().put("mobile_phone3", str(mobile_phone + 3))

        # 对当前的case进行参数化替换
        caseInfo = BaseCase().params_replace_current_case_info(caseInfo)

        headers = caseInfo['requestHeader']
        body = caseInfo['inputParams']
        url = "http://api.lemonban.com/futureloan" + caseInfo['url']
        res = requests.post(url, json=body, headers=headers)

        # 断言
        # 1、响应结果断言
        BaseCase().assert_expected(caseInfo, res)
        # 2、数据库断言
        BaseCase().assert_SQL(caseInfo)

        memberId = jmespath.search("data.id", res.json())
        if memberId != None:
            mobile_phone = jmespath.search("data.mobile_phone", res.json())
            # 3、注册成功的密码--从用例数据里面
            pwd = caseInfo['inputParams']['pwd']
            if caseInfo["caseId"] == 1:
                # 2、保存到环境变量中
                GlobalEnvironment().put("mobile_phone1", mobile_phone)
                GlobalEnvironment().put("member_id1", memberId)
                GlobalEnvironment().put("pwd1", pwd)

            elif caseInfo["caseId"] == 2:
                # 2、保存到环境变量中
                GlobalEnvironment().put("mobile_phone2", mobile_phone)
                GlobalEnvironment().put("member_id2", memberId)
                GlobalEnvironment().put("pwd2", pwd)

            elif caseInfo["caseId"] == 3:
                # 2、保存到环境变量中
                GlobalEnvironment().put("mobile_phone3", mobile_phone)
                GlobalEnvironment().put("member_id3", memberId)
                GlobalEnvironment().put("pwd3", pwd)
예제 #4
0
    def test_login(self, caseInfo):
        headers = caseInfo['requestHeader']
        body = caseInfo['inputParams']
        url = "http://api.lemonban.com/futureloan" + caseInfo['url']
        res = requests.post(url, json=body, headers=headers)

        # 断言
        # 1、响应结果断言
        BaseCase().assert_expected(caseInfo, res)

        member_id = jmespath.search("data.id", res.json())
        if member_id != None:
            token = jmespath.search("data.token_info.token", res.json())
            if caseInfo["caseId"] == 1:
                # 2、保存到环境变量中
                GlobalEnvironment().put("token1", token)

            elif caseInfo["caseId"] == 2:
                # 2、保存到环境变量中
                GlobalEnvironment().put("token2", token)

            elif caseInfo["caseId"] == 3:
                # 2、保存到环境变量中
                GlobalEnvironment().put("token3", token)
예제 #5
0
 def setUpClass(cls):
     print("=======所有测试用例执行之前,setupClass整个测试类只执行一次==========")
     caseInfoList = BaseCase().params_replace_all_case_info(cls.caseInfoList)