示例#1
0
    def test_ProductModify01(self):
        """简单验证修改产品接口容错"""
        datas = ExcelReader(self.excel, sheet='ModifyProduct').data
        for d in range(0, len(datas)):
            if datas[d]['is_execute'] == 'N':
                continue
            else:
                with self.subTest(data=datas[d]['CaseNo'] +
                                  datas[d]['describe']):
                    self.setUp()
                    # logger.debug(datas[d])
                    expect = datas[d]['expect_code']
                    casename = str(datas[d]['describe'])
                    caseNo = str(datas[d]['CaseNo'])
                    #请求的参数剔除期望值列、是否执行列、描述列、用例编号列
                    datas[d].pop('expect_code')
                    datas[d].pop('is_execute')
                    datas[d].pop('describe')
                    datas[d].pop('CaseNo')
                    if datas[d]['productId'] == '{pid1-0}':
                        datas[d]['productId'] = OpenPlatformCommon.getpid(
                            self.mid, category=1, platform=0)
                    elif datas[d]['productId'] == '{pid1-1}':
                        datas[d]['productId'] = OpenPlatformCommon.getpid(
                            self.mid, category=1, platform=1)
                    elif datas[d]['productId'] == '{pid2}':
                        datas[d]['productId'] = OpenPlatformCommon.getpid(
                            self.mid, category=2)
                    elif datas[d]['productId'] == '{pid3}':
                        datas[d]['productId'] = OpenPlatformCommon.getpid(
                            self.mid, category=3)

                    datas[d]['settings'] = ast.literal_eval(
                        datas[d]['settings'])
                    # logger.debug(type(datas[d]['setting']))
                    # logger.debug(datas[d]['setting'])
                    #转换为json格式
                    # json.dumps(datas[d]['settings'])
                    params = json.dumps(datas[d])
                    # logger.debug(type(params))

                    headers = {'Content-Type': "application/json"}
                    res = self.client.send(data=params, headers=headers)
                    # resultlist =[caseNo,casename,params,expect,res.text]
                    # resultdata.qppend(resultlist)
                    # logger.debug(res.text)
                    result = JMESPathExtractor().extract(query='success',
                                                         body=res.text)
                    message = JMESPathExtractor().extract(query='message',
                                                          body=res.text)
                    msg = '\n请求地址:' + res.url + '\n请求数据:' + params + '\n返回结果:' + res.text
                    self.assertEqual(expect, str(result).lower(), msg=msg)
                    self.assertNotIn('未知错误', str(message), msg=msg)
                    self.tearDown()
示例#2
0
 def test_ProductModify03(self):
     """验证修改产品成功时返回信息是否正确"""
     pid = OpenPlatformCommon.getpid(self.mid, category=3)
     datas = {
         "productId": pid,
         "name": "AutoTest修改测试",
         "iconUrl": "",
         "department": "",
         "introduction": "",
         "state": 2,
         "settings": {
             "packageName": "AutoTest",
             "signature": "AutoTest",
             "smallProgramId": "AutoTestEdit",
             "smallPlatformType": 0
         }
     }
     headers = {'Content-Type': "application/json"}
     res = self.client.send(data=json.dumps(datas), headers=headers)
     result = JMESPathExtractor().extract(query='success', body=res.text)
     message = JMESPathExtractor().extract(query='message', body=res.text)
     date = time.strftime('%Y-%m-%d', time.localtime(time.time()))
     responseTime = JMESPathExtractor().extract(query='responseTime',
                                                body=res.text)
     msg = '\n请求地址:' + res.url + '\n请求数据:' + json.dumps(
         datas) + '\n返回结果:' + res.text
     self.assertEqual('true', str(result).lower(), msg=msg)
     self.assertNotIn('未知', str(message), msg=msg)
     self.assertIn(date, str(responseTime), msg=msg)
