Beispiel #1
0
 def test_LUCI_CF_018(self, description, couponConfig, claimObject,
                      validTillDay):
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
         self, couponConfig)
     LuciHelper.claimCouponSeries(self, couponSeriesId, claimObject)
     couponConfigObj = LuciHelper.getCouponConfigAndAssertion(
         self, couponSeriesId, 0, 0)
     Assertion.constructAssertion(
         long(couponConfigObj['ownerValidity']) > 0,
         'Owner Validity is set Actual: {}'.format(
             couponConfigObj['ownerValidity']))
     couponConfigObj.update({
         'valid_till_date':
         Utils.getTime(days=validTillDay, milliSeconds=True),
         'ownerValidity':
         Utils.getTime(days=validTillDay, milliSeconds=True)
     })
     LuciHelper.saveCouponConfigAndAssertions(self, couponConfigObj)
     couponConfigObj = LuciHelper.getCouponConfigAndAssertion(
         self, couponSeriesId, 0, 0)
     Assertion.constructAssertion(
         long(couponConfigObj['valid_till_date']) > 0,
         'valid_till_date is set Actual: {}'.format(
             couponConfigObj['valid_till_date']))
     Assertion.constructAssertion(
         long(couponConfigObj['ownerValidity']) > 0,
         'Owner Validity is set Actual: {}'.format(
             couponConfigObj['ownerValidity']))
 def test_LUCI_RC_DCP_019(self,description):
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self,)
     LuciHelper.queuePumpWait(self, couponSeriesId)
     LuciHelper.couponPumpAssertion(self, couponSeriesId)
     couponCode = LuciHelper.issueCouponAndAssertions(self, couponSeriesId)[0]
     LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode, isRedeem=False)
     LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 0)
 def test_LUCI_RC_DCP_018_sanity(self, description):
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
         self,
         couponConfigReq={
             'client_handling_type': 'DISC_CODE_PIN',
             'multiple_use': True,
             'same_user_multiple_redeem': True,
             'do_not_resend_existing_voucher': True,
             'allow_multiple_vouchers_per_user': True,
             'max_redemptions_in_series_per_user': 2
         })
     couponCode = LuciHelper.uploadCouponAndAssertions(
         self, couponSeriesId,
         self.constructObj.importType['NONE'])['coupons'][0]
     LuciHelper.issueCouponAndAssertions(self, couponSeriesId)
     LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode)
     couponDetails = LuciHelper.redeemCouponAndAssertions(self,
                                                          couponSeriesId,
                                                          couponCode,
                                                          isRedeem=False)
     CouponRedemptionCount = couponDetails['redemptionCountDetails'][
         0].__dict__
     Assertion.constructAssertion(
         CouponRedemptionCount['redemptionCount'] == 1,
         'Coupon Redemption Count Actual: {} and Expected: {}'.format(
             CouponRedemptionCount['redemptionCount'], 1))
     Assertion.constructAssertion(
         CouponRedemptionCount['userId'] == self.userId,
         'Redemption userId Actual: {} and Expected: {}'.format(
             CouponRedemptionCount['userId'], self.userId))
     LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 1)
