Esempio n. 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_Maintenancedetail(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)

        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Maintenancedetail')
        self.id_change = commons.get_parameter_from_xls(xls_reponses_Addrepair, '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
Esempio n. 4
0
    def test01_Repairurge(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)


        # set url
        self.url = commons.get_url_from_xml('Repairurge')
        self.url_new = self.url.split("/")
        self.id_change = commons.get_parameter_from_xls(xls_reponses_Addrepair,'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 = {
        #     "isRepair ":self.isRepair
        # }
        # DATE = json.dumps(data)
        # print('DATE%s' % DATE)
        #
        # configHttp.set_params(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_Repairsmanagement(self):
        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Repairsmanagement')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # 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 = {
            "endDate": self.endDate,
            "keywords": self.keywords,
            "keywordsType": self.keywordsType,
            "lang ": self.lang,
            "maxPageItems": self.maxPageItems,
            "offsetStart": self.offsetStart,
            "startDate": self.startDate
        }
        DATE = json.dumps(data)
        print('DATE%s' % DATE)

        configHttp.set_params(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
Esempio n. 6
0
    def test01_Addoutsiders(self):
        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Addousider')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # 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 = {
            "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.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_GroupsgetStudent(self):

        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('GroupsgetStudent')
        self.url_last = self.url
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        #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
Esempio n. 8
0
    def test01_Itemslist(self):
        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Itemslist')
        self.url_new = self.url + "?" + "lang=" + self.lang
        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
        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
Esempio n. 9
0
    def test01_Upload(self):
        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Upload')
        configHttp.set_url(self.url)
        print("第一步:设置url  "+self.url)

        # 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 = {'Authorization':Authorization_id,'Cache-Control':no_cache}
        print('header%s ' % header )
        configHttp.set_headers(header)
        print("第二步:设置header等")

        # set params


        file_path = 'C:/Users/admin/Pictures/Saved Pictures/' + self.fileData

        files = {'relateType': (None, self.relateType), 'fileData': (self.fileData, open(file_path, 'rb'))}

        configHttp.set_files(files)

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

        # test interface
        try:
            self.return_json = configHttp.postWithFile()
        except Exception as e:
            print(e)

        self.checkResult()
Esempio n. 10
0
    def test01_AddGroups(self):

        #依賴其他接口參數
        # Addproject_xls = commons.get_xls("caseforparame.xlsx", "Addproject")
        # xls_01 = Addproject_xls[0]
        # xls_02 = Addproject_xls[1]
        # xls_reponses = Addproject_xls[0][-1]
        # 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('AddGroups')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # 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等")

        #從上一個接口獲取項目id,名稱
        # self.itemCnName = commons.get_parameter_from_xls(xls_reponse,"cnName",None)
        # self.itemEnName = commons.get_parameter_from_xls(xls_reponse,"enName",None)
        # self.itemId = commons.get_parameter_from_xls(xls_reponse,"id",None)
        # set params
        data = {
            "areaId":
            self.areaId,
            "cnName":
            self.cnName,
            "enName":
            self.enName,
            "groupHasBuildingOptionList": [{
                "landCnName": self.landCnName,
                "landEnName": self.landEnName,
                "landId": self.landId
            }],
            "groupHasItemOptionList": [{
                "itemId": self.itemId
            }],
            "groupHasUserOptionList": [{
                "isOutsider": self.isOutsider,
                "key": self.key,
                "thumb": self.thumb,
                "userCnName": self.userCnName,
                "userEnName": self.userEnName,
                "userId": self.userId
            }],
            "isReleased":
            self.isReleased,
            "studentGroupHasDepartmentList": [{
                "departmentCnName":
                self.sdepartmentCnName,
                "departmentEnName":
                self.sdepartmentEnName,
                "departmentId":
                self.sdepartmentId
            }],
            "teacherGroupHasDepartmentList": [{
                "departmentCnName": self.departmentCnName,
                "departmentEnName": self.departmentEnName,
                "departmentId": self.departmentId
            }],
            "type":
            self.types
        }
        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
Esempio n. 11
0
    def test01_Repairreapply(self):

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

        # set url
        # pa = json.loads(self.relyon_response)

        self.url = commons.get_url_from_xml('Repairreapply')
        self.url_new = self.url.split("/")
        self.id_change = commons.get_parameter_from_xls(
            xls_reponses_Addrepair, '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 = {
            "addr": self.addr,
            "attachmentIds": [self.attachmentIds],
            "id": self.id_change,
            "itemCnName": self.itemCnName,
            "itemEnName": self.itemEnName,
            "itemId": self.itemId,
            "landCnName": self.landCnName,
            "landEnName": self.landEnName,
            "landId": self.landId,
            "remark": self.remark,
            "roomCnName": self.roomCnName,
            "roomEnName": self.roomEnName,
            "roomId": self.roomId,
            "roomTypeKey": self.roomTypeKey,
            "tel": self.tel
        }
        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
Esempio n. 12
0
    def test01_listRepairUsers(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)

        localReadConfig = readConfig.ReadConfig()
        configHttp = ConfigHttp.ConfigHttp()
        info = {}
        Authorization_id = commons.get_Authorization()


        # set url
        self.repairId = commons.get_parameter_from_xls(xls_reponse, "id", None)
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('listRepairUsers')
        #+"keywords="+self.keywords+ "&"+"maxPageItems="+self.maxPageItems+"&"

        self.url_new = self.url+"?"+"repairId="+str(self.repairId)
        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 = {'Authorization':Authorization_id,'Cache-Control':no_cache}
        print('header%s ' % header )
        configHttp.set_headers(header)
        print("第二步:设置header等")



        # set params
        # data = {
        #     "keywords":self.keywords,
        #     "maxPageItems": self.maxPageItems,
        #     "offsetStart": self.offsetStart,
        #     "repairId ":self.repairId
        # }
        # DATE = json.dumps(data)
        # print('DATE%s' % DATE)
        # configHttp.set_params(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
Esempio n. 13
0
    def test01_Groupslist(self):
        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Groupslist')
        if self.offsetStart == '' and self.keywords == '' and self.maxPageItems == '':
            self.url_new = self.url + "?" + "type=" + self.type_change
        elif self.offsetStart == '' and self.keywords != '' and self.maxPageItems != '':
            self.url_new = self.url + "?" + "&" + "keywords=" + self.keywords + "&" + "maxPageItems=" + self.maxPageItems + "&" + "type=" + self.type_change
        elif self.offsetStart == '' and self.keywords == '' and self.maxPageItems != '':
            self.url_new = self.url + "?" + "maxPageItems=" + self.maxPageItems + "&" + "type=" + self.type_change
        elif self.offsetStart != '' and self.keywords != '' and self.maxPageItems != '':
            self.url_new = self.url + "?" + "offsetStart=" + self.offsetStart + "&" + "keywords=" + self.keywords + "&" + "maxPageItems=" + self.maxPageItems + "&" + "type=" + self.type_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 = {
        #     "keywords": self.keywords,
        #     "maxPageItems": self.maxPageItems,
        #     "offsetStart": self.offsetStart,
        #     "type": self.type_change
        # }
        # DATE = json.dumps(data)
        # print('DATE%s' % DATE)
        #
        # configHttp.set_params(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
Esempio n. 14
0
    def test01_Addrepair(self):

        #依賴其他接口參數
        # Addproject_xls = commons.get_xls("caseforparame.xlsx", "Addproject")
        # xls_01 = Addproject_xls[0]
        # xls_02 = Addproject_xls[1]
        # xls_reponses = Addproject_xls[0][-1]
        # xls_reponse = json.loads(xls_reponses)
        self.xls_response = commons.get_parameter_one("Addproject",1,-1)
        self.itemEnName = commons.get_parameter_from_xls(self.xls_response,"cnName",None)
        self.itemCnName = commons.get_parameter_from_xls(self.xls_response, "enName", None)
        self.itemId = commons.get_parameter_from_xls(self.xls_response, "id", None)

        # set url
        print('case ###############################################%s' % self.case_name)
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Addrepair')
        configHttp.set_url(self.url)
        print("第一步:设置url  "+self.url)

        # 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等")

        #從上一個接口獲取項目id,名稱
        # self.itemCnName = commons.get_parameter_from_xls(xls_reponse,"cnName",None)
        # self.itemEnName = commons.get_parameter_from_xls(xls_reponse,"enName",None)
        # self.itemId = commons.get_parameter_from_xls(xls_reponse,"id",None)

        # set params
        data = {
            "addr": self.addr,
            "attachmentIds": [self.attachmentIds],
            "id": self.id_change,
            "itemCnName": self.itemCnName,
            "itemEnName": self.itemEnName,
            "itemId": self.itemId,
            "landCnName": self.landCnName,
            "landEnName": self.landEnName,
            "landId": self.landId,
            "remark": self.remark,
            "roomCnName": self.roomCnName,
            "roomEnName": self.roomEnName,
            "roomId": self.roomId,
            "roomTypeKey": self.roomTypeKey,
            "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.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
Esempio n. 15
0
    def test01_Itemsupdate(self):

        get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "Addproject")
        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)


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

        #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 = {
            "cnName":self.cnName,
            "enName": self.enName ,
            "isApplyToStudent":self.isApplyToStudent ,
            "isApplyToTeacher": self.isApplyToTeacher,
            "isNeedAuditStudent": self.isNeedAuditStudent,
            "isNeedAuditTeacher": self.isNeedAuditTeacher,
            "isReleased": self.isReleased,
            "roomTypeList": [
                {
                    "roomTypeCnName": self.roomTypeCnName,
                    "roomTypeEnName": self.roomTypeEnName,
                    "roomTypeId": self.roomTypeId,
                    "roomTypeKey": self.roomTypeKey
                }
            ],
            "sn": self.sn
        }
        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
Esempio n. 16
0
    def test01_Addproject(self):
        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Addproject')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        #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 = {
            "cnName":
            self.cnName,
            "enName":
            self.enName,
            "isApplyToStudent":
            self.isApplyToStudent,
            "isApplyToTeacher":
            self.isApplyToTeacher,
            "isNeedAuditStudent":
            self.isNeedAuditStudent,
            "isNeedAuditTeacher":
            self.isNeedAuditTeacher,
            "isReleased":
            self.isReleased,
            "roomTypeList": [{
                "roomTypeCnName": self.roomTypeCnName,
                "roomTypeEnName": self.roomTypeEnName,
                "roomTypeId": self.roomTypeId,
                "roomTypeKey": self.roomTypeKey
            }],
            "sn":
            self.sn
        }
        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
Esempio n. 17
0
    def test01_Deleteproject(self):

        #依賴其他接口參數
        Addproject_xls = commons.get_xls("caseforparame.xlsx", "Addproject")
        xls_01 = Addproject_xls[0]
        xls_reponses_01 = Addproject_xls[0][-1]
        xls_res_01 = json.loads(xls_reponses_01)

        # set url
        print('case ###############################################%s' %
              self.case_name)
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Deleteproject')
        self.url_new = self.url.split("/")
        self.id_change = commons.get_parameter_from_xls(xls_res_01, '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
Esempio n. 18
0
    def test01_Approvalsdetails(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)

        # set url
        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Approvalsdetails')

        self.id_change = commons.get_parameter_from_xls(
            xls_reponse, "id", None)
        self.url_new = self.url + "/" + str(self.id_change)

        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.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