示例#3
0
    def test_ProductList02(self):
        """验证产品列表-产品名称搜索"""
        pid = OpenPlatformCommon.getpid(self.mid, category=2, platform=1)
        params = {
            'MerchantId': self.mid,
            'Condition': 'Autotest测试',
            'PageIndex': 1,
            'PageSize': 1
        }
        res = self.client.send(params=params)
        result = JMESPathExtractor().extract(query='success', body=res.text)
        message = JMESPathExtractor().extract(query='message', body=res.text)
        date = time.strftime('%Y-%m-%d', time.localtime(time.time()))
        responseTime = JMESPathExtractor().extract(query='responseTime',
                                                   body=res.text)
        res_pid = JMESPathExtractor().extract(query='data.data[0].productId',
                                              body=res.text)
        res_pname = JMESPathExtractor().extract(
            query='data.data[0].productName', body=res.text)
        res_iconurl = JMESPathExtractor().extract(query='data.data[0].iconUrl',
                                                  body=res.text)
        res_pnum = JMESPathExtractor().extract(query='data.data[0].productNum',
                                               body=res.text)
        res_pcategory = JMESPathExtractor().extract(
            query='data.data[0].productCategory', body=res.text)
        res_psubcategory = JMESPathExtractor().extract(
            query='data.data[0].subCategory', body=res.text)
        res_pecology = JMESPathExtractor().extract(
            query='data.data[0].productEcology', body=res.text)
        res_pmname = JMESPathExtractor().extract(
            query='data.data[0].merchantName', body=res.text)
        res_department = JMESPathExtractor().extract(
            query='data.data[0].department', body=res.text)
        res_pstate = JMESPathExtractor().extract(query='data.data[0].state',
                                                 body=res.text)
        res_recordsTotal = JMESPathExtractor().extract(
            query='data.recordsTotal', body=res.text)
        msg = '\n请求地址:' + res.url + '\n返回结果:' + res.text

        self.assertEqual('true', str(result).lower(), msg=msg)
        self.assertIn(date, str(responseTime), msg=msg)
        self.assertEqual(pid, res_pid, msg=msg)
        self.assertEqual('Autotest测试', res_pname, msg=msg)
        self.assertIn('key=Autotest', str(res_iconurl), msg=msg)
        self.assertEqual(2, res_pcategory, msg=msg)
        self.assertEqual('单网页形态', res_psubcategory, msg=msg)
        self.assertEqual(0, res_pecology, msg=msg)
        self.assertEqual('中顺网络公司', res_pmname, msg=msg)
        self.assertEqual('Web研发部门', res_department, msg=msg)
        self.assertEqual(1, res_pstate, msg=msg)
        self.assertEqual(1, res_recordsTotal, msg=msg)
示例#4
0
    def test_ProductGet01(self):
        """简单验证获取产品信息接口容错"""
        datas = ExcelReader(self.excel, sheet='ProductDetail').data
        for d in range(0, len(datas)):
            if datas[d]['is_execute'] == 'N':
                continue
            else:
                with self.subTest(data=datas[d]['CaseNo'] +
                                  datas[d]['describe']):
                    self.setUp()
                    # logger.debug(datas[d])
                    expect = datas[d]['expect_code']
                    casename = str(datas[d]['describe'])
                    caseNo = str(datas[d]['CaseNo'])
                    #请求的参数剔除期望值列、是否执行列、描述列、用例编号列
                    datas[d].pop('expect_code')
                    datas[d].pop('is_execute')
                    datas[d].pop('describe')
                    datas[d].pop('CaseNo')
                    if datas[d]['ProductId'] == '{pid}':
                        datas[d]['ProductId'] = OpenPlatformCommon.getpid(
                            self.mid)

                    #转换为json格式
                    # json.dumps(datas[d]['settings'])
                    params = datas[d]
                    # logger.debug(type(params))

                    res = self.client.send(params=params)
                    # resultlist =[caseNo,casename,params,expect,res.text]
                    # resultdata.qppend(resultlist)
                    # logger.debug(res.text)
                    result = JMESPathExtractor().extract(query='success',
                                                         body=res.text)
                    message = JMESPathExtractor().extract(query='message',
                                                          body=res.text)
                    msg = '\n请求地址:' + res.url + '\n返回结果:' + res.text
                    self.assertEqual(expect, str(result).lower(), msg=msg)
                    self.assertNotIn('未知错误', str(message), msg=msg)
                    self.tearDown()
