Пример #1
0
 def redeem_coupon(self, issued_coupons, isRedeem=True):
     coupon_list = issued_coupons[1]
     if not isinstance(issued_coupons, list):
         coupon_list = [issued_coupons[1]]
     redeem_coupon_request = LuciHelper.redeemCouponRequest(
         coupon_list,
         issued_coupons[0],
         redeemCouponRequest={'commit': isRedeem})
     start = time.time()
     self.connObj.redeemCoupons(redeem_coupon_request)
     end = time.time()
     total = end - start
     self.queue.task_done()
     with self.lock:
         self.result['total_redeem_count'] += 1
         self.result['total_redeem_time'] += total
         self.result['avg_redeem_time'] = self.result[
             'total_redeem_time'] / self.result['total_redeem_count']
    def est_LUCI_BulkIssual(self, description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self, couponConfigReq={"any_user": True})
        couponCodeList = []
        Logger.log('Coupon series Id: ', couponSeriesId)

        bulkUserIds = []
        for _ in range(1000000):
            bulkUserIds.append(randValues.randomInteger(9))
        bulkUserIds = list(set(bulkUserIds))
        limit = 500000
        i = 0
        Logger.log('Actial : ', len(bulkUserIds))
        for _ in range(len(bulkUserIds)):
            if limit > (len(bulkUserIds)):
                limit = len(bulkUserIds)
            issueMultipleCouponsRequest = {
                'couponSeriesId': couponSeriesId,
                'storeUnitId': self.tillId,
                'userIds': bulkUserIds[i:(limit)]
            }
            issueMultipleCouponsRequestObj = LuciObject.issueMultipleCouponsRequest(
                issueMultipleCouponsRequest)
            couponDetailsList = self.connObj.issueMultipleCoupons(
                issueMultipleCouponsRequestObj)

            for couponDetails in couponDetailsList:
                couponDetails = couponDetails.__dict__
                couponCodeList.append(couponDetails['couponCode'])
            if limit == len(bulkUserIds):
                break

            i = limit
            limit = limit + 1000

        for couponCode, userId in zip(couponCodeList, bulkUserIds):
            couponDetailsList = self.connObj.redeemCoupons(
                LuciHelper.redeemCouponRequest(
                    [couponCode],
                    userId,
                    billId=Utils.getTime(milliSeconds=True)))