Beispiel #4
0
 def test_LUCI_CF_007(self, description):
     try:
         couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
             self)
         LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 0, 0)
         getAllCouponConfig = self.connObj.getAllCouponConfigurations(
             LuciObject.getAllCouponConfigRequest(
                 {'couponSeriesIds': [couponSeriesId]}))[0].__dict__
         Assertion.constructAssertion(
             'owned_by' in getAllCouponConfig,
             'Getting Details Owned by in CouponConfig')
         Assertion.constructAssertion(
             'owner_id' in getAllCouponConfig,
             'Getting Details Owner id in CouponConfig')
     except Exception, luciExp:
         luciExp = luciExp.__dict__
         Assertion.constructAssertion(
             luciExp['errorCode'] == constant.INVALID_INPUT,
             'Luci Exception error code Actual: {} and Expected: {}'.format(
                 luciExp['errorCode'], constant.INVALID_INPUT))
         Assertion.constructAssertion(
             luciExp['errorMsg'] ==
             'owned by should be outbound when series type is campaign',
             'Luci Exception Error Msg Actual : {}'.format(
                 luciExp['errorMsg']))
    def test_LUCI_SCC_031_sanity(self, description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self)
        LuciHelper.queuePumpWait(self, couponSeriesId)
        createdCouponCount = LuciDBHelper.getCouponsCreated_Count(
            couponSeriesId)
        Assertion.constructAssertion(createdCouponCount != 0,
                                     'Coupon Code Pumped to Queue')
        couponConfigObj.update(
            {'description': 'luci testing description changed'})
        couponConfigObj = LuciHelper.saveCouponConfigAndAssertions(
            self, couponConfigObj)[0]
        couponCode = LuciHelper.issueCouponAndAssertions(self,
                                                         couponSeriesId)[0]
        LuciHelper.redeemCouponAndAssertions(self, [couponSeriesId],
                                             [couponCode])
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 1)

        #Changing client-handling-type
        couponConfigObj.update({'client_handling_type': 'DISC_CODE_PIN'})
        LuciHelper.saveCouponConfigAndAssertions(self, couponConfigObj)
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 1)
        time.sleep(2)
        createdCouponCount = LuciDBHelper.getCouponsCreated_Count(
            couponSeriesId, 1)
        Assertion.constructAssertion(
            createdCouponCount == 0,
            'Config changed as DC to DCP and Coupon codes marked as invalid ')
Beispiel #6
0
 def test_LUCI_UC_05(self, description, uploadType, expectedErrorMsg):
     #Save Coupon Config
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'client_handling_type': 'DISC_CODE'})
     response = LuciHelper.uploadCouponAndAssertions(self,couponSeriesId, self.constructObj.importType[uploadType],self.userId, noOfCouponsToBeUpload=2, dracraysUpload={'errorCount' : 1, 'userOnly' : True, 'invalidCase' : [False, True]})
     for errorMsg in response['errors']:
         Assertion.constructAssertion(errorMsg['ErrorMsg'] == expectedErrorMsg, 'Error Message is Mismatch Actual : {} and Expected: {}'.format(errorMsg['ErrorMsg'], expectedErrorMsg))
     LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId,2,0)
Beispiel #7
0
    def test_MULTI_INSTANCE_SCC_UCC_GCC_001(self, description):
        Logger.log('starting test_SCC_UCC_GCC_01_MULTI_INSTANCE execution')
        if not LuciHelper.verifyLuciServicesCount(2):
            pytest.skip("test requires minimum of 2 luci services running")

        self.connObj = LuciHelper.getFirstConn(newConnection=True)
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self)

        time.sleep(2)
        # update coupon config after some time on second server
        self.connObj = LuciHelper.getSecondConn(newConnection=True)
        dat = datetime.datetime.now() + datetime.timedelta(days=3)
        owner_validity = int(time.mktime(dat.timetuple()) * 1e3)
        couponConfigObj.update({
            'alphaNumeric': False,
            'shortCodeLength': 4,
            'ownerValidity': owner_validity,
            'max_vouchers_per_user': 5
        })
        LuciHelper.saveCouponConfigAndAssertions(self, couponConfigObj)

        # get updated coupon config on second server
        config1 = LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId)
        Assertion.constructAssertion(config1['alphaNumeric'] is False,
                                     'alphanumeric config key updated')
        Assertion.constructAssertion(config1['shortCodeLength'] == 4,
                                     'short code length updated')
        Assertion.constructAssertion(
            config1['ownerValidity'] == owner_validity,
            'owner validity is updated')
        Assertion.constructAssertion(config1['max_vouchers_per_user'] == 5,
                                     'max voucher per user is updated')

        # wait for coupon config to change on first server
        self.connObj = LuciHelper.getFirstConn(newConnection=True)
        configChanged = False
        config2 = None
        for _ in range(7):
            config2 = LuciHelper.getCouponConfigAndAssertion(
                self, couponSeriesId)
            if config2['alphaNumeric'] is not None:
                configChanged = True
                break
            time.sleep(10)

        if configChanged is True:
            Assertion.constructAssertion(config2['alphaNumeric'] is False,
                                         'alphanumeric config key updated')
            Assertion.constructAssertion(config2['shortCodeLength'] == 4,
                                         'short code length updated')
            Assertion.constructAssertion(
                config2['ownerValidity'] == owner_validity,
                'owner validity is updated')
            Assertion.constructAssertion(config2['max_vouchers_per_user'] == 5,
                                         'max voucher per user is updated')
        else:
            Assertion.constructAssertion(
                False, 'Coupon config is not updated in second server')