示例#5
0
    def test_ProductChannelList01(self):
        """简单验证添加产品渠道接口容错"""
        datas = ExcelReader(self.excel, sheet='ProductChannelList').data
        for d in range(0, len(datas)):
            if datas[d]['is_execute'] == 'N':
                continue
            else:
                with self.subTest(data=datas[d]['CaseNo'] +
                                  datas[d]['describe']):
                    self.setUp()
                    # logger.debug(datas[d])
                    expect = datas[d]['expect_code']
                    casename = str(datas[d]['describe'])
                    caseNo = str(datas[d]['CaseNo'])
                    #请求的参数剔除期望值列、是否执行列、描述列、用例编号列
                    datas[d].pop('expect_code')
                    datas[d].pop('is_execute')
                    datas[d].pop('describe')
                    datas[d].pop('CaseNo')
                    if datas[d]['ProductId'] == '{pid}':
                        datas[d]['ProductId'] = OpenPlatformCommon.getpid(
                            self.mid)
                    # #转换为json格式
                    # params = json.dumps(datas[d])
                    params = datas[d]
                    # headers={'Content-Type': "application/json"}
                    res = self.client.send(params=params)

                    result = JMESPathExtractor().extract(query='success',
                                                         body=res.text)
                    message = JMESPathExtractor().extract(query='message',
                                                          body=res.text)
                    msg = '\n请求地址:' + res.url + '\n返回结果:' + res.text
                    self.assertEqual(expect, str(result).lower(), msg=msg)
                    self.assertNotIn('未知错误', str(message), msg=msg)
                    self.tearDown()
