示例#1
0
    def test01_Taskscomplete(self):

        #依賴其他接口
        xls_reponses = commons.Deposit_xls_relyon("caseforparame.xlsx",
                                                  "Taskscomplete", "Addrepair",
                                                  self.case_name)
        xls_reponse = json.loads(xls_reponses)
        # set url
        self.url = commons.get_url_from_xml('Taskscomplete')
        self.url_new = self.url.split("/")
        self.id_change = commons.get_parameter_from_xls(
            xls_reponse, 'id', None)
        self.url_last = "/" + self.url_new[1] + "/" + str(
            self.id_change) + "/" + self.url_new[2]
        configHttp.set_url(self.url_last)
        print("第一步:设置url  " + self.url_last)

        # get visitor token
        # if self.token == '0':
        #     token = localReadConfig.get_headers("token_v")
        # elif self.token == '1':
        #     token = None

        #set headers
        Content_Type = localReadConfig.get_headers('Content-Type')
        no_cache = localReadConfig.get_headers('Cache-Control')
        header = {
            "Content-Type": Content_Type,
            'Authorization': Authorization_id,
            'Cache-Control': no_cache
        }
        print('header%s ' % header)
        configHttp.set_headers(header)
        print("第二步:设置header等")

        # set params
        data = {
            "attachmentIds": [self.attachmentIds],
            "costPrice": self.costPrice,
            "remarks": self.remarks
        }
        DATE = json.dumps(data)
        print('DATE%s' % DATE)

        configHttp.set_data(DATE)
        print("第三步:设置发送请求的参数")
        self.logger.info("********creater********")

        try:
            self.return_json = configHttp.post()
        except Exception as e:
            print('e %s' % e)
        method = str(self.return_json.request
                     )[int(str(self.return_json.request).find('[')) +
                       1:int(str(self.return_json.request).find(']'))]
        print("第四步:发送请求\n\t\t请求方法:" + method)

        print("第五步:检查结果")
        self.checkResult()
        return self.return_json
    def test01_PostmaintenanceTasksre(self):

        #依賴其他接口參數
        xls_reponses = commons.Deposit_xls_relyon("caseforparame.xlsx",
                                                  "PostmaintenanceTasksre",
                                                  "Repairreapply",
                                                  self.case_name)
        xls_reponse = json.loads(xls_reponses)

        # set url
        print('case ###############################################%s' %
              self.case_name)
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('PostmaintenanceTasksre')
        self.id_change = commons.get_parameter_from_xls(
            xls_reponse, 'id', None)
        self.url_new = self.url + "/" + str(self.id_change)
        configHttp.set_url(self.url_new)
        print("第一步:设置url  " + self.url_new)

        # get visitor token
        # if self.token == '0':
        #     token = localReadConfig.get_headers("token_v")
        # elif self.token == '1':
        #     token = None

        #set headers
        Content_Type = localReadConfig.get_headers('Content-Type')
        no_cache = localReadConfig.get_headers('Cache-Control')
        header = {
            "Content-Type": Content_Type,
            'Authorization': Authorization_id,
            'Cache-Control': no_cache
        }
        print('header%s ' % header)
        configHttp.set_headers(header)
        print("第二步:设置header等")

        # set params
        data = {"operation": self.operation, "remarks": self.remarks}
        DATE = json.dumps(data)
        print('DATE%s' % DATE)

        configHttp.set_data(DATE)
        print("第三步:设置发送请求的参数")
        self.logger.info("********creater********")

        # test interface
        try:
            self.return_json = configHttp.post()
        except Exception as e:
            print('e %s' % e)
        method = str(self.return_json.request
                     )[int(str(self.return_json.request).find('[')) +
                       1:int(str(self.return_json.request).find(']'))]
        print("第四步:发送请求\n\t\t请求方法:" + method)

        print("第五步:检查结果")
        self.checkResult()
        return self.return_json
    def test01_Repairsdetails(self):

        # 依賴其他接口
        # get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "Addrepair")
        # try:
        #     xls_01 = get_xls_Addrepair[0]
        #     xls_02 = get_xls_Addrepair[1]
        # except:
        #     print("超出列表值")
        # xls_reponses_Addrepairs = get_xls_Addrepair[0][-1]
        # xls_reponses_Addrepair = json.loads(xls_reponses_Addrepairs)

        xls_reponses = commons.Deposit_xls_relyon("caseforparame.xlsx",
                                                  "Repairsdetails",
                                                  "Addrepair", self.case_name)
        xls_reponse = json.loads(xls_reponses)

        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Repairsdetails')
        self.id_change = commons.get_parameter_from_xls(
            xls_reponse, 'id', None)
        self.url_last = self.url + "/" + str(self.id_change)
        configHttp.set_url(self.url_last)
        print("第一步:设置url  " + self.url_last)

        #set headers
        Content_Type = localReadConfig.get_headers('Content-Type')
        no_cache = localReadConfig.get_headers('Cache-Control')
        header = {
            "Content-Type": Content_Type,
            'Authorization': Authorization_id,
            'Cache-Control': no_cache
        }
        print('header%s ' % header)
        configHttp.set_headers(header)
        print("第二步:设置header等")

        #set params
        # data = {
        #     "attachmentId": self.attachmentId,
        #     "cnName":self.cnName,
        #     "employeeId":self.employeeId,
        #     "enName":self.enName,
        #     "isReleased":self.isReleased,
        #     "tel":self.tel
        # }
        #
        # DATE = json.dumps(data)
        # print('DATE%s' % DATE)
        # configHttp.set_data(DATE)

        print("第三步:设置发送请求的参数")
        self.logger.info("********creater********")

        # test interface
        try:
            self.return_json = configHttp.get()
        except Exception as e:
            print('e %s' % e)
        method = str(self.return_json.request
                     )[int(str(self.return_json.request).find('[')) +
                       1:int(str(self.return_json.request).find(']'))]
        print("第四步:发送请求\n\t\t请求方法:" + method)

        print("第五步:检查结果")
        self.checkResult()
        return self.return_json