Beispiel #8
0
 def test_LUCI_UC_03(self, description, couponConfig, expectedErrorMsg):
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq=couponConfig)
     LuciHelper.uploadCouponAndAssertions(self, couponSeriesId, self.constructObj.importType['USER_ID'], self.userId, noOfCouponsToBeUpload=1)
     for uploadType in self.uploadTypeList:
         response = LuciHelper.uploadCouponAndAssertions(self,couponSeriesId, self.constructObj.importType[uploadType],self.userId, noOfCouponsToBeUpload=1, dracraysUpload={'errorCount' : 1})
         for errorMsg in response['errors']:
             Assertion.constructAssertion(errorMsg['ErrorMsg'] == expectedErrorMsg, 'Error Message is Mismatch Actual : {} and Expected: {}'.format(errorMsg['ErrorMsg'], expectedErrorMsg))
             Assertion.constructAssertion(errorMsg['UserId'] == self.userId, 'UserId is Mismatch Actual : {} and Expected: {}'.format(errorMsg['UserId'], self.userId))
     LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId,1,0)
Beispiel #9
0
 def test_LUCI_UC_02_sanity(self, description, uploadType):
     #Save Coupon Config
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'client_handling_type': 'DISC_CODE_PIN'})
     # upload coupon Code to user1
     response = LuciHelper.uploadCouponAndAssertions(self,couponSeriesId, self.constructObj.importType[uploadType],self.userId, noOfCouponsToBeUpload=2, dracraysUpload={'errorCount' : 2, 'invalidCase' : [True, False]})
     for errorMsg in response['errors']:
         Assertion.constructAssertion(errorMsg['ErrorMsg'] == 'duplicate users provided in the same file', 'Error Message is Mismatch Actual : {} and Expected: {}'.format(errorMsg['ErrorMsg'], 'duplicate users provided in the same file'))
         Assertion.constructAssertion(errorMsg['UserId'] == self.userId, 'UserId is Mismatch Actual : {} and Expected: {}'.format(errorMsg['UserId'], self.userId))
     LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId,1,0)
 def test_LUCI_RSD_001(self, description, couponConfig):
     couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
         self, couponConfig)[1]
     couponCode = LuciHelper.issueCouponAndAssertions(self,
                                                      couponSeriesId)[0]
     LuciHelper.getCouponConfigAndAssertion(self,
                                            couponSeriesId,
                                            no_issued=1)
     LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode)
     LuciHelper.redemptionDBAssertion(self, couponSeriesId, numRedeemed=1)
Beispiel #11
0
    def test_LUCI_UC_09(self, description, uploadType, expectedErrorMsg):
        #Save Coupon Config
        mutualCouponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'client_handling_type': 'DISC_CODE_PIN'})[1]

        LuciHelper.uploadCouponAndAssertions(self,mutualCouponSeriesId, self.constructObj.importType[uploadType],self.userId, noOfCouponsToBeUpload=2)
        LuciHelper.getCouponConfigAndAssertion(self,mutualCouponSeriesId,2,0)
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'client_handling_type': 'DISC_CODE_PIN', 'mutual_exclusive_series_ids' : '[' + str(mutualCouponSeriesId) + ']'})
        response = LuciHelper.uploadCouponAndAssertions(self, couponSeriesId, self.constructObj.importType[uploadType], self.userId, noOfCouponsToBeUpload=2, dracraysUpload={'errorCount': 2})
        for errorMsg in response['errors']:
            Assertion.constructAssertion(errorMsg['ErrorMsg'] == expectedErrorMsg, 'Error Message is Mismatch Actual : {} and Expected: {}'.format(errorMsg['ErrorMsg'], expectedErrorMsg))
