def assertOrderCount(self, rsq, buyer): # C011待付款 orderCountWaitPayDB = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_orderdetail where buyer_id = ?) and order_status = ?', buyer.companyId, 'C011') self.assertEqual(rsq.model['orderCount']['pendingPaymentOrderCount'], str(orderCountWaitPayDB)) # C012已取消 orderCountCancelDB = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_orderdetail where buyer_id = ?) and order_status = ?', buyer.companyId, 'C012') self.assertEqual(rsq.model['orderCount']['cancelledOrderCount'], str(orderCountCancelDB)) # C015已退款 # C017待收货 orderCountWatiRecDB = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_orderdetail where buyer_id = ?) and order_status = ?', buyer.companyId, 'C017') self.assertEqual(rsq.model['orderCount']['waitingReceiveOrderCount'], str(orderCountWatiRecDB)) # C019交易完成 orderCountFinishDB = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_orderdetail where buyer_id = ?) and order_status = ?', buyer.companyId, 'C019') self.assertEqual(rsq.model['orderCount']['finishedOrderCount'], str(orderCountFinishDB)) # C020待发货 orderCountWaitDeliverDB = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_orderdetail where buyer_id = ?) and order_status = ?', buyer.companyId, 'C020') self.assertEqual(rsq.model['orderCount']['waitingShipmentOrderCount'], str(orderCountWaitDeliverDB))
def test_getCategoryList_beer(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) pijiuList = ws.getCategoryList(merchCategoryCode='C01L0104') self.assertEqual(pijiuList.model['success'], '0') self.assertEqual(pijiuList.model['categoryCode'], 'C01L0104') # 校验品牌数量 numPijiuBrand = select_int( 'select count(*) from dlcategroy.dl_brand where brand_id in (select brand_id from dlcategroy.dl_brand_ref_category where category_id = \'C01L0104\' and brand_status = \'01\') and brand_status != \'99\'' ) self.assertEqual( len(pijiuList.model['categoryItem']['brandTupleList']), numPijiuBrand) # 校验分类数量 numPijiuClassify = select_int( 'select count(*) from dlcategroy.dl_property_value where property_id = \'PL20401\'' ) self.assertEqual( len(pijiuList.model['categoryItem']['classifyTupleList']), numPijiuClassify) # 校验国家数量 numPijiuCountry = select_int( 'select count(*) from dlcategroy.dl_property_value where property_id = \'PL20402\'' ) self.assertEqual( len(pijiuList.model['categoryItem']['countryTupleList']), numPijiuCountry)
def test_delShoppingcartByProductIds_many(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) ws.addShoppingcar(merchId=self.Merch1.goodsId, merchCount='1', sellerId=self.Merch1.seller_store_id, sellerName=self.Merch1.sellerName) ws.addShoppingcar(merchId=self.Merch2.goodsId, merchCount='1', sellerId=self.Merch2.seller_store_id, sellerName=self.Merch2.sellerName) #ws.addShoppingcar(merchId=self.Merch4.goodsId, merchCount='1', sellerId=self.Merch4.seller_store_id, sellerName=self.Merch4.sellerName) shopcart = ws.toShoppingcart() shopcartId1 = None shopcartId2 = None if shopcart.model['sellerList'][0]['merchList'][0][ 'merchId'] == self.Merch1.goodsId: shopcartId1 = shopcart.model['sellerList'][0]['merchList'][0]['id'] shopcartId2 = shopcart.model['sellerList'][0]['merchList'][1]['id'] elif shopcart.model['sellerList'][0]['merchList'][0][ 'merchId'] == self.Merch2.goodsId: shopcartId1 = shopcart.model['sellerList'][0]['merchList'][1]['id'] shopcartId2 = shopcart.model['sellerList'][0]['merchList'][0]['id'] list1 = {"shoppingCartId": shopcartId1, "merchId": self.Merch1.goodsId} list2 = {"shoppingCartId": shopcartId2, "merchId": self.Merch2.goodsId} delMerch = ws.delShoppingcartByProductIds(delList=[list1, list2]) self.assertEqual(delMerch.model['success'], '0') shopNum = select_int( 'select count(*) from danlu_cd_database.dl_shoppingcart where user_id = ?', self.UserShop.userId) self.assertEqual(shopNum, 0)
def test_getSellerOrderList_page(self): orderCount = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_seller_detail where seller_id = ?)', self.DealMgr.companyId) page = orderCount / 15 flag = 0 for i in range(1, page + 2): sellerOrderList = self.wsDealMager.getSellerOrderList( orderStatus='0', page=i, rows=15) for j in range(0, len(sellerOrderList.model['paymentOrderList'])): if sellerOrderList.model['paymentOrderList'][j][ 'paymentNo'] == self.UserShop.orderCodWaitDeliver.paymentNo: flag += 1 if i == page + 1: self.assertEqual( len(sellerOrderList.model['paymentOrderList']), orderCount % 15, "The last page is wrong") else: self.assertEqual( len(sellerOrderList.model['paymentOrderList']), 15, "Every page is wrong") self.assertEqual( flag, 1, self.UserShop.orderCodWaitDeliver.paymentNo + ' is not once ')
def test_getArea_county(self): ws = webservice() countyList = ws.getArea('CHNP023C237') countyNum = select_int( 'select count(*) from dlpublic.dl_area where area_parent_code = ?', 'CHNP023C237') self.assertEqual(countyList.code, 200) self.assertEqual(countyList.model['success'], '0') self.assertEqual(len(countyList.model['areaList']), countyNum)
def test_getArea_province(self): ws = webservice() provinceList = ws.getArea('CHN') provinceNum = select_int( 'select count(*) from dlpublic.dl_area where area_parent_code = ?', 'CHN') self.assertEqual(provinceList.code, 200) self.assertEqual(provinceList.model['success'], '0') self.assertEqual(len(provinceList.model['areaList']), provinceNum)
def test_getAreaListStandAlone_city(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) areaList = ws.getAreaListStandAlone(provinceCode='P023') self.assertEqual(areaList.model['success'], '0') cityNum = select_int( 'select count(*) from dlpublic.dl_area where area_parent_code = ?', 'CHNP023') self.assertEqual(len(areaList.model['topList']), cityNum)
def test_getAreaListByCondition_province(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) areaList = ws.getAreaListByCondition() self.assertEqual(areaList.model['success'], '0') provinceNum = select_int( 'select count(*) from dlpublic.dl_area where area_parent_code = ?', 'CHN') self.assertEqual(len(areaList.model['topList']), provinceNum)
def test_getCategoryList_sprit(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) baijiuList = ws.getCategoryList() self.assertEqual(baijiuList.model['success'], '0') self.assertEqual(baijiuList.model['categoryCode'], 'C01L0101') # 校验品牌数量dlcategroy numBaijiuBrand = select_int( 'select count(*) from dlcategroy.dl_brand where brand_id in (select brand_id from dlcategroy.dl_brand_ref_category where category_id = \'C01L0101\' and brand_status = \'01\') and brand_status != \'99\'' ) self.assertEqual( len(baijiuList.model['categoryItem']['brandTupleList']), numBaijiuBrand) # 校验香型数量 numBaijiuProperty = select_int( 'select count(*) from dlcategroy.dl_property_value where property_id = \'PL20103\'' ) self.assertEqual( len(baijiuList.model['categoryItem']['odorTupleList']), numBaijiuProperty)
def test_getSellerOrderList_waitDeliver(self): sellerOrderList = self.wsDealMager.getSellerOrderList( orderStatus='C020', page=1, rows=999999) self.assertEqual(sellerOrderList.model['success'], '0') orderCount = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_seller_detail where seller_id = ?) and order_status = ?', self.DealMgr.companyId, 'C020') self.assertEqual(len(sellerOrderList.model['paymentOrderList']), orderCount) self.assertOrderList(sellerOrderList, self.UserShop.orderCodWaitDeliver, self.Merch1)
def test_getCategoryList_wine(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) putaojiuList = ws.getCategoryList(merchCategoryCode='C01L0102') self.assertEqual(putaojiuList.model['success'], '0') self.assertEqual(putaojiuList.model['categoryCode'], 'C01L0102') # 校验品牌数量 numPutaojiuBrand = select_int( 'select count(*) from dlcategroy.dl_brand where brand_id in (select brand_id from dlcategroy.dl_brand_ref_category where category_id = \'C01L0102\' and brand_status = \'01\') and brand_status != \'99\'' ) self.assertEqual( len(putaojiuList.model['categoryItem']['brandTupleList']), numPutaojiuBrand) # 校验产地 numPutaojiuProperty = select_int( 'select count(*) from dlcategroy.dl_property_value where property_id = \'PL20202\'' ) self.assertEqual( len(putaojiuList.model['categoryItem']['productionTupleList']), numPutaojiuProperty)
def test_getCategoryList_tea(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) teaList = ws.getCategoryList(merchCategoryCode='C01T01') self.assertEqual(teaList.model['success'], '0') self.assertEqual(teaList.model['categoryCode'], 'C01T01') # 校验茶类数量 numTeaClassify = select_int( 'select count(*) from dlcategroy.dl_category where parent_category_id = \'C01T01\'' ) self.assertEqual(len(teaList.model['categoryItem']), numTeaClassify)
def test_getBuyerOrderList_all(self): buyerOrderList = self.wsUserShop.getBuyerOrderList(orderStatus='0', page=1, rows=999999) self.assertEqual(buyerOrderList.model['success'], '0') orderCount = select_int( 'select count(*) from dlorder.dl_order_orderdetail where buyer_id = ?', self.UserShop.companyId) self.assertEqual(len(buyerOrderList.model['paymentOrderList']), orderCount) self.assertOrderList(buyerOrderList, self.UserShop.orderCodWaitDeliver, self.Merch1)
def test_getCategoryList_drink(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) drinkList = ws.getCategoryList(merchCategoryCode='C01X0101') self.assertEqual(drinkList.model['success'], '0') self.assertEqual(drinkList.model['categoryCode'], 'C01X0101') # 校验茶类数量 numDrinkBrand = select_int( 'select count(*) from dlcategroy.dl_brand where brand_id in (select brand_id from dlcategroy.dl_brand_ref_category where category_id = \'C01X0101\' and brand_status = \'01\') and brand_status != \'99\'' ) self.assertEqual( len(drinkList.model['categoryItem']['brandTupleList']), numDrinkBrand)
def test_getBuyerOrderList_cancel(self): buyerOrderList = self.wsUserShop.getBuyerOrderList(orderStatus='C012', page=1, rows=999999) self.assertEqual(buyerOrderList.model['success'], '0') orderCount = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_orderdetail where buyer_id = ?) and order_status = ?', self.UserShop.companyId, 'C012') self.assertEqual(len(buyerOrderList.model['paymentOrderList']), orderCount) self.assertOrderList(buyerOrderList, self.UserShop.orderCodCancel, self.Merch1, paymentOrderButtomList='00000')
def test_getSellerOrderList_complete(self): sellerOrderList = self.wsDealMager.getSellerOrderList( orderStatus='C019', page=1, rows=999999) self.assertEqual(sellerOrderList.model['success'], '0') orderCount = select_int( 'select count(*) from dlorder.dl_order_orderinfo where order_no in (SELECT order_no FROM dlorder.dl_order_seller_detail where seller_id = ?) and order_status = ?', self.DealMgr.companyId, 'C019') self.assertEqual(len(sellerOrderList.model['paymentOrderList']), orderCount) self.assertOrderList(sellerOrderList, self.UserShop.orderCodComplete, self.Merch1, payWay='01', receiveStatus='1', buttomList='0000000')
def test_getAreaListByCondition_city(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) areaList = ws.getAreaListByCondition(provinceCode='P023') self.assertEqual(areaList.model['success'], '0') cityNum = select_int( 'select count(*) from dlpublic.dl_area where area_parent_code = ?', 'CHNP023') flag = False for i in range(0, len(areaList.model['topList'])): if areaList.model['topList'][i]['code'] == 'P023': self.assertEqual( len(areaList.model['topList'][i]['childList']), cityNum) flag = True self.assertEqual(flag, True, '未找到相应的省份')
def test_delShoppingcartByProductIds_one(self): ws = webservice() ws.login(self.UserShop.username, self.UserShop.password) ws.addShoppingcar(merchId=self.Merch1.goodsId, merchCount='1', sellerId=self.Merch1.seller_store_id, sellerName=self.Merch1.sellerName) shopcart = ws.toShoppingcart() shopcartId = shopcart.model['sellerList'][0]['merchList'][0]['id'] delMerch = ws.delShoppingcartByProductIds( delList=[{ "shoppingCartId": shopcartId, "merchId": self.Merch1.goodsId }]) self.assertEqual(delMerch.model['success'], '0') shopNum = select_int( 'select count(*) from danlu_cd_database.dl_shoppingcart where user_id = ?', self.UserShop.userId) self.assertEqual(shopNum, 0)
def test_getBuyerOrderList_page(self): orderCount = select_int( 'select count(*) from dlorder.dl_order_orderdetail where buyer_id = ?', self.UserShop.companyId) page = orderCount / 15 flag = 0 for i in range(1, page + 2): buyerOrderList = self.wsUserShop.getBuyerOrderList(orderStatus='0', page=i, rows=15) for j in range(0, len(buyerOrderList.model['paymentOrderList'])): if buyerOrderList.model['paymentOrderList'][j][ 'paymentNo'] == self.UserShop.orderCodWaitDeliver.paymentNo: flag += 1 if i == page + 1: self.assertEqual(len(buyerOrderList.model['paymentOrderList']), orderCount % 15, "The last page is wrong") else: self.assertEqual(len(buyerOrderList.model['paymentOrderList']), 15, "Every page is wrong") self.assertEqual( flag, 1, self.UserShop.orderCodWaitDeliver.paymentNo + ' is not once ')