Exemplo n.º 1
0
 def constructInvalidateCoupon(revokeType, data):
     couponsToBeInvalidated = []
     for v in data:
         if revokeType == 'CUSTOMER_AND_COUPON':
             couponsToBeInvalidated.append(
                 LuciObject.issuedCouponDetails({
                     'couponCode': str(v[0]),
                     'issuedTo': v[1]
                 }))
         else:
             couponsToBeInvalidated.append(
                 LuciObject.issuedCouponDetails({revokeType: v}))
     return couponsToBeInvalidated
Exemplo n.º 2
0
    def invalidateCouponAndAssertions(self,
                                      couponSeriesId,
                                      couponCode=None,
                                      numRevoked=1,
                                      couponSeriesInfo=[True, False]):
        if couponSeriesInfo[0]:
            invalidateCouponRequest = LuciObject.invalidateCouponRequest(
                {'couponSeriesId': couponSeriesId})
        else:
            couponsToBeInvalidated = [
                LuciObject.issuedCouponDetails({
                    'couponCode': couponCode,
                    'issuedTo': self.userId
                })
            ]
            invalidateCouponRequest = LuciObject.invalidateCouponRequest({
                'couponSeriesId':
                couponSeriesId,
                'couponsToBeInvalidated':
                couponsToBeInvalidated
            })

        Assertion.constructAssertion(
            self.connObj.invalidateCoupons(invalidateCouponRequest) == True,
            'Requested Coupon codes are revoked')
        revokedCount = LuciDBHelper.getCouponsCreated_Count(
            couponSeriesId, not couponSeriesInfo[0])
        if 'GENERIC' not in couponSeriesInfo:
            Assertion.constructAssertion(
                revokedCount != 0,
                'Coupons code marked as invalid in coupons_created')
        Assertion.constructAssertion(
            LuciDBHelper.getCouponsIssued_Count(couponSeriesId,
                                                0) == numRevoked,
            'Revoked the Issued coupon code')
        queueSize = (self.connObj.getQueueSize(constant.config['orgId'],
                                               couponSeriesId,
                                               constant.config['requestId']))
        if True in couponSeriesInfo:
            Assertion.constructAssertion(
                queueSize == 0,
                'Revoked Coupons Cleared from Queue Actual: {}'.format(
                    queueSize))
        else:
            Assertion.constructAssertion(
                queueSize != 0,
                'Coupon Series not revoked from Queue Actual: {}'.format(
                    queueSize))