Beispiel #12
0
 def test_LUCI_UC_01(self,description, couponConfig, uploadType, dracarysUploadInput):
     #Save Coupon Config
     for i in range(5):
         self.userIds.append(constant.config['usersInfo'][i]['userId'])
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self)
     time.sleep(2)
     couponCodeList = LuciHelper.uploadCouponAndAssertions(self,couponSeriesId, self.constructObj.importType[uploadType],noOfCouponsToBeUpload=5, dracraysUpload=dracarysUploadInput)['coupons']
     Logger.log('Coupon Code list : ', couponCodeList)
     for couponCode, self.userId in zip(couponCodeList,self.userIds):
         LuciHelper.getCouponDetailsAndAssertion(self,couponSeriesId,couponCode, couponDetailsRequest={'onlyActive': True, 'couponCodeFilter': [couponCode]})
     LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId,5,0)
Beispiel #13
0
 def test_LUCI_UC_04(self, description, uploadType):
     #Save Coupon Config
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'client_handling_type': 'DISC_CODE_PIN'})
     # upload coupon Code to user1
     response = LuciHelper.uploadCouponAndAssertions(self,couponSeriesId, self.constructObj.importType[uploadType],self.userId, noOfCouponsToBeUpload=2, dracraysUpload={'errorCount' : 2, 'invalidCase' : [True, False]})
     for errorMsg in response['errors']:
         Assertion.constructAssertion(errorMsg['ErrorMsg'] == 'duplicate coupons provided in the same file', 'Error Message is Mismatch Actual : {} and Expected: {}'.format(errorMsg['ErrorMsg'], 'duplicate coupons provided in the same file'))
     LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId,0,0)
     createdCouponCount = LuciDBHelper.getCouponsCreated_Count(couponSeriesId, 1)
     Assertion.constructAssertion(createdCouponCount == 1, 'Uploaded coupons are recorded in coupons_created');
     Assertion.constructAssertion(self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 1, 'Coupon Code Pumped to Queue')
 def test_LUCI_RSD_007(self, description, couponConfig):
     couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
         self, couponConfig)[1]
     couponCode, couponDetails = LuciHelper.issueCouponAndAssertions(
         self, couponSeriesId)
     changeDate = Utils.getTime(days=-1, hours=-2, milliSeconds=True)
     self.connObj.changeCouponIssuedDate(couponDetails['id'], changeDate)
     LuciHelper.getCouponConfigAndAssertion(self,
                                            couponSeriesId,
                                            no_issued=1)
     LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode)
     LuciHelper.redemptionDBAssertion(self, couponSeriesId, numRedeemed=1)
    def test_LUCI_RC_DCP_013(self, description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self,
            couponConfigReq={
                'client_handling_type': 'DISC_CODE_PIN',
                'multiple_use': True,
                'any_user': True
            })
        couponCode = LuciHelper.uploadCouponAndAssertions(
            self, couponSeriesId,
            self.constructObj.importType['NONE'])['coupons'][0]

        #issueCode and Doing Assertion.constructAssertion(on)
        LuciHelper.issueCouponAndAssertions(self, couponSeriesId)
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 0)
        LuciHelper.getCouponDetailsAndAssertion(self,
                                                couponSeriesId,
                                                couponCode,
                                                couponDetailsRequest={
                                                    'onlyActive':
                                                    True,
                                                    'couponCodeFilter':
                                                    [couponCode]
                                                })
        #Coupon Redemption
        redeemedIds = [self.userId]
        LuciHelper.redeemCouponAndAssertions(
            self,
            couponSeriesId,
            couponCode,
            couponIssuedTo=[constant.config['usersInfo'][0]['userId']])
        self.userId = constant.config['usersInfo'][1]['userId']
        redeemedIds.append(self.userId)
        LuciHelper.redeemCouponAndAssertions(
            self,
            couponSeriesId,
            couponCode,
            couponIssuedTo=[constant.config['usersInfo'][0]['userId']])
        self.userId = constant.config['usersInfo'][2]['userId']
        redeemedIds.append(self.userId)
        LuciHelper.redeemCouponAndAssertions(
            self,
            couponSeriesId,
            couponCode,
            couponIssuedTo=[constant.config['usersInfo'][0]['userId']])
        LuciHelper.redemptionDBAssertion(self,
                                         couponSeriesId,
                                         numRedeemed=3,
                                         redeemedBy=redeemedIds)
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 3)
 def test_LUCI_RC_DC_012_sanity(self,description):
     #Save Coupon Config
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self)
     LuciHelper.queuePumpWait(self, couponSeriesId)
     LuciHelper.couponPumpAssertion(self, couponSeriesId)
     # issue coupon Code
     couponCode = LuciHelper.issueCouponAndAssertions(self,couponSeriesId)[0]
     # CouponConfigAssertion
     LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId, 1, 0)
     # redeem Coupon and Assertion.constructAssertion(on)
     LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode)
     LuciHelper.redemptionDBAssertion(self, couponSeriesId)
     LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId, 1, 1)
     # GetCoupon Details and Assertion.constructAssertion(on)
     couponDetailsRequest = {'onlyActive': True, 'couponCodeFilter': [couponCode]}
     LuciHelper.getCouponDetailsAndAssertion(self,couponSeriesId,couponCode,couponDetailsRequest)
