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 ')
def test_LUCI_CF_001(self, description, couponConfig, expected): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfig) Assertion.constructAssertion( couponConfigObj['discount_upto'] == couponConfig['discount_upto'], 'Discount upto value set Actual {} and Expected : {}'.format( couponConfigObj['discount_upto'], couponConfig['discount_upto'])) 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]))
def couponPumpAssertion(self, couponSeriesId, isDiscCode=True, DiscCodePinCouponUploaded=0): if isDiscCode: createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId) Assertion.constructAssertion(createdCouponCount != 0, 'Coupon Code Pumped to Queue') Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) != 0, 'DiscCode Coupons Pumped to Queue') else: createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion( createdCouponCount == DiscCodePinCouponUploaded, 'Coupons are created for DCP') Assertion.constructAssertion( self.connObj.getQueueSize( constant.config['orgId'], couponSeriesId, constant.config['requestId']) == DiscCodePinCouponUploaded, 'DiscCodePin Coupons not pumped')
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_EI_013(self, description, config): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigReq=config) Assertion.constructAssertion( LuciDBHelper.isExternalCouponSeries(couponSeriesId), 'Client handling type isExternal Enabled for coupon series id: {}'. format(couponSeriesId)) Assertion.constructAssertion( couponConfigObj['client_handling_type'] == 'DISC_CODE_PIN', 'External coupon series Client handling type Matched Actual: {} and Expected: {}' .format(couponConfigObj['client_handling_type'], 'DISC_CODE_PIN')) couponCodeList = LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE'], noOfCouponsToBeUpload=10, dracraysUpload={'couponCodeCAPS': False})['coupons'] queueSize = LuciHelper.getQueueSize(self, couponSeriesId) Assertion.constructAssertion( queueSize == 0, 'External Coupons not pumped to Queue Actual: {}'.format( queueSize)) issuedCount = LuciDBHelper.getCouponsIssued_Count(couponSeriesId) Assertion.constructAssertion( issuedCount == 10, 'Uploaded External Coupons & Issued DB count Matched Actual: {} and Expected: {}' .format(issuedCount, 10)) LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCodeList[0], couponIssuedTo=[-1]) couponConfigObj.update({'any_user': False, 'isExternalIssual': False}) LuciHelper.saveCouponConfigAndAssertions( self, couponConfigReq=couponConfigObj) LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE'], noOfCouponsToBeUpload=10, dracraysUpload={'couponCodeCAPS': False}) queueSize = LuciHelper.getQueueSize(self, couponSeriesId) Assertion.constructAssertion( queueSize == 10, 'External Coupons not pumped to Queue Actual: {}'.format( queueSize)) couponCode, _ = LuciHelper.issueCouponAndAssertions( self, couponSeriesId) LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode) queueSize = LuciHelper.getQueueSize(self, couponSeriesId) Assertion.constructAssertion( queueSize == 9, 'External Coupons not pumped to Queue Actual: {}'.format( queueSize))
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)
def test_LUCI_IC_DCP_011(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 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) Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 0, 'All DCP Coupons are issued')
def claimCouponSeries(self, couponSeriesId, claimRequestParams, expectedErrors=[], ownerValidityDays=2, claimResult=True): claimObj = LuciObject.claimCouponConfigRequest({ 'couponSeriesId': couponSeriesId, 'ownedBy': claimRequestParams[0], 'ownerId': claimRequestParams[1], 'ownerValidity': Utils.getTime(days=ownerValidityDays, milliSeconds=True) }) result = self.connObj.claimCouponConfig(claimObj).__dict__ ownerInfo = LuciDBHelper.getOwnerInfo(couponSeriesId) if claimResult: Assertion.constructAssertion( result['success'], 'Coupon Series claimed by {}'.format(claimRequestParams[0])) LuciHelper.queuePumpWait(self, couponSeriesId) Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) != 0, 'Coupons Pumped to Queue') else: Assertion.constructAssertion( not result['success'], 'Re-claim Coupon Series by {}'.format(claimRequestParams[0])) luciExp = result['ex'].__dict__ Assertion.constructAssertion( luciExp['errorCode'] == expectedErrors[0], 'Luci Exception error code Actual: {} and Expected: {}'.format( luciExp['errorCode'], expectedErrors[0])) Assertion.constructAssertion( luciExp['errorMsg'] == expectedErrors[1], 'Luci Exception Error Msg Actual : {}'.format( luciExp['errorMsg'])) voucherType = LuciDBHelper.getCouponSeriesType( couponSeriesId)['seriesType'] Assertion.constructAssertion( voucherType == claimRequestParams[2], 'Coupon Series Type in voucher_series Actual : {} and Expected : {}' .format(voucherType, claimRequestParams[2])) Assertion.constructAssertion( ownerInfo['expiry_date'] != None, 'Owner Expiry date is set Actual: {}'.format( ownerInfo['expiry_date']))
def setBaseState(): module = constant.config['module'] if module == 'nsadmin': NSAdminHelper.checkCommServerConn() if module == 'iris': NSAdminHelper.checkCommServerConn(ignoreConnectionError=True) LuciHelper.checkLuciConn(ignoreConnectionError=False) if module == 'irisv2': LuciHelper.checkLuciConn(ignoreConnectionError=True) ReonHelper.checkReonConnection(ignoreConnectionError=True) NSAdminHelper.checkCommServerConn() CampaignShardHelper.checkCampaignShardConnection() if module == 'luci': LuciHelper.loginAndGetCookies() LuciHelper.checkLuciConn() DracarysHelper.checkDracarysConn() LuciHelper.setBaseDetails() if module == 'veneno': LuciHelper.checkLuciConn(ignoreConnectionError=True) LuciDBHelper.getAdminUserId() VenenoHelper.checkVenenoServerConnection() NSAdminHelper.checkCommServerConn(ignoreConnectionError=True) CampaignShardHelper.checkCampaignShardConnection() if module == 'campaign_shard': CampaignShardHelper.checkCampaignShardConnection() if module == 'darknight': DarknightHelper.checkDarknightConn() if module == 'campaignsui': NSAdminHelper.checkCommServerConn(ignoreConnectionError=True) TemporalHelper.checkTemporalServerConnection(ignoreConnectionError=True) try: status, version = ChromeDriverManager.checkChromeDriverCompatibility() if not status: ChromeDriverManager.downloadChromeDriver(version) except: Logger.log(traceback.format_exc()) if module == 'emf' or module == 'peb': LoyaltyHelper.checkEMFConn() PEBHelper.checkPEBConn() if module == 'peb': PEBHelper.checkPEBConn() if module == 'social': SocialHelper.checkSocialConn() VenenoHelper.checkVenenoServerConnection() LuciHelper.checkLuciConn(ignoreConnectionError=True) LuciDBHelper.getAdminUserId() DracarysHelper.checkDracarysConn(ignoreConnectionError=True) LuciHelper.loginAndGetCookies() LuciHelper.setBaseDetails()
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))
def test_LUCI_IC_DCP_016(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, { 'client_handling_type': 'DISC_CODE_PIN', 'do_not_resend_existing_voucher': False, 'allow_multiple_vouchers_per_user': True }) createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion(createdCouponCount == 0, 'Coupons are created for DCP') Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 0, 'Coupons not pumped to queue') # upload the coupon code LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE']) LuciHelper.issueCouponAndAssertions(self, couponSeriesId) LuciHelper.issueCouponAndAssertions(self, couponSeriesId, couponIssuedCount=2)
def loginAndGetCookies(): try: driver = webdriver.PhantomJS( executable_path=constant.phantomjsPath) driver.get(constant.config['intouchUrl']) driver.find_element_by_id('login_user').send_keys( constant.config['intouchUsername']) driver.find_element_by_id('login_cred').send_keys( constant.config['intouchPassword']) driver.find_element_by_id('c-login-btn').click() try: if driver.find_element_by_id('otp__code').is_displayed(): otp = LuciDBHelper.getOTP() driver.find_element_by_id('otp__code').send_keys(otp) driver.find_element_by_id('c-login-btn').click() except: Logger.log('OTP Verification Page not Found') cookieList = driver.get_cookies() temp = '' for k in cookieList: if (k['name'] == 'OID'): temp += k['name'] + '=' + str( constant.config['orgId']) + ";" else: temp += k['name'] + '=' + k['value'] + ";" constant.config['intouchCookie'] = temp except Exception, intouchExp: Logger.log( '{} Intouch is down and setting up Cookies Empty String & Exception : {}' .format(constant.config['cluster'], intouchExp)) constant.config['intouchCookie'] = 'Cookies Not Set'
def redemptionDBAssertion(self, couponSeriesId, numRedeemed=1, redeemedBy=[]): if not redeemedBy: redeemedBy = [self.userId] couponRedemptionList = LuciDBHelper.getCouponRedemptionsListByCouponSeriesId( couponSeriesId) Assertion.constructAssertion(couponRedemptionList is not None, 'Coupon_redemption has the records') Assertion.constructAssertion( len(couponRedemptionList) == numRedeemed, 'No of Coupon redeemed Actual: {} and Expected: {}'.format( len(couponRedemptionList), numRedeemed)) for cr in couponRedemptionList: Assertion.constructAssertion( cr['redeemedUserId'] in redeemedBy, 'Coupon redeemed by Actual: {} and Expected: {}'.format( cr['redeemedUserId'], redeemedBy)) Assertion.constructAssertion( cr['redeemedAtStore'] == self.tillId, 'Redeemed Till id Actual: {} and Expected: {}'.format( cr['redeemedAtStore'], self.tillId)) Assertion.constructAssertion( cr['billId'] == self.billId, 'Redeemed Bill Id Actual : {} and Expected: {}'.format( cr['billId'], self.billId))
def test_LUCI_PC_001(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self) time.sleep(10) count = 2500 createCouponobj = LuciObject.couponCreateRequest({ 'couponSeriesId': couponSeriesId, 'count': count }) createCouponDict = self.connObj.createCoupons(createCouponobj).__dict__ Assertion.constructAssertion( createCouponDict['statusCode'] == 1200, 'CREATE COUPON STATUS CODE IS MISMATCH - ' + str(createCouponDict['statusCode'])) Assertion.constructAssertion( createCouponDict['message'] == 'coupon pump successfully started', 'CREATE COUPON CODE MESSAGE IS WRONG') time.sleep(5) createdCount = LuciDBHelper.getCouponsCreated_Count(couponSeriesId) Assertion.constructAssertion( createdCount >= count, 'COUPON CREATED IS LESS THAN REQUEST COUNTS')
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_015(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, { 'do_not_resend_existing_voucher': True, 'allow_multiple_vouchers_per_user': False }) 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}) luciExp = LuciHelper.issueCouponAndAssertions(self, couponSeriesId, expectException=True) Assertion.constructAssertion( luciExp['errorCode'] == constant.COUPON_ALREADY_ISSUED, 'Luci Exception error code Actual: {} and Expected: {}'.format( luciExp['errorCode'], constant.COUPON_ALREADY_ISSUED)) Assertion.constructAssertion( luciExp['errorMsg'] == 'user already has a coupon', 'Luci Exception Error Msg Actual : {}'.format(luciExp['errorMsg']))
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 setup_class(self): Logger.logSuiteName(str(self).split('.')[-1]) self.constructObj = LuciObject() self.DracarysObj = DracarysObject() self.userId = constant.config['usersInfo'][0]['userId'] self.tillId = constant.config['tillIds'][0] self.orgDefaultValue = LuciDBHelper.orgDefaultValues()
def test_LUCI_IC_DCP_015(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, { 'client_handling_type': 'DISC_CODE_PIN', 'do_not_resend_existing_voucher': True, 'allow_multiple_vouchers_per_user': False }) createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion(createdCouponCount == 0, 'Coupons are created for DCP') Assertion.constructAssertion( self.connObj.getQueueSize(constant.config['orgId'], couponSeriesId, constant.config['requestId']) == 0, 'Coupons not pumped to queue') # upload the coupon code LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE']) LuciHelper.issueCouponAndAssertions(self, couponSeriesId) luciExp = LuciHelper.issueCouponAndAssertions(self, couponSeriesId, expectException=True) Assertion.constructAssertion( luciExp['errorCode'] == constant.COUPON_ALREADY_ISSUED, 'Luci Exception error code Actual: {} and Expected: {}'.format( luciExp['errorCode'], constant.COUPON_ALREADY_ISSUED)) Assertion.constructAssertion( luciExp['errorMsg'] == 'user already has a coupon', 'Luci Exception Error Msg Actual : {}'.format(luciExp['errorMsg']))
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_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 setBaseDetails(): Logger.log( "Retriving Base Info's for Testcases like AdminUser, UserList, TIll & Store id's and CampaignId" ) LuciDBHelper.getAdminUserId() LuciDBHelper.getUsers() LuciDBHelper.getActiveTillIdList() LuciDBHelper.getActiveStoreIdList() LuciHelper.createCampaign() Logger.log('Base Details set for Testcases')
def test_LUCI_IMC_DCP_012(self, description): try: couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigReq={'client_handling_type': 'DISC_CODE_PIN'}) LuciHelper.couponPumpAssertion(self, couponSeriesId, False) noOfCouponUpload = 100 noOfCouponToBeIssue = 120 LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE'], noOfCouponsToBeUpload=noOfCouponUpload) time.sleep(2) createdCouponCount = LuciDBHelper.getCouponsCreated_Count( couponSeriesId, 1) Assertion.constructAssertion( createdCouponCount == noOfCouponUpload, 'Uploaded coupon & Valid coupon in DB count Mismatch Actual : {} and Expected : {}' .format(createdCouponCount, noOfCouponUpload)) queueCount = self.connObj.getQueueSize( constant.config['orgId'], couponSeriesId, constant.config['requestId']) Assertion.constructAssertion( queueCount == noOfCouponUpload, 'Uploaded coupon and Queued Coupon count is Mismatch Actual : {} and Expected : {}' .format(queueCount, noOfCouponUpload)) LuciDBHelper.getUsers(noOfCouponToBeIssue) for i in range(len(constant.config['usersInfo'])): self.bulkUserIds.append( constant.config['usersInfo'][i]['userId']) exceptionList = LuciHelper.issueMultipleCoupon( self, couponSeriesId, self.bulkUserIds, expectResponseException=[True, 'coupons exhausted']) Assertion.constructAssertion( (noOfCouponToBeIssue - noOfCouponUpload) == len(exceptionList), 'Uploaded and Issued Coupons : {} and Coupon Exhausted Exception : {}' .format(noOfCouponUpload, len(exceptionList))) finally: del constant.config['usersInfo'][10:]
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_BCSKU_002_sanity(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self) prodInfo = LuciObject.productInfo( {'productIds': [9926522, 9926523, 15972]}) couponConfigObj.update({'productInfo': [prodInfo]}) couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigObj, {'includeProductInfo': True}) prodInfo = LuciObject.productInfo({ 'productType': 0, 'productIds': [1243] }) couponConfigObj.update({'productInfo': [prodInfo]}) couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigObj, {'includeProductInfo': True}) LuciHelper.queuePumpWait(self, couponSeriesId) Assertion.constructAssertion( LuciDBHelper.getCouponsCreated_Count(couponSeriesId) != 0, 'Coupon Code Pumped to Queue') configRequest = LuciObject.getCouponConfigRequest( {'couponSeriesId': couponSeriesId}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) productInfo = couponConfigList[0].__dict__ productInfo = productInfo['productInfo'] productIds = [] productIds2 = [] voucherProductDataValuesList = LuciDBHelper.getVoucherProductDataValues( couponSeriesId) for k in productInfo: k = k.__dict__ Assertion.constructAssertion( (k['productType'] == self.constructObj.productType['BRAND']) or (k['productType'] == self.constructObj.productType['CATEGORY']), 'PRODUCT TYPE IS MISMATCH') productIds += k['productIds'] for k in voucherProductDataValuesList: productIds2.append(k['product_id']) Assertion.constructAssertion( len(voucherProductDataValuesList) == len(productIds), 'PRODUCT IDs COUNT IS MISMATCH') Assertion.constructAssertion( set(productIds) == set(productIds2), 'PRODUCT IDs ARE MISMATCH IN DB AND THRIFT RESPONSE')
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_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_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_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_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']