示例#6
0
    def test_ProductGet02(self):
        """验证新增产品成功后获取产品信息是否正确"""
        pid = OpenPlatformCommon.getpid(self.mid)
        params = {"ProductId": pid}
        res = self.client.send(params=params)
        msg = '\n请求地址:' + res.url + '\n请求数据:' + str(pid) + '\n返回结果:' + res.text
        #获取返回信息
        result = JMESPathExtractor().extract(query='success', body=res.text)
        message = JMESPathExtractor().extract(query='message', body=res.text)
        date = time.strftime('%Y-%m-%d', time.localtime(time.time()))
        responseTime = JMESPathExtractor().extract(query='responseTime',
                                                   body=res.text)
        res_pid = JMESPathExtractor().extract(query='data.productId',
                                              body=res.text)
        res_pname = JMESPathExtractor().extract(query='data.productName',
                                                body=res.text)
        res_iconurl = JMESPathExtractor().extract(query='data.iconUrl',
                                                  body=res.text)
        res_pnum = JMESPathExtractor().extract(query='data.productNum',
                                               body=res.text)
        res_pcategory = JMESPathExtractor().extract(
            query='data.productCategory', body=res.text)
        res_pecology = JMESPathExtractor().extract(query='data.productEcology',
                                                   body=res.text)
        res_pmname = JMESPathExtractor().extract(query='data.merchantName',
                                                 body=res.text)
        res_department = JMESPathExtractor().extract(query='data.department',
                                                     body=res.text)
        res_psecret = JMESPathExtractor().extract(query='data.productSecret',
                                                  body=res.text)
        res_pintroduction = JMESPathExtractor().extract(
            query='data.introduction', body=res.text)
        res_pstate = JMESPathExtractor().extract(query='data.state',
                                                 body=res.text)
        res_psettings_platform = JMESPathExtractor().extract(
            query='data.settings.platform', body=res.text)
        res_psettings_packagename = JMESPathExtractor().extract(
            query='data.settings.packageName', body=res.text)
        res_psettings_signature = JMESPathExtractor().extract(
            query='data.settings.signature', body=res.text)
        res_psettings_bundleID = JMESPathExtractor().extract(
            query='data.settings.bundleID', body=res.text)
        res_psettings_appID = JMESPathExtractor().extract(
            query='data.settings.appId', body=res.text)
        res_psettings_h5type = JMESPathExtractor().extract(
            query='data.settings.h5Type', body=res.text)
        res_psettings_h5platformname = JMESPathExtractor().extract(
            query='data.settings.h5PlatformName', body=res.text)
        res_psettings_h5address = JMESPathExtractor().extract(
            query='data.settings.h5Address', body=res.text)
        res_psettings_smallProgramId = JMESPathExtractor().extract(
            query='data.settings.smallProgramId', body=res.text)
        res_psettings_smallPlatformType = JMESPathExtractor().extract(
            query='data.settings.smallPlatformType', body=res.text)

        self.assertEqual('true', str(result).lower(), msg=msg)
        self.assertIn(date, str(responseTime), msg=msg)
        self.assertEqual(pid, res_pid, msg=msg)
        self.assertEqual('Autotest测试', res_pname, msg=msg)
        self.assertIn('key=Autotest', str(res_iconurl), msg=msg)
        self.assertEqual(1, res_pcategory, msg=msg)
        self.assertEqual(0, res_pecology, msg=msg)
        self.assertEqual('中顺网络公司', res_pmname, msg=msg)
        self.assertEqual('Web研发部门', res_department, msg=msg)
        self.assertEqual('Autotest自动化自动创建产品', res_pintroduction, msg=msg)
        self.assertEqual(1, res_pstate, msg=msg)
        self.assertEqual(0, res_psettings_platform, msg=msg)
        self.assertEqual('Autotest', res_psettings_packagename, msg=msg)
        self.assertEqual('Autotest', res_psettings_signature, msg=msg)
        self.assertEqual('Autotest.bundleID', res_psettings_bundleID, msg=msg)
        self.assertEqual('Autotest.appId', res_psettings_appID, msg=msg)
        self.assertEqual(0, res_psettings_h5type, msg=msg)
        self.assertEqual('AutotestH5', res_psettings_h5platformname, msg=msg)
        self.assertEqual('Autotest.H5', res_psettings_h5address, msg=msg)
        self.assertEqual('AutotestsmallProgramId',
                         res_psettings_smallProgramId,
                         msg=msg)
        self.assertEqual(0, res_psettings_smallPlatformType, msg=msg)
