def testCase5(self, id=39):
     """删除地址"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'].replace("{0}", str(address_id2)),
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson1 = json.loads(apijson)
     actual_one = apijson1["isSuccess"]
     sleep(1)
     sql = operate_excel.get_palce(case_num=id)['sql'].format(address_id2)
     actual_two = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).Perform()
     try:
         self.assertEqual(int(expect_one['isSuccess']), actual_one, msg='预期和返回不一致')
         Log().info('对【isSuccess】断言,断言结果--预期值%s == 实际值%s' % (expect_one['isSuccess'], actual_one))
     except:
         Log().warning('对【isSuccess】断言,断言结果--预期值%s != 实际值%s' % (expect_one['isSuccess'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['COUNT(*)']), actual_two, msg='预期和返回不一致')
             Log().info('对【删除结果数】断言,断言结果--预期值%s == 实际值%s' % (expect_two['COUNT(*)'], actual_two))
         except:
             Log().warning('对【删除结果数】断言,断言结果--预期值%s != 实际值%s' % (expect_two['COUNT(*)'], actual_two))
             raise
 def testCase1(self, id=35):
     """新增地址"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["isSuccess"]
     global address_id1
     address_id1 = apijson2["data"]
     actual_two = address_id1
     sql = operate_excel.get_palce(case_num=id, case_name=MyTest.name)['sql']
     expect_two = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).Perform()
     try:
         self.assertEqual(int(expect_one['isSuccess']), actual_one, msg='预期和返回不一致')
         Log().info('对【isSuccess】断言,断言结果--预期值%s == 实际值%s' % (expect_one['isSuccess'], actual_one))
     except:
         Log().warning('对【isSuccess】断言,断言结果--预期值%s != 实际值%s' % (expect_one['isSuccess'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(expect_two, actual_two, msg='预期和返回不一致')
             Log().info('对【地址id】断言,断言结果--预期值%s == 实际值%s' % (expect_two, actual_two))
         except:
             Log().warning('对【地址id】断言,断言结果--预期值%s != 实际值%s' % (expect_two, actual_two))
             raise
Esempio n. 3
0
 def testCase12(self, id=34):
     """删除发布内容"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'].format(note_id), key=data_test['key'], param=data_test['param'].format(note_id),
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["msg"]
     sql = operate_excel.get_palce(case_num=id, case_name=MyTest.name)['sql'].format(note_id)
     actual_two = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).Perform()
     try:
         self.assertEqual(expect_one['msg'], actual_one, msg='预期和返回不一致')
         Log().info('删除成功,对【删除结果】断言,断言结果--预期值%s == 实际值%s' % (expect_one['msg'], actual_one))
     except:
         Log().warning('删除失败,对【删除结果】断言,断言结果--预期值%s != 实际值%s' % (expect_one['msg'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['COUNT(*)']), actual_two, msg='预期和返回不一致')
             Log().info('对【删除数】断言,断言结果--预期值%s == 实际值%s' % (expect_two['COUNT(*)'], actual_two))
         except:
             Log().warning('对【删除数】断言,断言结果--预期值%s != 实际值%s' % (expect_two['COUNT(*)'], actual_two))
             raise
Esempio n. 4
0
 def testCase02(self, id=24):
     """获取个人发布内容"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     sql = operate_excel.get_palce(case_num=id)['sql']
     expect_two = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).Perform()
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'], data_test['way']))
     apijson1 = json.loads(apijson)
     actual_one = apijson1["data"][0]["noteBaseInfo"]["content"]
     actual_two = apijson1["data"][0]["noteBaseInfo"]["noteId"]
     global note_id
     note_id = actual_two
     try:
         self.assertEqual(expect_one['content'], actual_one, msg='预期和返回不一致')
         Log().info('对【发布内容】断言,断言结果--预期值%s == 实际值%s' % (expect_one['content'], actual_one))
     except:
         Log().warning('对【发布内容】断言,断言结果--预期值%s != 实际值%s' % (expect_one['content'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(expect_two, actual_two, msg='预期和返回不一致')
             Log().info('对【发布内容id】断言,断言结果--预期值%s == 实际值%s' % (expect_two, actual_two))
         except:
             Log().warning('对【发布内容id】断言,断言结果--预期值%s != 实际值%s' % (expect_two, actual_two))
             raise
Esempio n. 5
0
 def testCase11(self, id=33):
     """发表评论"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'].replace("{0}", str(note_id)),
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     sql = operate_excel.get_palce(case_num=id, case_name=MyTest.name)['sql']
     actual_one = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).Perform()
     actual_two = apijson2["data"]
     try:
         self.assertEqual(expect_one['comment_text'], actual_one, msg='预期和返回不一致')
         Log().info('对【评论内容】断言,断言结果--预期值%s == 实际值%s' % (expect_one['comment_text'], actual_one))
     except:
         Log().warning('对【评论内容】断言,断言结果--预期值%s != 实际值%s' % (expect_one['comment_text'], actual_one))
         raise
     finally:
         try:
             self.assertIsNotNone(actual_two, msg='实际值不存在')
             Log().info('已发送【%s】条评论' % (actual_two))
         except:
             Log().warning('评论发送失败')
             raise
Esempio n. 6
0
 def testCase10(self, id=32):
     """取消关注"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["isSuccess"]
     actual_two = apijson2["data"]
     try:
         self.assertEqual(int(expect_one['isSuccess']), actual_one, msg='预期和返回不一致')
         Log().info('取消关注,对【isSuccess】断言,断言结果--预期值%s == 实际值%s' % (expect_one['isSuccess'], actual_one))
     except:
         Log().warning('取消关注,对【isSuccess】断言,断言结果--预期值%s != 实际值%s' % (expect_one['isSuccess'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['data']), actual_two, msg='预期和返回不一致')
             Log().info('对【已关注人数】断言,断言结果--预期值%s == 实际值%s' % (expect_two['data'], actual_two))
         except:
             Log().warning('对【已关注人数】断言,断言结果--预期值%s != 实际值%s' % (expect_two['data'], actual_two))
             raise
Esempio n. 7
0
 def testCase06(self, id=28):
     """查看已关注的用户信息"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["data"][0]["userName"]
     actual_two = apijson2["data"][0]["shopId"]
     try:
         self.assertEqual(expect_one['userName'], actual_one, msg='预期和返回不一致')
         Log().info('对【用户名】断言,断言结果--预期值%s == 实际值%s' % (expect_one['userName'], actual_one))
     except:
         Log().warning('对【用户名】断言,断言结果--预期值%s != 实际值%s' % (expect_one['userName'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['shopId']), actual_two, msg='预期和返回不一致')
             Log().info('对【店铺id】断言,断言结果--预期值%s == 实际值%s' % (expect_two['shopId'], actual_two))
         except:
             Log().warning('对【店铺id】断言,断言结果--预期值%s != 实际值%s' % (expect_two['shopId'], actual_two))
             raise
 def testCase2(self, id=36):
     """查看地址"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'], data_test['way']))
     apijson1 = json.loads(apijson)
     actual_one = apijson1["data"]["addresses"][-1]["id"]
     actual_two = apijson1["data"]["addresses"][-1]["isDefault"]
     try:
         self.assertEqual(int(address_id1), actual_one, msg='预期和返回不一致')
         Log().info('对【地址id】断言,断言结果--预期值%s == 实际值%s' % (address_id1, actual_one))
     except:
         Log().warning('对【地址id】断言,断言结果--预期值%s != 实际值%s' % (address_id1, actual_one))
         raise
     finally:
         try:
             self.assertEqual(expect_two['isDefault'], str(actual_two), msg='预期和返回不一致')
             Log().info('对【是否为默认地址】断言,断言结果--预期值%s == 实际值%s' % (expect_two['isDefault'], actual_two))
         except:
             Log().warning('对【是否为默认地址】断言,断言结果--预期值%s != 实际值%s' % (expect_two['isDefault'], actual_two))
             raise
Esempio n. 9
0
 def testCase6(self, id=9):
     """订单取消成功"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'].format(actual), key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["isSuccess"]
     sql = operate_excel.get_palce(case_num=id, case_name=MyTest.name)['sql'].format(actual)
     sleep(1)
     actual_two = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).Perform()
     try:
         self.assertEqual(int(expect_one['isSuccess']), actual_one, msg='预期和返回不一致')
         Log().info('对【订购结果】断言,断言结果--预期值%s == 实际值%s' % (expect_one['isSuccess'], actual_one))
     except:
         Log().warning('对【订购结果】断言,断言结果--预期值%s != 实际值%s' % (expect_one['isSuccess'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['tradestatus']), actual_two, msg='预期和返回不一致')
             Log().info('对【订单状态】断言,断言结果--支付成功预期值%s == 实际值%s' % (expect_two['tradestatus'], actual_two))
         except:
             Log().warning('对【订单状态】断言,断言结果--支付成功预期值%s != 实际值%s' % (expect_two['tradestatus'], actual_two))
             raise
Esempio n. 10
0
 def testCase10(self, id=16):
     """优惠劵抵扣订单金额确认"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'].format(actual_couponid),
                       key=data_test['key'],
                       param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                (data_test['url'], data_test['key'], data_test['param'],
                 data_test['way']))
     apijson1 = json.loads(apijson)
     actual_one = apijson1['data']['itemsTotalPrice']
     expect_totalPrice = float(
         expect_one['itemsTotalPrice']) - actual_couponworth
     actual_totalPrice = actual_one - actual_couponworth
     if expect_totalPrice == actual_totalPrice:
         Log().info('抵扣优惠卷金额正确:预期值%s == 实际值%s' %
                    (expect_totalPrice, actual_totalPrice))
     else:
         Log().warning('抵扣优惠卷金额不正确:预期值%s != 实际值%s' %
                       (expect_totalPrice, actual_totalPrice))
     try:
         self.assertEqual(int(expect_one['itemsTotalPrice']),
                          actual_one,
                          msg='预期和返回不一致')
         Log().info('对【订单金额】断言,断言结果--预期值%s == 实际值%s' %
                    (int(expect_one['itemsTotalPrice']), actual_one))
     except:
         Log().warning('对【订单金额】断言,断言结果--预期值%s == 实际值%s' %
                       (int(expect_one['itemsTotalPrice']), actual_one))
         raise
Esempio n. 11
0
 def testCase3(self, id=17):
     """消息通知成功"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'],
                       key=data_test['key'],
                       param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                (data_test['url'], data_test['key'], data_test['param'],
                 data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["isSuccess"]
     msg = apijson2["count"]
     try:
         self.assertEqual(int(expect_one['isSuccess']),
                          actual_one,
                          msg='预期和返回不一致')
         Log().info('对【isSuccess】断言,断言结果--预期值%s == 实际值%s,收到%s条消息' %
                    (expect_one['isSuccess'], actual_one, msg))
     except:
         Log().warning('对【isSuccess】断言,断言结果--预期值%s != 实际值%s' %
                       (expect_one['isSuccess'], actual_one))
         raise
Esempio n. 12
0
 def testCase2(self, id=20):
     """查看购物车信息"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'], data_test['way']))
     apijson1 = apijson.replace('false', '"false"')
     apijson2 = apijson1.replace('true', '"true"')
     apijson3 = json.loads(apijson2)
     actual_one = apijson3["data"]["itemList"][0]["name"]
     actual_two = apijson3["data"]["itemList"][0]["price"]
     try:
         self.assertEqual(expect_one['name'], actual_one, msg='预期和返回不一致')
         Log().info('对【商品名称】断言,断言结果--预期值%s == 实际值%s' % (expect_one['name'], actual_one))
     except:
         Log().warning('对【商品名称】断言,断言结果--预期值%s != 实际值%s' % (expect_one['name'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(float(expect_two['price']), actual_two, msg='预期和返回不一致')
             Log().info('对【商品价格】断言,断言结果--预期值%s == 实际值%s' % (expect_two['price'], actual_two))
         except:
             Log().warning('对【商品价格】断言,断言结果--预期值%s != 实际值%s' % (expect_two['price'], actual_two))
             raise
Esempio n. 13
0
 def testCase2(self, id=1):
     """提交订单成功未支付"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'], data_test['way']))
     apijson1 =json.loads(apijson)
     global actual
     actual = apijson1["data"]["orderNumber"]
     sql = operate_excel.get_palce(case_num=id, case_name=MyTest.name)['sql'].format(actual)
     actual_two = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).Perform()
     try:
         self.assertIsNotNone(actual, msg='实际值不存在')
         Log().info('对【订单号】断言,生成订单号%s' % (actual))
     except:
         Log().warning('对【订单号】断言,订单号生成失败')
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['tradestatus']), actual_two, msg='预期和返回不一致')
             Log().info('对【订单状态】断言,断言结果--预期值%s == 实际值%s' % (expect_two['tradestatus'], actual_two))
         except:
             Log().warning('对【订单状态】断言,断言结果--预期值%s != 实际值%s' % (expect_two['tradestatus'], actual_two))
             raise
Esempio n. 14
0
    def testCase1(self, id=0):
        """确认订单信息"""
        data_test = operate_excel.data(case_name=MyTest.name)[id]    #从Excel获取第1条测试用例
        expect_one = operate_excel.change(asserexpect=data_test['expect1'])    #获取期望值1,从Excel获取
        expect_two = operate_excel.change(asserexpect=data_test['expect2'])    #获取期望值2,从Excel获取
        Log().info('获取用例数据:%s' % data_test)
        # 接口请求,得到响应体
        apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                          way=data_test['way']).selectway()
        Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                   data_test['param'], data_test['way']))
        #接口返回的false和true无法解析,先替换为0
        apijson1 = apijson.replace('false', '"false"')
        apijson2 = apijson1.replace('true', '"true"')
        apijson3 = json.loads(apijson2)                           #json转化成字典
        actual_one = apijson3['data']['totalPrice']               #获取实际值1,从响应体获取
        actual_two = apijson3['data']['items'][id]['itemZhName']   #获取实际值2,从响应体获取
        # 期望值1和实际值1进行对比校验
        try:
            self.assertEqual(float(expect_one['totalPrice']), actual_one, msg='预期和返回不一致')

            Log().info('对【商品价格】断言,断言结果--预期值%s == 实际值%s' % (expect_one['totalPrice'], actual_one))
        except:
            Log().warning('对【商品价格】断言,断言结果--预期值%s != 实际值%s' % (expect_one['totalPrice'], actual_one))
            raise
        finally:
        #期望值2和实际值2进行对比校验
            try:
                self.assertEqual(expect_two['itemZhName'], actual_two, msg='预期和返回不一致')
                Log().info('对【商品名称】断言,断言结果--预期值%s == 实际值%s' % (expect_two['itemZhName'], actual_two))
            except:
                Log().warning('对【商品名称】断言,断言结果--预期值%s != 实际值%s' % (expect_two, actual_two))
                raise
Esempio n. 15
0
 def testCase2(self, id=16):
     """店铺信息展示"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'],
                       key=data_test['key'],
                       param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                (data_test['url'], data_test['key'], data_test['param'],
                 data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["data"]["nick"]
     actual_two = apijson2["data"]["tel"]
     try:
         self.assertEqual(expect_one['nick'], actual_one, msg='预期和返回不一致')
         Log().info('对【店铺名称】断言,断言结果--预期值%s == 实际值%s' %
                    (expect_one['nick'], actual_one))
     except:
         Log().warning('对【店铺名称】断言,断言结果--预期值%s != 实际值%s' %
                       (expect_one['nick'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(expect_two['tel'], actual_two, msg='预期和返回不一致')
             Log().info('对【店铺手机号】断言,断言结果--预期值%s == 实际值%s' %
                        (expect_two['tel'], actual_two))
         except:
             Log().warning('对【店铺手机号】断言,断言结果--预期值%s != 实际值%s' %
                           (expect_two['tel'], actual_two))
             raise
Esempio n. 16
0
 def testCase7(self, id=46):
     """查看提现手机号和可提现金额"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'],
                       key=data_test['key'],
                       param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                (data_test['url'], data_test['key'], data_test['param'],
                 data_test['way']))
     apijson1 = json.loads(apijson)
     actual_one = apijson1["data"]["mobile"]
     actual_two = apijson1["data"]["withdrawCommission"]
     try:
         self.assertEqual(expect_one['mobile'], actual_one, msg='预期和返回不一致')
         Log().info('对【提现手机号】断言,断言结果--预期值%s == 实际值%s' %
                    (expect_one['mobile'], actual_one))
     except:
         Log().warning('对【提现手机号】断言,断言结果--预期值%s != 实际值%s' %
                       (expect_one['mobile'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['withdrawCommission']),
                              actual_two,
                              msg='预期和返回不一致')
             Log().info('对【可提现金额】断言,断言结果--预期值%s == 实际值%s' %
                        (expect_two['withdrawCommission'], actual_two))
         except:
             Log().warning('对【可提现金额】断言,断言结果--预期值%s != 实际值%s' %
                           (expect_two['withdrawCommission'], actual_two))
             raise
Esempio n. 17
0
 def testCase05(self, id=4):
     """下单优惠劵后台配置"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'],
                       key=data_test['key'],
                       param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                (data_test['url'], data_test['key'], data_test['param'],
                 data_test['way']))
     apijson1 = json.loads(apijson)
     actual_one = apijson1['data'][0]['couponId']
     actual_two = apijson1['data'][0]['value']
     read_coupon_url = apijson1['data'][0]['remainCount']
     if read_coupon_url == 0:
         data_test1 = operate_excel.data(case_name=MyTest.name)[5]
         TestApi(url2=data_test1['url'],
                 key=data_test1['key'],
                 param=data_test1['param'],
                 way=data_test1['way']).selectway()
     try:
         self.assertEqual(int(expect_one['couponId']),
                          actual_one,
                          msg='预期和返回不一致')
         Log().info('对【后台优惠劵id】断言,断言结果--预期值%s == 实际值%s' %
                    (expect_one['couponId'], actual_one))
     except:
         Log().warning('对【后台优惠劵id】断言,断言结果--预期值%s == 实际值%s' %
                       (expect_one['couponId'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['value']),
                              actual_two,
                              msg='预期和返回不一致')
             Log().info('对【后台优惠劵面额】断言,断言结果--预期值%s == 实际值%s' %
                        (int(expect_two['value']), actual_two))
         except:
             Log().warning('对【后台优惠劵面额】断言,断言结果--预期值%s == 实际值%s' %
                           (int(expect_two['value']), actual_one))
             raise
Esempio n. 18
0
 def testCase03(self, id=2):
     """使用余额支付成功"""
     #校验下单前收益明细详情
     '''sql = 'SELECT commission from shop_commission where shop_id = 546082 limit 1'
     re_comm_Cumulative,re_comm_sale,re_comm_today,banlance = operate_db.Operate_db(self,casenum=id,sql=sql).income_db()
     print('下单前累计收益:' % re_comm_Cumulative)
     print('下单前销售收益:'% re_comm_sale)
     print('下单前今日收益:'% re_comm_today)
     print('下单前账户余额:' % banlance)'''
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'].format(actual),
                       key=data_test['key'],
                       param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                (data_test['url'], data_test['key'], data_test['param'],
                 data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["isSuccess"]
     sql = operate_excel.get_palce(
         case_num=id, case_name=MyTest.name)['sql'].format(actual)
     actual_two = operate_db.Operate_db(case_num=id,
                                        sql=sql,
                                        case_name=MyTest.name).Perform()
     try:
         self.assertEqual(int(expect_one['isSuccess']),
                          actual_one,
                          msg='预期和返回不一致')
         Log().info('对【订购结果】断言,断言结果--预期值%s == 实际值%s' %
                    (expect_one['isSuccess'], actual_one))
     except:
         Log().warning('对【订购结果】断言,断言结果--预期值%s != 实际值%s' %
                       (expect_one['isSuccess'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(int(expect_two['tradestatus']),
                              actual_two,
                              msg='预期和返回不一致')
             Log().info('对【订单状态】断言,断言结果--支付成功预期值%s == 实际值%s' %
                        (expect_two['tradestatus'], actual_two))
         except:
             Log().warning('对【订单状态】断言,断言结果--支付成功预期值%s != 实际值%s' %
                           (expect_two['tradestatus'], actual_two))
             raise
Esempio n. 19
0
 def testCase04(self, id=3):
     """下单成功发送站内信"""
     '''message_url = 'https://shop.m.showjoy.com.cn/api/message/count?userId=9082723'
     with urllib.request.urlopen(message_url) as resp:
         res = resp.read()
         print('下单前消息数count:', res['count'])'''
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'],
                       key=data_test['key'],
                       param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                (data_test['url'], data_test['key'], data_test['param'],
                 data_test['way']))
     apijson1 = json.loads(apijson)
     actual_one = apijson1['data'][0]['content']
     time = apijson1['data'][0]['time']
     sql = operate_excel.get_palce(case_num=id,
                                   case_name=MyTest.name)['sql']
     excuse_sql = operate_db.Operate_db(case_num=id,
                                        sql=sql,
                                        case_name=MyTest.name).Perform()
     json_dict = json.loads(excuse_sql)
     messageSubLines = json_dict['messageSubLines'][0]['content']
     actual_two = messageSubLines
     try:
         self.assertIn(expect_one['content'], actual_one, msg='预期和返回不一致')
         Log().info('%s,对【下单成功消息内容】断言,断言结果--预期值%s == 实际值%s' %
                    (time, expect_one['content'], actual_one))
     except:
         Log().warning('%s,对【下单成功消息内容】断言,断言结果--预期值%s == 实际值%s' %
                       (time, expect_one['content'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(expect_two['price'],
                              actual_two,
                              msg='预期和返回不一致')
             Log().info('对【下单成功消息展示订单实付金额】断言,断言结果--预期值%s == 实际值%s' %
                        (expect_two['price'], actual_two))
         except:
             Log().warning('对【下单成功消息展示订单实付金额】断言,断言结果--预期值%s == 实际值%s' %
                           (expect_two['price'], actual_two))
             raise
Esempio n. 20
0
 def testCase7(self, id=10):
     """发送订单退款通知"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["data"][0]["content"]
     try:
         self.assertEqual(expect_one['content'], actual_one, msg='预期和返回不一致')
         Log().info('对支付成功消息【content】断言,断言结果--预期值%s == 实际值%s' % (expect_one['content'], actual_one))
     except:
         Log().warning('对支付成功消息【content】断言,断言结果--预期值%s != 实际值%s' % (expect_one['content'], actual_one))
         raise
Esempio n. 21
0
 def testCase4(self, id=14):
     """绑定折扣码"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'],
                       key=data_test['key'],
                       param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                (data_test['url'], data_test['key'], data_test['param'],
                 data_test['way']))
     apijson1 = apijson.replace('false', '"false"')
     apijson2 = apijson1.replace('true', '"true"')
     apijson3 = json.loads(apijson2)
     actual_one = apijson3['data']['parentId']
     actual_two = apijson3['data']['name']
     sql = operate_excel.get_palce(case_num=11,
                                   case_name=MyTest.name)['sql']
     expect_two = operate_db.Operate_db(case_num=11,
                                        sql=sql,
                                        case_name=MyTest.name).Perform()
     try:
         self.assertEqual(int(expect_one['parentId']),
                          actual_one,
                          msg='预期和返回不一致')
         Log().info('对【parentId】断言,断言结果--预期值%s == 实际值%s' %
                    (expect_one['parentId'], actual_one))
     except:
         Log().warning('对【parentId】断言,断言结果--预期值%s != 实际值%s' %
                       (expect_one['parentId'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(expect_two, actual_two, msg='预期和返回不一致')
             Log().info('对【邀请人】断言,断言结果--预期值%s == 实际值%s' %
                        (expect_two, actual_two))
         except:
             Log().warning('对【邀请人】断言,断言结果--预期值%s != 实际值%s' %
                           (expect_two, actual_two))
             raise
     sleep(1)
     sql1 = operate_excel.get_palce(case_num=8,
                                    case_name=MyTest.name)['sql']
     operate_db.Operate_db(case_num=8, sql=sql1,
                           case_name=MyTest.name).Perform()
Esempio n. 22
0
 def testCase5(self, id=4):
     """订单详情收益和上级佣金"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     expect_three = operate_excel.change(asserexpect=data_test['expect3'])
     expect_four = operate_excel.change(asserexpect=data_test['expect4'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'].format(actual), key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'].format(actual), data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson1 = json.loads(apijson)
     actual_one = apijson1["data"]["tradePageInfoVO"]["orderDirectCommission"]
     sql = operate_excel.get_palce(case_num=id, case_name=MyTest.name)['sql']
     actual_com = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).more_perform()
     actual_two = str(decimal.Decimal(actual_com[0]['commission']))
     actual_three = str(decimal.Decimal(actual_com[1]['commission']))
     actual_four = str(decimal.Decimal(actual_com[2]['commission']))
     try:
         self.assertEqual(float(expect_one['orderDirectCommission']), actual_one, msg='预期和返回不一致')
         Log().info('对详情页【收益】断言,断言结果--预期值%s == 实际值%s' % (expect_one['orderDirectCommission'], actual_one))
     except:
         Log().warning('对详情页【收益】断言,断言结果--预期值%s != 实际值%s' % (expect_one['orderDirectCommission'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(expect_two['invite'], actual_two, msg='预期和返回不一致')
             Log().info('对邀请人【佣金】断言,断言结果--支付成功预期值%s == 实际值%s' % (expect_two['invite'], actual_two))
         except:
             Log().warning('对邀请人【佣金】断言,断言结果--支付成功预期值%s != 实际值%s' % (expect_two['invite'], actual_two))
             raise
         finally:
             try:
                 self.assertEqual(expect_three['guwen'], actual_three, msg='预期和返回不一致')
                 Log().info('对客户代表/营销顾问【佣金】断言,断言结果--支付成功预期值%s == 实际值%s' % (expect_three['guwen'], actual_three))
             except:
                 Log().warning('对客户代表/营销顾问【佣金】断言,断言结果--支付成功预期值%s != 实际值%s' % (expect_three['guwen'], actual_three))
                 raise
             finally:
                 try:
                     self.assertEqual(expect_four['jinli'], actual_four, msg='预期和返回不一致')
                     Log().info('对市场经理【佣金】断言,断言结果--支付成功预期值%s == 实际值%s' % (expect_four['jinli'], actual_four))
                 except:
                     Log().warning('对市场经理【佣金】断言,断言结果--支付成功预期值%s != 实际值%s' % (expect_four['jinli'], actual_four))
                     raise
Esempio n. 23
0
 def testCase4(self, id=3):
     """发送支付成功和收益到账通知"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     expect_two = operate_excel.change(asserexpect=data_test['expect2'])
     expect_three = operate_excel.change(asserexpect=data_test['expect3'])
     expect_four = operate_excel.change(asserexpect=data_test['expect4'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     actual_str1 = apijson2["data"][1]["content"]
     actual_one = json.loads(actual_str1)["title"]
     actual_two = json.loads(actual_str1)["messageSubLines"][0]["content"]
     actual_str2 = apijson2["data"][0]["content"]
     actual_three = json.loads(actual_str2)["title"]
     actual_four = json.loads(actual_str2)["messageSubLines"][0]["content"]
     try:
         self.assertEqual(expect_one['title'], actual_one, msg='预期和返回不一致')
         Log().info('对支付成功消息【title】断言,断言结果--预期值%s == 实际值%s' % (expect_one['title'], actual_one))
     except:
         Log().warning('对支付成功消息【title】断言,断言结果--预期值%s != 实际值%s' % (expect_one['title'], actual_one))
         raise
     finally:
         try:
             self.assertEqual(expect_two['content'], actual_two, msg='预期和返回不一致')
             Log().info('对支付成功消息【金额】断言,断言结果--支付成功预期值%s == 实际值%s' % (expect_two['content'], actual_two))
         except:
             Log().warning('对支付成功消息【金额】断言,断言结果--支付成功预期值%s != 实际值%s' % (expect_two['content'], actual_two))
             raise
         finally:
             try:
                 self.assertEqual(expect_three['title'], actual_three, msg='预期和返回不一致')
                 Log().info('对收益到账消息【title】断言,断言结果--支付成功预期值%s == 实际值%s' % (expect_three['title'], actual_three))
             except:
                 Log().warning('对收益到账消息【title】断言,断言结果--支付成功预期值%s != 实际值%s' % (expect_three['title'], actual_three))
                 raise
             finally:
                 try:
                     self.assertEqual(expect_four['content'], actual_four, msg='预期和返回不一致')
                     Log().info('对收益到账消息【金额】断言,断言结果--支付成功预期值%s == 实际值%s' % (expect_four['content'], actual_four))
                 except:
                     Log().warning('对收益到账消息【金额】断言,断言结果--支付成功预期值%s != 实际值%s' % (expect_four['content'], actual_four))
                     raise
Esempio n. 24
0
    def testCase02(self, id=1):
        """直播推流成功"""
        data_test = operate_excel.data(case_name=MyTest.name)[id]
        expect_one = operate_excel.change(asserexpect=data_test['expect1'])
        expect_two = operate_excel.change(asserexpect=data_test['expect2'])
        Log().info('获取用例数据:%s' % data_test)
        apijson2 = TestApi(url2=data_test['url'],
                           key=data_test['key'],
                           param=data_test['param'].replace(
                               "{0}", str(note_Id)),
                           way=data_test['way']).selectway()

        Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                   (data_test['url'], data_test['key'], data_test['param'],
                    data_test['way']))
        print(apijson2)
        apijson1 = json.loads(apijson2)
        sleep(1)
        sql = operate_excel.get_palce(case_num=id,
                                      case_name=MyTest.name)['sql']
        actual_one = apijson1["isSuccess"]
        actual_two = operate_db.Operate_db(case_num=id,
                                           sql=sql,
                                           case_name=MyTest.name).Perform()
        try:
            self.assertEqual(int(expect_one['isSuccess']),
                             actual_one,
                             msg='预期和返回不一致')
            Log().info('推流成功,对【isSuccess】断言,断言结果--预期值%s == 实际值%s' %
                       (expect_one['isSuccess'], actual_one))
        except:
            Log().warning('推流失败,对【isSuccess】断言,断言结果--预期值%s == 实际值%s' %
                          (expect_one['isSuccess'], actual_one))
            raise
        finally:
            try:
                self.assertEqual(int(expect_two['live_status']),
                                 actual_two,
                                 msg='预期和返回不一致')
                Log().info('对【直播状态】断言,断言结果--预期值%s == 实际值%s' %
                           (expect_two['live_status'], actual_two))
            except:
                Log().warning('对【直播状态】断言,断言结果--预期值%s != 实际值%s' %
                              (expect_two['live_status'], actual_two))
                raise
Esempio n. 25
0
 def testCase3(self, id=37):
     """设置默认地址"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'].format(address_id1), key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'].format(address_id1), data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson1 = json.loads(apijson)
     global address_id
     address_id = apijson1["data"]["addresses"][0]["id"]
     actual_one = apijson1["data"]["addresses"][0]["isDefault"]
     try:
         self.assertEqual(expect_one['isDefault'], str(actual_one), msg='预期和返回不一致')
         Log().info('地址【%s】是否为默认地址,断言结果--预期值%s == 实际值%s' % (address_id, expect_one['isDefault'], actual_one))
     except:
         Log().warning('地址【%s】是否为默认地址,断言结果--预期值%s != 实际值%s' % (address_id, expect_one['isDefault'], actual_one))
         raise
Esempio n. 26
0
    def testCase04(self, id=3):
        """观众加入直播"""
        data_test = operate_excel.data(case_name=MyTest.name)[id]
        expect_one = operate_excel.change(asserexpect=data_test['expect1'])
        Log().info('获取用例数据:%s' % data_test)
        apijson2 = TestApi(url2=data_test['url'].format(note_Id),
                           key=data_test['key'],
                           param=data_test['param'],
                           way=data_test['way']).selectway()

        Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' %
                   (data_test['url'], data_test['key'], data_test['param'],
                    data_test['way']))

        sql = operate_excel.get_palce(
            case_num=id, case_name=MyTest.name)['sql'].format(note_Id)
        expect_two = operate_db.Operate_db(case_num=id,
                                           sql=sql,
                                           case_name=MyTest.name).Perform()
        print(apijson2)
        apijson1 = json.loads(apijson2)
        actual_one = apijson1["isSuccess"]
        sleep(1)
        actual_two = apijson1["data"]["pullUrl"]
        try:
            self.assertEqual(int(expect_one['isSuccess']),
                             actual_one,
                             msg='预期和返回不一致')
            Log().info('加入成功,对【isSuccess】断言,断言结果--预期值%s == 实际值%s' %
                       (expect_one['isSuccess'], actual_one))
        except:
            Log().warning('加入失败,对【isSuccess】断言,断言结果--预期值%s == 实际值%s' %
                          (expect_one['isSuccess'], actual_one))
            raise
        finally:
            try:
                self.assertEqual(expect_two, actual_two, msg='预期和返回不一致')
                Log().info('对【加入状态】断言,断言结果--预期值%s == 实际值%s' %
                           (expect_two, actual_two))
            except:
                Log().warning('对【加入状态】断言,断言结果--预期值%s != 实际值%s' %
                              (expect_two, actual_two))
                raise
Esempio n. 27
0
    def testCase06(self, id=5):
        """观众对主播进行关注/取关/互相关注"""
        data_test = operate_excel.data(case_name=MyTest.name)[id]
        expect_one = operate_excel.change(asserexpect=data_test['expect1'])
        expect_two = operate_excel.change(asserexpect=data_test['expect2'])
        Log().info('开始执行测试用例:%s' % data_test)
        apijson = TestApi(url2=data_test['url'],
                          param=data_test['param'],
                          key=data_test['key'],
                          way=data_test['way']).selectway()
        Log().info('请求传入的数据:url:%s,param:%s,key:%s,way:%s' %
                   (data_test['url'], data_test['param'], data_test['key'],
                    data_test['way']))
        apijson1 = json.loads(apijson)
        actual_one = apijson1["isSuccess"]
        sleep(1)
        sql = operate_excel.get_palce(
            case_num=id, case_name=MyTest.name)['sql'].format(note_Id)
        actual_two = operate_db.Operate_db(case_num=id,
                                           sql=sql,
                                           case_name=MyTest.name).Perform()
        try:
            self.assertEqual(int((expect_one)['isSuccess']),
                             actual_one,
                             msg='预期和返回不一致')
            Log().info('关注/取关/互关成功,对【isSuccess】断言,断言结果--预期值%s==实际值%s' %
                       (expect_one['isSuccess'], actual_one))
        except:
            Log().warning('关注/取关/互关失败,对【isSuccess】断言,断言结果--预期值%s==实际值%s' %
                          (expect_one['isSuccess'], actual_one))
            raise

        finally:
            try:
                self.assertEqual(int(expect_two['live_status']),
                                 actual_two,
                                 msg='预期和返回不一致')
                Log().info('对【直播状态】断言,断言结果--预期值%s == 实际值%s' %
                           (expect_two['live_status'], actual_two))
            except:
                Log().warning('对【直播状态】断言,断言结果--预期值%s != 实际值%s' %
                              (expect_two['live_status'], actual_two))
                raise
Esempio n. 28
0
 def testCase1(self, id=19):
     """商品加入购物车"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'], data_test['way']))
     apijson2 = json.loads(apijson)
     actual_one = apijson2["data"]
     try:
         self.assertEqual(int(expect_one['data']), actual_one, msg='预期和返回不一致')
         Log().info('成功加入购物车,对【data】断言,断言结果--预期值%s == 实际值%s' % (expect_one['data'], actual_one))
     except:
         Log().warning('成功加入购物车,对【data】断言,断言结果--预期值%s != 实际值%s' % (expect_one['data'], actual_one))
         raise
     else:
         Log().info('第1条断言成功')
Esempio n. 29
0
 def testCase4(self, id=22):
     """删除购物车商品"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'],
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                                                        data_test['param'], data_test['way']))
     apijson1 = apijson.replace('false', '"false"')
     apijson2 = apijson1.replace('true', '"true"')
     apijson3 = json.loads(apijson2)
     actual_one = apijson3["data"]["itemList"]
     try:
         self.assertEqual(int(expect_one['itemList']), len(actual_one), msg='预期和返回不一致')
         Log().info('对【购物车商品】断言,断言结果--预期值%s == 实际值%s' % (expect_one['itemList'], len(actual_one)))
     except:
         Log().warning('对【购物车商品】断言,断言结果--预期值%s != 实际值%s' % (expect_one['itemList'], len(actual_one)))
         raise
Esempio n. 30
0
 def testCase4(self, id=38):
     """编辑地址"""
     data_test = operate_excel.data(case_name=MyTest.name)[id]
     expect_one = operate_excel.change(asserexpect=data_test['expect1'])
     Log().info('获取用例数据:%s' % data_test)
     apijson = TestApi(url2=data_test['url'], key=data_test['key'], param=data_test['param'].replace("{0}", str(address_id1)),
                       way=data_test['way']).selectway()
     Log().info('请求传入数据:url:%s,key:%s,参数:%s,请求方式:%s' % (data_test['url'], data_test['key'],
                data_test['param'].replace("{0}", str(address_id1)), data_test['way']))
     apijson2 = json.loads(apijson)
     sql = operate_excel.get_palce(case_num=id, case_name=MyTest.name)['sql']
     actual_one = operate_db.Operate_db(case_num=id, sql=sql, case_name=MyTest.name).Perform()
     global address_id2
     address_id2 = apijson2["data"]
     try:
         self.assertEqual(expect_one['fullName'], actual_one, msg='预期和返回不一致')
         Log().info('重新生成地址id【%s】,对【fullName】断言,断言结果--预期值%s == 实际值%s' % (address_id2, expect_one['fullName'], actual_one))
     except:
         Log().warning('重新生成地址id【%s】,对【fullName】断言,断言结果--预期值%s != 实际值%s' % (address_id2, expect_one['fullName'], actual_one))
         raise