Beispiel #17
0
 def test_LUCI_CF_013(self, description, couponConfig, expected):
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
         self, couponConfig)
     ownedInfo = LuciDBHelper.getOwnerInfo(couponSeriesId)
     Assertion.constructAssertion(
         ownedInfo['owned_by'] == expected[0],
         'Owned by Actual: {} and Expected: {}'.format(
             ownedInfo['owned_by'], expected[0]))
     if couponConfigObj['series_type'] in [
             'OUTBOUND', 'LOYALTY'
     ] or couponConfigObj['owned_by'] in [2, 1]:
         Assertion.constructAssertion(
             ownedInfo['owner_id'] == expected[1],
             'Owner Id Actual: {} and Expected: {}'.format(
                 ownedInfo['owner_id'], expected[1]))
     discount_upto = LuciDBHelper.getCouponConfigKeyValues(
         couponSeriesId, 4)
     Assertion.constructAssertion(
         discount_upto == expected[2],
         'Discount upto Actual: {} and Expected: {}'.format(
             discount_upto, expected[2]))
     getCouponConfig = LuciHelper.getCouponConfigAndAssertion(
         self, couponSeriesId, 0, 0)
     Assertion.constructAssertion(
         getCouponConfig['discount_upto'] == couponConfig['discount_upto'],
         'Discount upto value set Actual {} and Expected : {}'.format(
             getCouponConfig['discount_upto'],
             couponConfig['discount_upto']))
 def test_LUCI_RSD_002(self, description, couponConfig):
     couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
         self, couponConfig)[1]
     couponCode = LuciHelper.issueCouponAndAssertions(self,
                                                      couponSeriesId)[0]
     LuciHelper.getCouponConfigAndAssertion(self,
                                            couponSeriesId,
                                            no_issued=1)
     LuciHelper.redeemCouponAndAssertions(
         self,
         couponSeriesId,
         couponCode,
         error=[
             constant.REDEMPTION_VALIDITY_DATE_NOT_REACHED,
             'event date is lesser than redemption validity date'
         ])
    def test_LUCI_RC_DC_011_sanity(self, description, uploadType):
        #Save Coupon Config
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self)
        time.sleep(2)
        createdCouponCount = LuciDBHelper.getCouponsCreated_Count(couponSeriesId)
        Assertion.constructAssertion(createdCouponCount != 0, 'Coupon Code Pumped to Queue')

        couponCode = LuciHelper.uploadCouponAndAssertions(self,couponSeriesId,self.constructObj.importType[uploadType],dracraysUpload={'userOnly' : True})['coupons'][0]
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 0)

        LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode)
        LuciHelper.redemptionDBAssertion(self, couponSeriesId)

        couponDetailsRequest = {'onlyActive': True, 'couponCodeFilter': [couponCode]}
        LuciHelper.getCouponDetailsAndAssertion(self,couponSeriesId,couponCode,couponDetailsRequest)
        couponDetailsRequest.update({'couponSeriesRequired' : True})
        LuciHelper.getCouponDetailsAndAssertion(self,couponSeriesId,couponCode,couponDetailsRequest)
