Exemple #1
0
 def test_001(self):
     '''查看状态和库存正常的商品'''
     productIdList = Shopping().GouWuChe_add(self.token)
     productId = productIdList[0]
     self.logger.info('获取的分销商商品id为:%s' % productId)
     dict = H5Method().Excel_Dict('H5商城', '商品详情', 1, 4, 3, 2)
     dict['headers']['token'] = self.token
     dict['data']['goodsId'] = productId
     response = H5Method().Post_H5(dict['url'], dict['headers'],
                                   json.dumps(dict['data']))
     self.logger.info('获取的商品id为:%s,获取的商品状态为:%s' %
                      (productId, response.json()['data']['status']))
     self.assertEqual(ProductDetails().productParam(productId)[0],
                      response.json()['data']['goodsTitle'],
                      msg='返回商品名称不正确')
     self.assertEqual(ProductDetails().productParam(productId)[1],
                      response.json()['data']['status'],
                      msg='返回的商品状态不正确')
     self.logger.info('获取商品状态为:1---上架中')
Exemple #2
0
 def test_012(self):
     '''已过期列表'''
     dict = H5Method().Excel_Dict('H5商城', '确认订单', 11, 4, 3, 2)
     dict['headers']['token'] = self.token
     response = H5Method().Post_H5(dict['url'], dict['headers'], json.dumps(dict['data']))
     numberCode = len(response.json()['data'])
     self.logger.info('查询所有可用优惠券内容,返回列表为:%s' % response.json())
     self.logger.info('查询该用已使用优惠券数量为:%s' % numberCode)
     tokenCode = eval(H5Method().token_code(self.token))
     shopId = tokenCode['user']['shopId']
     userId = tokenCode['user']['id']
     couponNumber = ProductDetails().CouponNumber(2, shopId, userId)
     self.assertEqual(couponNumber, numberCode, msg='该用户预期返回条数和实际返回条数不相符')
Exemple #3
0
    def test_002(self):
        '''库存已售罄查看商品详情'''
        productIdList = Shopping().GouWuChe_add(self.token)
        productId = productIdList[0]
        self.logger.info('获取的分销商商品id为:%s' % productId)
        dict = H5Method().Excel_Dict('H5商城', '商品详情', 2, 4, 3, 2)
        dict['headers']['token'] = self.token
        dict['data']['goodsId'] = productId

        H5Method().updateSQl(productId, 0, 2)  # 根据分销商商品id修改一下商品库存
        response = H5Method().Post_H5(dict['url'], dict['headers'],
                                      json.dumps(dict['data']))

        self.logger.info('获取的商品id为:%s,获取的商品状态为:%s' %
                         (productId, response.json()['data']['status']))
        self.assertEqual(ProductDetails().productParam(productId)[0],
                         response.json()['data']['goodsTitle'],
                         msg='返回商品名称不正确')
        self.assertEqual(ProductDetails().productParam(productId)[1],
                         response.json()['data']['status'],
                         msg='返回的商品状态不正确')
        self.logger.info('获取商品状态为:2---已售罄')
        H5Method().updateSQl(productId, 456455, 1)  # 还原分销商商品库存和状态
Exemple #4
0
 def test_001(self):
     '''购买一件商品,确认订单'''
     goodsId=Shopping().GouWuChe_add(self.token)  #goodsId为商品id列表,len()之后为2
     goodId=goodsId[0]
     self.logger.info('确认订单页面的id为:%s'%goodId)
     dict=H5Method().Excel_Dict('H5商城','确认订单',1,4,3,2)
     dict['headers']['token']=self.token
     dict['headers']['Referer']=dict['headers']['Referer']+ str(goodId)
     dict['data']['goodsId']=goodId  #购买请求商品id   购买请求商品数量默认为1
     response=H5Method().Post_H5(dict['url'],dict['headers'],json.dumps(dict['data']))
     self.logger.info('返回内容为:\n%s'%response.json())
     self.assertEqual(eval(table.cell(1,8).value)['msg'],response.json()['msg'],msg='跳转确认订单页面未成功')  #断言是否成功
     #断言商品名称
     self.assertEqual(ProductDetails().productParam(goodId)[0],response.json()['data']['products'][0]['productName'],msg='商品名称不对')
