def test_审核项目配置(self, cases):

        for caseName, caseInfo in cases.items():
            caseName = caseName
            caseData = caseInfo["data"]
            check = caseInfo["assert"]
            self.__dict__['_testMethodDoc'] = caseName

        ids = {"id": self.config_number,
               "riskStrategy": confParam("riskStrategy"),
               "riskStrategyName": confParam("riskStrategyName"),
               }

        #  用例中值替换为变量
        data = eval(findAndReplace(str(caseData), ids))

        # 发送请求
        response = requests.post(self.url, headers=self.headers, data=json.dumps(data))

        # 接口返回信息
        text = response.text

        self.log.info("#" * 100 + "开始测试" + "#" * 100)
        self.log.info("用例名字:{}".format(caseName))
        self.log.info("请求参数:{}".format(data))
        self.log.info("-" * 200)
        self.log.info("期望结果:{}, 实际结果:{}".format(check, text))
        self.log.info("#" * 100 + "测试结束" + "#" * 100)

        # 断言
        self.assertIn(check, text)
Exemple #2
0
    def test_创建项目配置(self, cases):

        for caseName, caseInfo in cases.items():
            caseName = caseName
            caseData = caseInfo["data"]
            check = caseInfo["assert"]
            self.__dict__['_testMethodDoc'] = caseName

        config_dict = {"projectName": confParam("projectName")}

        #  用例中值替换为变量
        data = eval(findAndReplace(str(caseData), config_dict))

        # 发送请求
        response = requests.post(self.url, headers=self.headers, data=json.dumps(data))
        text = response.text  # 接口返回信息

        self.log.info("#" * 100 + "开始测试" + "#" * 100)
        self.log.info("用例名字:{}".format(caseName))
        self.log.info("请求参数:{}".format(data))
        self.log.info("-" * 200)
        self.log.info("期望结果:{}, 实际结果:{}".format(check, text))
        self.log.info("#" * 100 + "测试结束" + "#" * 100)

        # 断言
        self.assertIn(check, text)
Exemple #3
0
    def test_修改车型(self, cases):

        for caseName, caseInfo in cases.items():
            caseName = caseName
            data = caseInfo["data"]
            check = caseInfo["check"]
            self.__dict__['_testMethodDoc'] = caseName

        ids = {"carModelId": self.car_model_id}

        #  用例中值替换为变量
        data = eval(findAndReplace(str(data), ids))

        # 发送请求
        response = self.client.sendRequest(self.method, self.url, self.headers, data)

        # 接口返回文本信息
        text = response.text

        # 把文本信息转化为字典格式
        text_dict = json.loads(text)

        # 写日志
        writeLog(caseName, self.url, data, check, text_dict)

        # 断言
        Check().check(check, text_dict)