Beispiel #20
0
    def test_LUCI_EI_011_sanity_smoke(self, description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self,
            couponConfigReq={
                'client_handling_type': 'DISC_CODE_PIN',
                'any_user': True,
                'isExternalIssual': True
            })
        Assertion.constructAssertion(
            LuciDBHelper.isExternalCouponSeries(couponSeriesId),
            'Client handling type isExternal Enabled for coupon series id: {}'.
            format(couponSeriesId))
        #Checking Queue Count
        Assertion.constructAssertion(
            self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId,
                                      constant.config['requestId']) == 0,
            'Coupon codes are cleared from queue')

        couponCode = LuciHelper.uploadCouponAndAssertions(
            self, couponSeriesId,
            self.constructObj.importType['NONE'])['coupons'][0]

        #CouponDetails Request
        couponDetailsRequest = {
            'onlyActive': True,
            'couponCodeFilter': [couponCode]
        }
        self.userId = -1
        LuciHelper.getCouponDetailsAndAssertion(self, couponSeriesId,
                                                couponCode,
                                                couponDetailsRequest)
        LuciHelper.issuedCouponsDBAssertion(self, couponSeriesId, couponCode)

        self.userId = constant.config['usersInfo'][0]['userId']

        LuciHelper.redeemCouponAndAssertions(self,
                                             couponSeriesId,
                                             couponCode,
                                             couponIssuedTo=[-1])
        LuciHelper.redemptionDBAssertion(self, couponSeriesId)
        #Get Coupon Configuration
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 1)
    def test_LUCI_RC_DC_014(self,description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'multiple_use' : True, 'any_user' : True})
        LuciHelper.queuePumpWait(self, couponSeriesId)
        LuciHelper.couponPumpAssertion(self, couponSeriesId)

        #issueCode and Doing Assertion.constructAssertion(on)
        couponCode = LuciHelper.issueCouponAndAssertions(self, couponSeriesId)[0]
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 0)
        LuciHelper.getCouponDetailsAndAssertion(self,couponSeriesId,couponCode, couponDetailsRequest={'onlyActive': True, 'couponCodeFilter': [couponCode]})
        #Coupon Redemption
        redeemedIds = [self.userId]
        LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode, couponIssuedTo=[constant.config['usersInfo'][0]['userId']])
        self.userId = constant.config['usersInfo'][1]['userId']
        redeemedIds.append(self.userId)
        LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode, couponIssuedTo=[constant.config['usersInfo'][0]['userId']])
        self.userId = constant.config['usersInfo'][2]['userId']
        redeemedIds.append(self.userId)
        LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode, couponIssuedTo=[constant.config['usersInfo'][0]['userId']])
        LuciHelper.redemptionDBAssertion(self,couponSeriesId, numRedeemed=3, redeemedBy=redeemedIds)
        LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId,1,3)
Beispiel #22
0
 def test_LUCI_GCC_007(self, description):
     couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self)[1]
     couponCode, couponDetailsFirst = LuciHelper.issueCouponAndAssertions(self,couponSeriesId)
     redeemDetailsFirst = LuciHelper.redeemCouponAndAssertions(self,couponSeriesId,couponCode)
     time.sleep(5)
     self.userId = constant.config['usersInfo'][1]['userId']
     couponCode, couponDetailsLatest = LuciHelper.issueCouponAndAssertions(self,couponSeriesId)
     redeemDetailsLatest = LuciHelper.redeemCouponAndAssertions(self,couponSeriesId,couponCode)
     config = LuciHelper.getCouponConfigAndAssertion(self,couponSeriesId,2,2)
     Assertion.constructAssertion(couponDetailsFirst['issuedDate'] != config['latestIssualTime'], 'Latest issual time is mismatch ' )
     Assertion.constructAssertion(redeemDetailsFirst['redemptionDate'] != config['latestRedemptionTime'], 'Latest redemption time is mismatch' )
     Assertion.constructAssertion(couponDetailsLatest['issuedDate'] == config['latestIssualTime'], 'Latest issual time in getCouponConfig' )
     Assertion.constructAssertion(redeemDetailsLatest['redemptionDate'] == config['latestRedemptionTime'], 'Latest redemption time in getCouponConfig' )