Exemple #5
0
    def test_009(self):
        '''购买多件商品,可选择优惠券'''

        goodsId = Shopping().GouWuChe_add(self.token)  # goodsId为商品id列表,len()之后为2
        self.logger.info('确认订单页面的id为:%s' % goodsId)
        dict = H5Method().Excel_Dict('H5商城', '确认订单',7,4,3,2)
        dict['headers']['token'] = self.token
        products=dict['data']['products']
        classList=[]  #商品分类id列表
        for a in goodsId:
            code=ProductDetails().productCoupon(a)
            classList.append(code)   #根据商品id  得出 商品金额 以及商品所属分类id
            products.append({"buyCount":1,"goodsId":str(a)})
        print(products)
        dict['data']['products'] = products  # 购买请求商品id   购买请求商品数量默认为1
        self.logger.info('请求参数为:%s'%dict['data'])
        response = H5Method().Post_H5(dict['url'], dict['headers'], json.dumps(dict['data']))
        self.logger.info('返回内容为:\n%s' % response.json())
        # self.assertEqual(eval(table.cell(2, 8).value)['msg'], response.json()['msg'], msg='跳转确认订单页面未成功')  # 断言是否成功
        self.assertEqual(eval(table.cell(7, 8).value)['msg'],
                         response.json()['msg'], msg='购买数量大于库存数量,该接口判断异常')
        self.assertEqual(eval(table.cell(7, 8).value)['statusCode'],
                         response.json()['statusCode'], msg='购买数量大于库存数量,该接口判断异常')
        print(ProductDetails.CouponYes('62302675','17700000000'))   #获取出该用户所有可用的优惠券列表
        listCode=ProductDetails.CouponYes('62302675','17700000000')
        print(len(listCode))
        CouponList=[]  #创建优惠券可使用列表
        '''以下获取两个商品的可用优惠券列表'''
        for code in  listCode:
            if  code[1]==0:  #判断使用门槛
                CouponList.append(str(code[0]))
            if code[1]==1:
                if code[3]==0: #判断时间 为绝对时间
                    nowTime = datetime.datetime.now()
                    if code[4]<nowTime or nowTime<code[5]  or  code[4]==None:  #如果优惠券最后使用期限<当前时间或者小于开始时间
                        pass #则pass
                    if code[4]>=nowTime>=code[5]:  #最小时间《当前时间《结束时间
                        if code[2]>classList[0][0][1]+classList[1][0][1]:
                            pass
                        else:
                            if code[7]==0:   #判断使用范围:0,全场商品|all;1,分类商品|category;2,指定商品|appoint',
                                CouponList.append(str(code[0]))  ###需求逻辑有问题 ,需要咨询产品
                            if code[7]==1:     #根据分类时,则要求确认订单页面的所有商品都是属于同一分类,则展示该对应的有优惠券
                                if classList[0][0][0]==classList[1][0][0]  and classList[0][0][0]==code[8]:
                                    CouponList.append(str(code[0]))
                                else:
                                    pass
                            if code[7]==2:   ##指定商品id
                                if goodsId[0]==goodsId[1] and goodsId[0]==code[-1]:
                                    CouponList.append(str(code[0]))
                                else:
                                    pass
                if code[3]==1:  #判断linux时间戳  相对时间
                    nowTime=int(time.time())
                    if int(code[6])<nowTime  or  code[6]==None  or code[6]==0:
                        pass
                    if int(code[6])>=nowTime:
                        if code[2] > classList[0][0][1] + classList[1][0][1]:
                            pass
                        else:
                            if code[7]==0:   #判断使用范围:0,全场商品|all;1,分类商品|category;2,指定商品|appoint',
                                CouponList.append(str(code[0]))  ###需求逻辑有问题 ,需要咨询产品
                            if code[7]==1:     #根据分类时,则要求确认订单页面的所有商品都是属于同一分类,则展示该对应的有优惠券
                                if classList[0][0][0]==classList[1][0][0]  and classList[0][0][0]==code[8]:
                                    CouponList.append(str(code[0]))
                                else:
                                    pass
                            if code[7]==2:   ##指定商品id
                                if goodsId[0]==goodsId[1] and goodsId[0]==code[-1]:
                                    CouponList.append(str(code[0]))
                                else:
                                    pass
        self.logger.info('商品id列表为:%s;商品分类id和库存为:%s'%(goodsId,classList))
        self.logger.info('可以用的优惠券id列表为:%s'%CouponList)
        responseIdList=[]
        for  a  in  response.json()['data']['list']:
            responseIdList.append(a['couponId'])
        self.assertEqual(CouponList,responseIdList,msg='返回可使用优惠券不对')