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_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_IC_DCP_012(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self) LuciHelper.queuePumpWait(self, couponSeriesId) # Checking Coupon Created Count createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion(createdCouponCount != 0, 'Coupon Code Pumped to Queue') Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) != 0, 'Coupon Code Pumped to Queue') #Update the coupon series from DC -> DCP couponConfigObj.update({'client_handling_type': 'DISC_CODE_PIN'}) LuciHelper.saveCouponConfigAndAssertions( self, couponConfigReq=couponConfigObj) #Checking Queue count and coupons_created count once update DC -> DCP time.sleep(2) createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion(createdCouponCount == 0, 'Disc Code Marked as Invalid') Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 0, 'Coupon codes are cleared from queue') # upload the coupon code LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE']) # Checking Coupon Count once DCP uploaded +1 time.sleep(2) 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') LuciHelper.issueCouponAndAssertions(self, couponSeriesId) luciExp = LuciHelper.issueCouponAndAssertions( self, couponSeriesId, {'userId': constant.config['usersInfo'][1]['userId']}, expectException=True) Assertion.constructAssertion( luciExp['errorCode'] == constant.COUPONS_EXHAUSTED, 'Luci Exception error code Actual: {} and Expected: {}'.format( luciExp['errorCode'], constant.COUPONS_EXHAUSTED)) Assertion.constructAssertion( luciExp['errorMsg'] == 'coupons exhausted', 'Luci Exception Error Msg Actual : {}'.format(luciExp['errorMsg']))
def test_LUCI_RSC_002(self, description, config): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, config) LuciHelper.queuePumpWait(self, couponSeriesId) # Issue Coupon Code couponCode = LuciHelper.issueCouponAndAssertions(self, couponSeriesId)[0] resendRequest = LuciObject.resendCouponRequest({ 'storeUnitId': self.tillId, 'eventTimeInMillis': Utils.getTime(milliSeconds=True), 'couponCode': couponCode, 'userId': self.userId }) couponDetails = self.connObj.resendCoupon(resendRequest).__dict__ Assertion.constructAssertion( couponCode == couponDetails['couponCode'], 'Resend Coupon Code Actual: {} and Expected: {}'.format( couponCode, couponDetails['couponCode'])) Assertion.constructAssertion( couponDetails['ex'] == None, 'Resend Coupon No exception occurred : {}'.format( couponDetails['ex']))
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_IMC_DCP_019(self, description, invalidInput, expected): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, {'client_handling_type': 'DISC_CODE_PIN'}) # upload the coupon code LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE']) if invalidInput == None: invalidInput = { 'userIds': [ constant.config['usersInfo'][0]['userId'], constant.config['usersInfo'][0]['userId'] ] } expected[1] = expected[1].format( constant.config['usersInfo'][0]['userId']) try: LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds, issueCouponParamObj=invalidInput) except Exception, luciExp: Logger.log('Exception : ', luciExp) luciExp = luciExp.__dict__ Assertion.constructAssertion( luciExp['errorCode'] == expected[0], 'Luci Exception error code Actual: {} and Expected: {}'.format( luciExp['errorCode'], expected[0])) Assertion.constructAssertion( luciExp['errorMsg'] == expected[1], 'Luci Exception Error Msg Actual : {}'.format( luciExp['errorMsg']))
def test_LUCI_IMC_DCP_014(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, { 'client_handling_type': 'DISC_CODE_PIN', 'do_not_resend_existing_voucher': True, 'allow_multiple_vouchers_per_user': True, 'max_vouchers_per_user': 2 }) LuciHelper.couponPumpAssertion(self, couponSeriesId, isDiscCode=False) # upload the coupon code LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE'], noOfCouponsToBeUpload=20) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) maxCouponLimitExceed = LuciHelper.issueMultipleCoupon( self, couponSeriesId, self.userIds, expectResponseException=[True, 'max coupon per user exceeded']) Assertion.constructAssertion( len(maxCouponLimitExceed) == len(self.userIds), 'Max Coupon per user Exceeded with limit 2')
def test_LUCI_IC_DC_018(self, description): actualUserId = self.userId couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, {'max_create': 1}) time.sleep(2) createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion(createdCouponCount != 0, 'Coupons are created for DC') Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) != 0, 'Coupon codes pumped to queue') LuciHelper.issueCouponAndAssertions(self, couponSeriesId) self.userId = constant.config['usersInfo'][1]['userId'] luciExp = LuciHelper.issueCouponAndAssertions(self, couponSeriesId, expectException=True) Assertion.constructAssertion( luciExp['errorCode'] == constant.MAX_COUPON_ISSUAL_PER_SERIES_EXCEEDED, 'Luci Exception error code Actual: {} and Expected: {}'.format( luciExp['errorCode'], constant.MAX_COUPON_ISSUAL_PER_SERIES_EXCEEDED)) Assertion.constructAssertion( luciExp['errorMsg'] == 'max create for series exceeded', 'Luci Exception Error Msg Actual : {}'.format(luciExp['errorMsg'])) self.userId = actualUserId
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)
def test_LUCI_RC_DC_017(self,description, couponConfig, noOfRedeem): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq=couponConfig) LuciHelper.queuePumpWait(self, couponSeriesId) LuciHelper.couponPumpAssertion(self, couponSeriesId) couponCode = LuciHelper.issueCouponAndAssertions(self, couponSeriesId)[0] #Coupon Redemption for _ in range(noOfRedeem): LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode) LuciHelper.redemptionDBAssertion(self, couponSeriesId, noOfRedeem)
def test_LUCI_IMC_GC_02(self, description, couponConfig, expectedErrorMsg, sentHistoryCount): couponCode = LuciHelper.generateCouponCode() couponConfig.update({'client_handling_type' : 'GENERIC', 'genericCode' : couponCode}) couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self,couponConfigReq=couponConfig) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) exceptionList = LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds, expectResponseException=[True, expectedErrorMsg]) Assertion.constructAssertion(len(exceptionList) == len(self.userIds), 'Requested issual {}'.format(expectedErrorMsg))
def test_LUCI_IMC_GC_01(self, description): couponCode = LuciHelper.generateCouponCode() couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self,couponConfigReq={'client_handling_type' : 'GENERIC', 'genericCode' : couponCode}) LuciHelper.issueMultipleCoupon(self,couponSeriesId,self.userIds) couponIssuedList = LuciDBHelper.getCouponsIssuedList(couponSeriesId) Assertion.constructAssertion(couponIssuedList != [], 'Issued Coupon Code recorded in Coupons_issued table') Assertion.constructAssertion(len(couponIssuedList) == len(self.userIds), 'Issued Coupons are recorded in coupons_issued')
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_IMC_GC_09(self, description): couponCode = LuciHelper.generateCouponCode() couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, {'client_handling_type' : 'GENERIC', 'genericCode' : couponCode, 'do_not_resend_existing_voucher' : False, 'allow_multiple_vouchers_per_user' : False , 'valid_days_from_create' : 1}) couponDetailsList = LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) couponIssuedList = LuciDBHelper.getCouponsIssuedList(couponSeriesId) Assertion.constructAssertion(couponIssuedList != [], 'Issued Coupon Code recorded in Coupons_issued table') Assertion.constructAssertion(len(couponIssuedList) == len(self.userIds), 'Issued Coupons are recorded in coupons_issued')
def test_LUCI_GCD_038_sanity_smoke(self,description): # Save Coupon Config couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self) couponCode = LuciHelper.issueCouponAndAssertions(self,couponSeriesId)[0] # Added Issue Filter issualFilterObj = LuciObject.issualFilters({'redeemableAtStoreId': [self.storeId]}) issualFilterObj = {'issualFilters': issualFilterObj} #coupon Search and Assertion LuciHelper.couponSearchAndAssertion(self, [couponSeriesId], issualFilterObj, [couponCode])
def test_LUCI_IMC_DCP_011_sanity_smoke(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigReq={'client_handling_type': 'DISC_CODE_PIN'}) LuciHelper.couponPumpAssertion(self, couponSeriesId, False) noOfCouponUpload = 10 LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE'], noOfCouponsToBeUpload=noOfCouponUpload) time.sleep(2) LuciHelper.couponPumpAssertion( self, couponSeriesId, isDiscCode=False, DiscCodePinCouponUploaded=noOfCouponUpload) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) # Check the queue size after coupon issued Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 0, 'Coupon Queue count deducted with No. of Issued Coupons') couponIssuedList = LuciDBHelper.getCouponsIssuedList(couponSeriesId) Assertion.constructAssertion( couponIssuedList != [], 'Issued Coupon Code recorded in Coupons_issued table') Assertion.constructAssertion( len(couponIssuedList) == noOfCouponUpload, 'Issued Coupons are recorded in coupons_issued')
def test_LUCI_IC_DC_013(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self) LuciHelper.queuePumpWait(self, couponSeriesId) createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion(createdCouponCount != 0, 'Coupon codes are created for DC') Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) != 0, 'Coupon codes pumped to queue') # upload the coupon code LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['USER_ID'], issuedTo=self.userId, dracraysUpload={'userOnly': True}) LuciHelper.issueCouponAndAssertions( self, couponSeriesId, issueCouponParamObj={'storeUnitId': constant.config['adminId']}) LuciHelper.issueCouponAndAssertions( self, couponSeriesId, issueCouponParamObj={'storeUnitId': constant.config['adminId']}, couponIssuedCount=2)
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)
def test_LUCI_IC_DCP_025_sanity(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigReq={'client_handling_type': 'DISC_CODE_PIN'}) time.sleep(2) LuciHelper.couponPumpAssertion(self, couponSeriesId, isDiscCode=False) LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE']) time.sleep(2) 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') #Update Coupon series & issue coupon check queue size LuciHelper.saveCouponConfigAndAssertions( self, couponConfigReq=couponConfigObj) Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 1, 'Coupon Code Pumped to Queue') LuciHelper.issueCouponAndAssertions(self, couponSeriesId) Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 0, 'Coupon Queue count deducted with No. of Issued Coupons')
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')
def test_downloadCoupon_001_sanity(self, description): couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self)[1] couponCode = LuciHelper.issueCouponAndAssertions(self, couponSeriesId)[0] DracarysHelper.downloadCouponsRequestAndAssertion( self, couponSeriesId, self.DracarysObj.DownloadReportType['ISSUED'], [couponCode]) LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode) DracarysHelper.downloadCouponsRequestAndAssertion( self, couponSeriesId, self.DracarysObj.DownloadReportType['REDEEMED'], [couponCode])
def test_LUCI_CF_004(self, description, couponConfig, claimObject, updateClaim, expected): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfig) LuciHelper.claimCouponSeries(self, couponSeriesId, claimObject) #Re-claim with Diff owners LuciHelper.claimCouponSeries(self, couponSeriesId, updateClaim, expectedErrors=expected, claimResult=False)
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_005(self, description, couponConfig, expectedError): couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfig)[1] luciExp = LuciHelper.issueCouponAndAssertions(self, couponSeriesId, expectException=True) Assertion.constructAssertion( luciExp['errorCode'] == expectedError[0], 'Luci Exception error code Actual: {} and Expected: {}'.format( luciExp['errorCode'], expectedError[0])) Assertion.constructAssertion( luciExp['errorMsg'] == expectedError[1], 'Luci Exception Error Msg Actual : {}'.format(luciExp['errorMsg']))
def test_LUCI_IMC_GC_08(self, description): couponCode = LuciHelper.generateCouponCode() couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, {'client_handling_type' : 'GENERIC', 'genericCode' : couponCode, 'do_not_resend_existing_voucher' : False, 'allow_multiple_vouchers_per_user' : False , 'valid_days_from_create' : 1}) couponDetailsList = LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) for couponDetails in couponDetailsList: couponDetails = couponDetails.__dict__ self.connObj.changeCouponIssuedDate(couponDetails['id'], Utils.getTime(days=-2, minutes=5,milliSeconds=True)) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) couponIssuedList = LuciDBHelper.getCouponsIssuedList(couponSeriesId) Assertion.constructAssertion(couponIssuedList != [], 'Issued Coupon Code recorded in Coupons_issued table') Assertion.constructAssertion(len(couponIssuedList) == len(self.userIds), 'Issued Coupons are recorded in coupons_issued')
def test_LUCI_IC_DC_012(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self) LuciHelper.queuePumpWait(self, couponSeriesId) createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion(createdCouponCount != 0, 'Coupon codes are created for DC') Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) != 0, 'Coupon codes pumped to queue') # upload the coupon code LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['USER_ID'], issuedTo=self.userId, dracraysUpload={'userOnly': True}) couponCode = LuciHelper.issueCouponAndAssertions( self, couponSeriesId, issueCouponParamObj={'storeUnitId': constant.config['adminId']})[0] Assertion.constructAssertion(not LuciHelper.isNumeric(couponCode), 'Upload & issued Alpha-Numeric coupon') self.userId = constant.config['usersInfo'][1]['userId'] couponCode2 = LuciHelper.issueCouponAndAssertions( self, couponSeriesId, issueCouponParamObj={'storeUnitId': constant.config['adminId']})[0] Assertion.constructAssertion( len(str(couponCode2)) == int( self.orgDefaultValue['random_code_length']), 'Coupon Org Config Length is: {} Actual Coupon Lenght : {}'.format( len(str(couponCode2)), self.orgDefaultValue['random_code_length'])) if not self.orgDefaultValue['is_alpha_numeric']: Assertion.constructAssertion( LuciHelper.isNumeric(couponCode2), 'Org Config is Numeric Generated Coupon: {}'.format( couponCode2)) elif self.orgDefaultValue['is_alpha_numeric']: Assertion.constructAssertion( not LuciHelper.isNumeric(couponCode2), 'Org Config is AlphaNumeric Generated Coupon: {}'.format( couponCode2)) self.userId = constant.config['usersInfo'][0]['userId']
def test_LUCI_IMC_DCP_017(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, {'client_handling_type': 'DISC_CODE_PIN'}) LuciHelper.couponPumpAssertion(self, couponSeriesId, isDiscCode=False) exceptionList = LuciHelper.issueMultipleCoupon( self, couponSeriesId, self.userIds, expectResponseException=[True, 'coupons exhausted']) Assertion.constructAssertion( len(self.userIds) == len(exceptionList), 'Uploaded and Issued Coupons : {} and Coupon Exhausted Exception : {}' .format(len(self.userIds), len(exceptionList)))
def test_LUCI_CF_003(self, description, couponConfig, claimObject): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfig) voucherType = LuciDBHelper.getCouponSeriesType( couponSeriesId)['seriesType'] Assertion.constructAssertion( voucherType == couponConfig['series_type'], 'Coupon Series Type in voucher_series Actual : {} and Expected : {}' .format(voucherType, couponConfig['series_type'])) Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 0, 'Coupons Not Pumped to Queue') LuciHelper.claimCouponSeries(self, couponSeriesId, claimObject)
def test_LUCI_IMC_DC_016(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, { 'do_not_resend_existing_voucher': False, 'allow_multiple_vouchers_per_user': True }) LuciHelper.queuePumpWait(self, couponSeriesId) LuciHelper.couponPumpAssertion(self, couponSeriesId) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds)
def test_LUCI_GCD_034(self): # Save Coupon Config couponSeriesId1 = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'valid_days_from_create': 10, 'valid_till_date': Utils.getTime(days=5, milliSeconds=True)})[1] couponSeriesId2 = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'valid_days_from_create': 10, 'valid_till_date': Utils.getTime(days=6, milliSeconds=True)})[1] couponSeriesId3 = LuciHelper.saveCouponConfigAndAssertions(self, couponConfigReq={'valid_days_from_create': 10, 'valid_till_date': Utils.getTime(days=2, milliSeconds=True)})[1] couponCode1 = LuciHelper.issueCouponAndAssertions(self, couponSeriesId1)[0] couponCode2 = LuciHelper.issueCouponAndAssertions(self, couponSeriesId2)[0] couponCode3 = LuciHelper.issueCouponAndAssertions(self, couponSeriesId3)[0] couponSearchRequest = {'orderBy': self.constructObj.orderBy['EXPIRY_DATE'], 'sort': self.constructObj.sort['DESC']} LuciHelper.couponSearchAndAssertion(self, [couponSeriesId1, couponSeriesId2, couponSeriesId3], couponSearchRequest, [couponCode2, couponCode1, couponCode3]) couponSearchRequest = {'orderBy': self.constructObj.orderBy['EXPIRY_DATE'], 'sort': self.constructObj.sort['ASC']} LuciHelper.couponSearchAndAssertion(self, [couponSeriesId1, couponSeriesId2, couponSeriesId3], couponSearchRequest, [couponCode3, couponCode1, couponCode2])