示例#4
0
    def test01_Approvalre(self):

        #依賴其他接口參數

        # get_xls = commons.get_xls("caseforparame.xlsx", "Addrepair")
        # try:
        #     xls_01 = get_xls[0]
        #     xls_02 = get_xls[1]
        # except:
        #     print("超出列表值")
        # xls_reponses = get_xls[0][-1]
        # xls_reponse = json.loads(xls_reponses)

        xls_reponses = commons.Deposit_xls_relyon("caseforparame.xlsx",
                                                  "Approvalre",
                                                  "Repairreapply",
                                                  self.case_name)
        xls_reponse = json.loads(xls_reponses)

        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Approvalre')
        p = "http://wmrepair.doocom.net:8080/approvals/791?operation=AUDIT_ADOPT&remarks=24"

        # xls_reponse = json.loads(self.relyon_response)

        self.id_change = commons.get_parameter_from_xls(
            xls_reponse, "id", None)

        self.url_new = self.url + "/" + str(
            self.id_change
        ) + "?" + "operation=" + self.operation + "&" + "remarks=" + self.remarks

        print(self.url_new)
        configHttp.set_url(self.url_new)
        print("第一步:设置url  " + self.url_new)

        # get visitor token
        # if self.token == '0':
        #     token = localReadConfig.get_headers("token_v")
        # elif self.token == '1':
        #     token = None

        #set headers
        Content_Type = localReadConfig.get_headers('Content-Type')
        no_cache = localReadConfig.get_headers('Cache-Control')
        header = {
            "Content-Type": "text/plain",
            'Authorization': Authorization_id,
            'Cache-Control': no_cache
        }
        print('header%s ' % header)
        configHttp.set_headers(header)
        print("第二步:设置header等")

        # set params
        # data = {
        #     "operation": self.operation,
        #     "remarks": self.remarks
        # }
        # DATE = json.dumps(data)
        # print('DATE%s' % DATE)

        # configHttp.set_data(DATE)
        print("第三步:设置发送请求的参数")
        self.logger.info("********creater********")

        # test interface
        try:
            self.return_json = configHttp.post()
        except Exception as e:
            print('e %s' % e)
        method = str(self.return_json.request
                     )[int(str(self.return_json.request).find('[')) +
                       1:int(str(self.return_json.request).find(']'))]
        print("第四步:发送请求\n\t\t请求方法:" + method)

        print("第五步:检查结果")
        self.checkResult()
        return self.return_json