Beispiel #23
0
    def test_IC_RC_010_PERF(self, description, number_of_runs,
                            number_of_threads, simultaneous_issue_redeem):
        Logger.log('starting tc execution')
        self.number_of_runs = number_of_runs
        self.issue_pool = ThreadPool(number_of_threads)
        self.redeem_pool = ThreadPool(number_of_threads)
        self.initialize()

        # Save Coupon Config
        coupon_config_obj, self.coupon_series_id = LuciHelper.saveCouponConfigAndAssertions(
            self)
        time.sleep(2)

        print_stats_thread = threading.Thread(target=self.scheduler,
                                              name="print stats thread",
                                              args=('print_stats', ))
        print_stats_thread.start()

        redeem_thread = threading.Thread(target=self.scheduler,
                                         name="redeem coupons thread",
                                         args=('redeem_coupons', ))
        if simultaneous_issue_redeem:
            redeem_thread.start()

        func = partial(self.issue_coupon, self.coupon_series_id)
        self.issue_pool.map(func, self.user_id)

        if not simultaneous_issue_redeem:
            redeem_thread.start()
        redeem_thread.join()

        LuciHelper.getCouponConfigAndAssertion(
            self,
            couponSeriesId=self.coupon_series_id,
            no_issued=self.number_of_runs,
            no_redeemed=self.number_of_runs)

        self.print_details()
        Logger.log('All done!!!')
    def test_LUCI_RC_DCP_011_sanity_smoke(self, description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self,
            couponConfigReq={
                'client_handling_type': 'DISC_CODE_PIN',
                'max_redeem': 10
            })

        #upload the coupon code
        couponCode = LuciHelper.uploadCouponAndAssertions(
            self, couponSeriesId,
            self.constructObj.importType['NONE'])['coupons'][0]
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 0, 0)

        #Check in issued table
        couponIssuedList = LuciDBHelper.getCouponsIssuedList(couponSeriesId)
        Assertion.constructAssertion(
            couponIssuedList == [], 'Issued Coupon recorded in coupons_issued')

        #Checking Queue count and coupons_created count once update DC -> DCP
        couponsCreatedList = LuciDBHelper.getCouponsCreated(couponSeriesId)
        Assertion.constructAssertion(
            couponsCreatedList != [],
            'Uploaded Coupons Added in Coupons_created table')
        Assertion.constructAssertion(
            len(couponsCreatedList) == 1,
            'Uploaded Coupon recorded in DB, Actual: {} and Expected : {}'.
            format(len(couponsCreatedList), 1))
        Assertion.constructAssertion(
            couponsCreatedList[0]['couponCode'] == couponCode,
            'Uploaded Coupon Code, Actual : {} and Expected : {}'.format(
                couponsCreatedList[0]['couponCode'], couponCode))

        #issueCode and Doing Assertion.constructAssertion(on)
        LuciHelper.issueCouponAndAssertions(self, couponSeriesId)[0]
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 0)
        # CouponDetails Request
        LuciHelper.getCouponDetailsAndAssertion(self,
                                                couponSeriesId,
                                                couponCode,
                                                couponDetailsRequest={
                                                    'onlyActive':
                                                    True,
                                                    'couponCodeFilter':
                                                    [couponCode]
                                                })
        #Coupon Redemption
        LuciHelper.redeemCouponAndAssertions(self,
                                             couponSeriesId,
                                             couponCode,
                                             isMaxRedeemSet=True)

        LuciHelper.redemptionDBAssertion(self, couponSeriesId)
        # Get Coupon Configuration
        LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 1, 1)
Beispiel #25
0
 def test_LUCI_CF_016(self, description, couponConfig, claimObject):
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
         self, couponConfig)
     LuciHelper.claimCouponSeries(self, couponSeriesId, claimObject)
     LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 0, 0,
                                            {'ownedBy': claimObject[0]})
     LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 0, 0,
                                            {'ownerId': claimObject[1]})
     LuciHelper.getCouponConfigAndAssertion(self, couponSeriesId, 0, 0, {
         'ownedBy': claimObject[0],
         'ownerId': claimObject[1]
     })