示例#7
0
    def test_ProductGet03(self):
        """验证修改产品成功后获取产品信息是否正确"""
        pid = OpenPlatformCommon.getpid(self.mid)
        edit_datas = {
            "productId": pid,
            "name": "编辑产品名Autotest",
            "iconUrl": "iconUrl.modify",
            "department": "modify部门",
            "introduction": "modify介绍",
            "state": 2,
            "settings": {
                "packageName": "modify包名",
                "signature": "modifysignature",
                "bundleID": "modifybundleID",
                "appId": "modifyAPPID",
                "h5PlatformName": "modifyH5平台名",
                "h5Address": "modifyH5.Address",
                "smallProgramId": "modifysmallProgramId"
            }
        }
        edit_url = Config().get('OpenPlatform_API').get('Product').get(
            'Product')
        edit_headers = {'Content-Type': "application/json"}
        edit_client = HTTPClient(url=self.API_URL, method='PATCH')
        edit_client.send(data=json.dumps(edit_datas), headers=edit_headers)
        #查询编辑后的产品信息
        params = {"ProductId": pid}
        res = self.client.send(params=params)
        msg = '\n请求地址:' + res.url + '\n请求数据:' + str(pid) + '\n返回结果:' + res.text
        #获取返回信息
        result = JMESPathExtractor().extract(query='success', body=res.text)
        message = JMESPathExtractor().extract(query='message', body=res.text)
        date = time.strftime('%Y-%m-%d', time.localtime(time.time()))
        responseTime = JMESPathExtractor().extract(query='responseTime',
                                                   body=res.text)
        res_pid = JMESPathExtractor().extract(query='data.productId',
                                              body=res.text)
        res_pname = JMESPathExtractor().extract(query='data.productName',
                                                body=res.text)
        res_iconurl = JMESPathExtractor().extract(query='data.iconUrl',
                                                  body=res.text)
        res_pnum = JMESPathExtractor().extract(query='data.productNum',
                                               body=res.text)
        res_pcategory = JMESPathExtractor().extract(
            query='data.productCategory', body=res.text)
        res_pecology = JMESPathExtractor().extract(query='data.productEcology',
                                                   body=res.text)
        res_pmname = JMESPathExtractor().extract(query='data.merchantName',
                                                 body=res.text)
        res_department = JMESPathExtractor().extract(query='data.department',
                                                     body=res.text)
        res_psecret = JMESPathExtractor().extract(query='data.productSecret',
                                                  body=res.text)
        res_pintroduction = JMESPathExtractor().extract(
            query='data.introduction', body=res.text)
        res_pstate = JMESPathExtractor().extract(query='data.state',
                                                 body=res.text)
        res_psettings_platform = JMESPathExtractor().extract(
            query='data.settings.platform', body=res.text)
        res_psettings_packagename = JMESPathExtractor().extract(
            query='data.settings.packageName', body=res.text)
        res_psettings_signature = JMESPathExtractor().extract(
            query='data.settings.signature', body=res.text)
        res_psettings_bundleID = JMESPathExtractor().extract(
            query='data.settings.bundleID', body=res.text)
        res_psettings_appID = JMESPathExtractor().extract(
            query='data.settings.appId', body=res.text)
        res_psettings_h5type = JMESPathExtractor().extract(
            query='data.settings.h5Type', body=res.text)
        res_psettings_h5platformname = JMESPathExtractor().extract(
            query='data.settings.h5PlatformName', body=res.text)
        res_psettings_h5address = JMESPathExtractor().extract(
            query='data.settings.h5Address', body=res.text)
        res_psettings_smallProgramId = JMESPathExtractor().extract(
            query='data.settings.smallProgramId', body=res.text)
        res_psettings_smallPlatformType = JMESPathExtractor().extract(
            query='data.settings.smallPlatformType', body=res.text)

        self.assertEqual('true', str(result).lower(), msg=msg)
        self.assertIn(date, str(responseTime), msg=msg)
        self.assertEqual(pid, res_pid, msg=msg)
        self.assertEqual('编辑产品名Autotest', res_pname, msg=msg)
        self.assertIn('key=iconUrl.modify', str(res_iconurl), msg=msg)
        self.assertEqual(1, res_pcategory, msg=msg)
        self.assertEqual(0, res_pecology, msg=msg)
        self.assertEqual('中顺网络公司', res_pmname, msg=msg)
        self.assertEqual('modify部门', res_department, msg=msg)
        self.assertEqual('modify介绍', res_pintroduction, msg=msg)
        self.assertEqual(2, res_pstate, msg=msg)
        self.assertEqual(0, res_psettings_platform, msg=msg)
        self.assertEqual('modify包名', res_psettings_packagename, msg=msg)
        self.assertEqual('modifysignature', res_psettings_signature, msg=msg)
        self.assertEqual('modifybundleID', res_psettings_bundleID, msg=msg)
        self.assertEqual('modifyAPPID', res_psettings_appID, msg=msg)
        self.assertEqual(0, res_psettings_h5type, msg=msg)
        self.assertEqual('modifyH5平台名', res_psettings_h5platformname, msg=msg)
        self.assertEqual('modifyH5.Address', res_psettings_h5address, msg=msg)
        self.assertEqual('modifysmallProgramId',
                         res_psettings_smallProgramId,
                         msg=msg)
        self.assertEqual(0, res_psettings_smallPlatformType, msg=msg)