Exemplo n.º 1
0
    def checkResult(self):
        # show return message

        self.info = commons.show_return_msg(self.return_json)
        #     # if self.result == '0':
        self.infos = json.loads(self.info)
        result_status = commons.get_parameter_from_xls(self.infos, "success",
                                                       None)
        #     email = commons.get_value_from_return_json(self.info, 'member', 'email')
        print(result_status)
        self.assertEqual(result_status, self.result)
        #     print('第六步,記錄響應結果')
        commons.Deposit_xls('caseforparame.xlsx', 'Repairshistory', self.info,
                            self.case_name)
Exemplo n.º 2
0
    def checkResult(self):
        """
        check test result
        :return:
        """

        self.info = commons.show_return_msg(self.return_json)
        #     # if self.result == '0':
        self.infos = json.loads(self.info)
        result_status = commons.get_parameter_from_xls(self.infos, "success", None)
        #     email = commons.get_value_from_return_json(self.info, 'member', 'email')
        print(result_status)
        self.assertEqual(result_status, self.result)
        #     print('第六步,記錄響應結果')
        commons.Deposit_xls('caseforparame.xlsx', 'DispatchingTags', self.info, self.case_name)
Exemplo n.º 3
0
    def test01_Itemsdetails(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('Itemsdetails')
        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
Exemplo n.º 4
0
    def test01_Dispatchingre(self):

        #依賴其他接口參數
        xls_reponses = commons.Deposit_xls_relyon("caseforparame.xlsx",
                                                  "Dispatchingre",
                                                  "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('Dispatchingre')
        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 = {
            "day": self.day,
            "operation": self.operation,
            "receiverCnName": self.receiverCnName,
            "receiverEnName": self.receiverEnName,
            "receiverId": self.receiverId,
            "receiverIsoutsider": self.receiverIsoutsider,
            "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
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
0
    def test01_Repaircomplete(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('Repaircomplete')
        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 = {
            "option ": {
                "serviceEvaluation": self.serviceEvaluation,
                "serviceScore": self.serviceScore
            }
        }
        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
Exemplo n.º 8
0
    def test01_Groupsedit(self):

        #依賴其他接口參數
        Addproject_xls = commons.get_xls("caseforparame.xlsx", "AddGroups")
        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('Groupsedit')
        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)
        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": "",
                "departmentEnName": "",
                "departmentId": ""
            }],
            "teacherGroupHasDepartmentList": [{
                "departmentCnName": "",
                "departmentEnName": "",
                "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
Exemplo n.º 9
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
Exemplo n.º 10
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
Exemplo n.º 11
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
Exemplo n.º 12
0
    def test01_Groupsgetdelete(self):
        # set url

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

        self._testMethodDoc = self.case_name
        self.url = commons.get_url_from_xml('Groupsgetdelete')
        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