Beispiel #26
0
 def test_LUCI_CF_014(self, description, couponConfig, expected):
     couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
         self, couponConfig)
     Assertion.constructAssertion(
         couponConfigObj['redemption_org_entity_type'] ==
         couponConfig['redemption_org_entity_type'],
         'Redemption Org Entity Type in API call Actual {} and Expected : {}'
         .format(couponConfigObj['redemption_org_entity_type'],
                 couponConfig['redemption_org_entity_type']))
     redemptionEntityType = LuciDBHelper.getCouponConfigKeyValues(
         couponSeriesId, 3)
     Assertion.constructAssertion(
         redemptionEntityType == expected[0],
         'Redemption Org Entity Type in DB Actual: {} and Expected: {}'.
         format(redemptionEntityType, expected[0]))
     getCouponConfig = LuciHelper.getCouponConfigAndAssertion(
         self, couponSeriesId, 0, 0)
     Assertion.constructAssertion(
         getCouponConfig['redemption_org_entity_type'] ==
         couponConfig['redemption_org_entity_type'],
         'Redemption Org Entity Type in GetCouponConfig Actual {} and Expected : {}'
         .format(getCouponConfig['redemption_org_entity_type'],
                 couponConfig['redemption_org_entity_type']))
Beispiel #27
0
    def test_MULTI_INSTANCE_SCC_IC_CS_002(self, description):
        Logger.log('starting test_SCC_IC_CS_002_MULTI_INSTANCE execution')
        if not LuciHelper.verifyLuciServicesCount(2):
            pytest.skip("test requires minimum of 2 luci services running")

        self.connObj = LuciHelper.getFirstConn(newConnection=True)
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self)

        self.connObj = LuciHelper.getSecondConn(newConnection=True)
        userId = random.randint(1111111, 9999999)
        issueCouponObj = {
            'couponSeriesId': couponSeriesId,
            'storeUnitId': self.tillId,
            'userId': userId
        }
        issueCouponRequest = LuciObject.issueCouponRequest(issueCouponObj)
        coupon_details = self.connObj.issueCoupon(issueCouponRequest).__dict__
        Assertion.constructAssertion(coupon_details['couponCode'] is not None,
                                     'Coupon code is not null')

        time.sleep(2)
        # update coupon config on second server
        dat = datetime.datetime.now() + datetime.timedelta(days=3)
        owner_validity = int(time.mktime(dat.timetuple()) * 1e3)
        couponConfigObj.update({
            'alphaNumeric': False,
            'shortCodeLength': 4,
            'ownerValidity': owner_validity,
            'max_vouchers_per_user': 5
        })
        LuciHelper.saveCouponConfigAndAssertions(self, couponConfigObj)
        config1 = LuciHelper.getCouponConfigAndAssertion(self,
                                                         couponSeriesId,
                                                         no_issued=1)
        Assertion.constructAssertion(config1['alphaNumeric'] is False,
                                     'alphanumeric config key updated')
        Assertion.constructAssertion(config1['shortCodeLength'] == 4,
                                     'short code length updated')
        Assertion.constructAssertion(
            config1['ownerValidity'] == owner_validity,
            'owner validity is updated')
        Assertion.constructAssertion(config1['max_vouchers_per_user'] == 5,
                                     'max voucher per user is updated')

        self.connObj = LuciHelper.getFirstConn(newConnection=True)
        couponSearchRequest = {
            'couponSeriesIds': [couponSeriesId],
            'customerIds': [userId],
            'couponSeriesRequired': True
        }

        couponDetailsList = None
        for _ in range(7):
            couponDetailsResponse = self.connObj.couponSearch(
                LuciObject.couponSearchRequest(couponSearchRequest)).__dict__
            couponDetailsList = couponDetailsResponse['coupons']
            if len(couponDetailsList) == 1 and vars(
                    vars(couponDetailsResponse['coupons'][0])
                ['couponSeries'])['alphaNumeric'] is not None:
                break
            time.sleep(10)

        Assertion.constructAssertion(
            len(couponDetailsList) == 1,
            'Coupon Details list, Actual  {} and Expected 1'.format(
                len(couponDetailsList)))

        for i in range(len(couponDetailsList)):
            couponDetails = couponDetailsList[i].__dict__
            Assertion.constructAssertion(
                vars(couponDetails['couponSeries'])['alphaNumeric'] is False,
                'alphanumeric config key updated')
            Assertion.constructAssertion(
                vars(couponDetails['couponSeries'])['shortCodeLength'] == 4,
                'short code length updated')
            Assertion.constructAssertion(
                vars(couponDetails['couponSeries'])['ownerValidity'] ==
                owner_validity, 'owner validity is updated')
            Assertion.constructAssertion(
                vars(couponDetails['couponSeries'])['max_vouchers_per_user'] ==
                5, 'max voucher per user is updated')