def est_ratelimit( self, mobileNumber ): # Same number if used will timeout within 24hrs # to be fixed self.nsadminHelper.configureGateway('BULK', 'valuefirstmock') msgObjList = [] for i in range(1, 10): msgObj = NSAdminObject.message({ "messageClass": "SMS", "inboxId": i, "clientId": 113, "priority": "BULK", "message": "test message " + str(i), "receiver": mobileNumber }) msgObjList.append(msgObj) self.nsObj.sendMultipleMessages(msgObjList) msgObj = NSAdminObject.message({ "messageClass": "SMS", "inboxId": 10, "clientId": 113, "priority": "BULK", "message": "test message 10", "receiver": mobileNumber }) nsadminId = self.nsObj.sendMessage(msgObj) resp = self.nsadminHelper.waitUntil(nsadminId, ['SENT']) if resp: Assertion.constructAssertion(resp.requestId != '', 'msg_ref_id is not generated') else: Assertion.constructAssertion(False, 'Failed to get status SENT') msgObj = NSAdminObject.message({ "messageClass": "SMS", "inboxId": 11, "clientId": 113, "priority": "BULK", "message": "test message 11", "receiver": mobileNumber }) nsadminId = self.nsObj.sendMessage(msgObj) resp = self.nsadminHelper.waitUntil(nsadminId, ['RATE_LIMIT_EXCEEDED']) if resp: Assertion.constructAssertion(resp.requestId == '', 'msg_ref_id is generated') else: Assertion.constructAssertion( False, 'Failed to get status RATE_LIMIT_EXCEEDED')
def validateChannelSetting(self, responseVariantInfo, dbVarinatInfo): if responseVariantInfo['channelSetting']['channel'] == 'SMS': keyToBeValidated = [ 'channel', 'gsmSenderId', 'domainGatewayMapId', 'targetNdnc', 'cdmaSenderId' ] elif responseVariantInfo['channelSetting']['channel'] == 'MOBILEPUSH': keyToBeValidated = ['channel'] else: keyToBeValidated = [ 'channel', 'domainGatewayMapId', 'senderLabel', 'senderEmail', 'senderReplyTo' ] for eachChannelSettingKey in keyToBeValidated: Assertion.constructAssertion( responseVariantInfo['channelSetting'][eachChannelSettingKey] == dbVarinatInfo['channelSetting'][eachChannelSettingKey], 'ChannelSetting from key :{} in Response :{} and in DB :{}'. format( eachChannelSettingKey, responseVariantInfo['channelSetting'] [eachChannelSettingKey], dbVarinatInfo['channelSetting'][eachChannelSettingKey])) for eachAdditionalSetting in [ 'useTinyUrl', 'encryptUrl', 'skipRateLimit' ]: Assertion.constructAssertion( responseVariantInfo['additionalSetting'][eachAdditionalSetting] == dbVarinatInfo['additionalSetting'][eachAdditionalSetting], 'AdditionalInfo from key :{} in Response :{} and in DB :{}'. format( eachAdditionalSetting, responseVariantInfo['additionalSetting'] [eachAdditionalSetting], dbVarinatInfo['additionalSetting'][eachAdditionalSetting]))
def test_LUCI_GCC_004(self, description): self.couponConfig4.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self,self.couponConfig4) time.sleep(2) self.couponConfig1.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self, self.couponConfig1) time.sleep(2) self.couponConfig3.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self, self.couponConfig3) time.sleep(2) self.couponConfig5.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self, self.couponConfig5) time.sleep(2) self.couponConfig2.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self, self.couponConfig2) couponSeriesDesc = [self.couponSeriesId2, self.couponSeriesId5, self.couponSeriesId3, self.couponSeriesId1, self.couponSeriesId4] configRequest = LuciObject.getCouponConfigRequest({'orderBy' : self.constructObj.couponConfigOrderBy['LAST_MODIFIED_DATE'], 'sort' : self.constructObj.sort['DESC'], 'limit' : 5}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) Assertion.constructAssertion(len(couponConfigList) == 5, 'GetCouponConfig Limit {} and couponconfig got {}'.format(5, len(couponConfigList))) for couponConfig,couponSeriesId in zip(couponConfigList,couponSeriesDesc): couponConfig = couponConfig.__dict__ Logger.log('Coupon Config Ids : ' , couponConfig['id'] ) Assertion.constructAssertion(couponConfig['id'] == couponSeriesId , 'GetCouponConfig CouponSeriesId sort by desc order by Created Date Actual :{} and Excepted : {}'.format(couponConfig['id'],couponSeriesId))
def unMapWeChatTemplate(self): try: if not self.isElementPresent(self.wechat_unmap_noTemplate_xpath, locatorType='xpath'): self.waitForElement(self.wechat_unmap_template_icon_xpath, locatorType='xpath') if self.isElementPresent(self.wechat_unmap_template_icon_xpath, locatorType='xpath'): allIconsOfunmap = self.getElements( self.wechat_unmap_template_icon_xpath, locatorType='xpath') for eachIcon in allIconsOfunmap: eachIcon.click() self.getElements(self.wechat_unmap_template_btn_xpath, locatorType='xpath')[-1].click() self.waitForElement(self.wechat_unmap_template_del_id) if self.isElementPresent( self.wechat_unmap_template_del_id): self.elementClick( self.wechat_unmap_template_del_id) else: time.sleep(2) self.elementClick( self.wechat_unmap_template_del_id) self.waitForElement( self.wechat_unmap_template_icon_xpath, locatorType='xpath') else: Assertion.constructAssertion( False, 'Unable to UnMap Wechat Template ', verify=True) except Exception, exp: Assertion.constructAssertion( False, 'UnMapTemplate Exception :{}, please check manually'.format( exp), verify=True)
def test_irisv2_getStatusBy_messageId_Sanity(self, campaignType, testControlType, channel, messageInfo, queryParam): messageDetails = CreateMessage.create(campaignType, testControlType, 'LOYALTY', channel, messageInfo, updateNode=True, lockNode=True) CreateMessage.assertResponse(messageDetails['RESPONSE'], 200) message_calls().waitForJobDetailsStatusToClose( messageDetails['RESPONSE']['json']['entity']['id'], 'VARIANT_CREATION') approveRespone = AuthorizeMessage.approve( campaignType, testControlType, 'LOYALTY', channel, messageInfo, messageCreateResponse=messageDetails) AuthorizeMessage.assertResponse(approveRespone, 200) campaignId = constant.config['node'][campaignType][testControlType][ 'CAMPAIGN']['ID'] AuthorizeMessageDBAssertion(campaignId, messageDetails['RESPONSE'], messageDetails['PAYLOAD'], testControlType).check() response = GetMonitoringDetails.getByMessageId( campaignId, messageDetails['RESPONSE']['json']['entity']['id'], queryParam) actualResponse, expectedResponse = GetMonitoringDetails.formatingMonitorDetails( response, isScheduledMsg=True, isDeliveryBreakEnabled=True) Assertion.constructAssertion( actualResponse == expectedResponse, 'Monitoring Details response Matched Actual: {} and Expected: {}'. format(actualResponse, expectedResponse))
def test_createMessage_email_differentIncentives(self, request, messageType, listType, incentiveType, templateName): self.createCampaignPage.navigateBackToCampaignsOverviewPage( dependencies={ 'coupon': '', 'list': ['loyalty'] }) try: self.createCampaignPage.goToMessagePage(messageType) self.messagePage.chooseRecipient( constant.config['list'][listType]['name']) self.messagePage.attachIncentive(incentiveType) self.messagePage.customizeContent(templateName, channel='email') self.messagePage.deliverySetting() self.createCampaignPage.authorizePresentCampaignOnPage() self.messagePage.verifyAuthorizeCampaign( constant.config['campaign']['id'], constant.config['list'][listType]['id']) except Exception, exp: self.getScreenshot(request.node.name) Assertion.constructAssertion( False, 'Failure with Exception :{}'.format(exp))
def revokeCoupon(self, couponSeriesId, issuedCoupon, revokeType=-1, reqDict={}): tmpDict = {'couponSeriesId': couponSeriesId} tmpDict.update(reqDict) invalidateCouponRequest = None if revokeType in [0, 1]: invalidateCouponRequest = LuciObject.invalidateCouponRequest( tmpDict) else: couponsToBeInvalidated = LuciHelper.constructInvalidateCoupon( self.constructObj.revokeType[revokeType], issuedCoupon) tmpDict.update({'couponsToBeInvalidated': couponsToBeInvalidated}) invalidateCouponRequest = LuciObject.invalidateCouponRequest( tmpDict) if invalidateCouponRequest != None: Assertion.constructAssertion( self.connObj.invalidateCoupons(invalidateCouponRequest) == True, 'Requested Coupon codes are revoked CouponSeriesId : {}'. format(couponSeriesId)) else: Logger.log('Invalidate Coupon Request Object not constructed')
def test_irisv2_message_execute_flow_precheck_immediate_GatewayUnavialable_remind( self, campaignType, testControlType, listType, channel, messageInfo): preCheckError = { 'status': 'TEMPORARY_FAILURE', 'errorDescription': 'GATEWAY_NOT_AVAILABLE' } try: messageDetails = CreateMessage.create(campaignType, testControlType, listType, channel, messageInfo, updateNode=True, lockNode=True) CreateMessage.assertResponse(messageDetails['RESPONSE'], 200) IrisHelper.disableDomainGatewayMapId(channel) approveRespone = AuthorizeMessage.approve( campaignType, testControlType, listType, channel, messageInfo, messageCreateResponse=messageDetails) AuthorizeMessage.assertResponse(approveRespone, 200) PreCheckDBValidation( constant.config['node'][campaignType][testControlType] ['CAMPAIGN']['ID'], messageDetails['RESPONSE']['json']['entity']['id'], messageInfo['scheduleType']['type'], ['REMINDED', 'OPENED'], remindCheck=False, precheck=preCheckError, variantCheck=False).validateMessageFlow() except AssertionError, exp: Assertion.constructAssertion(False, '{}'.format(exp))
def test_getCampaignAll_updateUpcomingCampaign_outOfGivenRange(self, description, numberOfCamaigns, startDate, endDate, startFrom): getCampaignResponseCheck = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', numberOfCamaigns)]) campaignsRequiredToCreate = numberOfCamaigns - len(getCampaignResponseCheck.get('json').get('data')) numberOfCampaignsGotCreated = 0 if campaignsRequiredToCreate > 0: for number in range(campaignsRequiredToCreate): response, payload = campaigns.createCampaign({'name':'IRIS_' + str(int(time.time())), 'goalId':str(constant.irisGenericValues['goalId']), 'objectiveId': constant.irisGenericValues['objectiveId'], 'startDate':startDate, 'endDate':endDate}) campaigns.assertCreateCampaign(response, 200) if response.get('statusCode') == 200: numberOfCampaignsGotCreated = numberOfCampaignsGotCreated + 1 Logger.log('Number of Campaigns required :{} and CampaignsAlready Present in Range :{} and created Camapign in this job :{}'.format(numberOfCamaigns, len(getCampaignResponseCheck.get('json').get('data')), numberOfCampaignsGotCreated)) getCampaignResponse = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', numberOfCamaigns)]) campaigns.assertGetCampaignAll(getCampaignResponse, numberOfCamaigns, 200) listOfCampaignsWithCampaignIdAndResponse = construct.constructGetCampaignAllToGetCampaignIdResponse(getCampaignResponse) campaignIdToUpdate = listOfCampaignsWithCampaignIdAndResponse[0][0] Logger.log('Updating Campaign with id :', campaignIdToUpdate) campaigns.updateCampaign({'startDate':int(time.time() * 1000 + 24 * 60 * 60 * 1000 * 469), 'endDate':int(time.time() * 1000 + 24 * 60 * 60 * 1000 * 470)}, campaignId=campaignIdToUpdate) getCampaignResponseAfterUpdatingSingleCampaignInThatRange = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', numberOfCamaigns)]) for each in getCampaignResponseAfterUpdatingSingleCampaignInThatRange.get('json').get('data'): if int(each.get('id')) == int(campaignIdToUpdate): Assertion.constructAssertion(False, 'Updated Campaign Found in Get All Call')
def assertCreateCampaignForSocial(campaignId, SocialCampaignObject): Assertion.constructAssertion( SocialCampaignObject.campaignId == campaignId, 'Intouch CampaignId, Actual :{} and Expected :{}'.format( SocialCampaignObject.campaignId, campaignId)) Assertion.constructAssertion( SocialCampaignObject.socialCampaignStatus == 0, 'socialCampaignStatus is 0') Assertion.constructAssertion( SocialCampaignObject.orgId == constant.config['orgId'], 'OrgId , Actual :{} and Expected :{}'.format( SocialCampaignObject.orgId, constant.config['orgId'])) Assertion.constructAssertion( int(SocialCampaignObject.accountId) == constant.config['facebook'] ['accountId'], 'AccountId , Actual :{} and Expected :{}'.format( SocialCampaignObject.accountId, constant.config['facebook']['accountId']))
def validateMessageContent(self, responseVariantInfo, dbVarinatInfo): if responseVariantInfo['messageContent']['channel'] == 'SMS': keysToValidate = ['channel', 'messageBody', 'storeType'] elif responseVariantInfo['messageContent']['channel'] == 'MOBILEPUSH': keysToValidate = [ 'channel', 'storeType', 'accountId', 'androidContent', 'iosContent' ] else: keysToValidate = [ 'channel', 'emailSubject', 'emailBody', 'storeType' ] for eachMessageContentKey in keysToValidate: if type(responseVariantInfo['messageContent'] [eachMessageContentKey]) is dict: for eachKey in responseVariantInfo['messageContent'][ eachMessageContentKey]: if eachKey in dbVarinatInfo['messageContent'][ eachMessageContentKey]: Assertion.constructAssertion( responseVariantInfo['messageContent'] [eachMessageContentKey][eachKey] == dbVarinatInfo['messageContent'] [eachMessageContentKey][eachKey], 'Key :{} in {} -> Value in Db and in response :{}'. format( eachKey, eachMessageContentKey, responseVariantInfo['messageContent'] [eachMessageContentKey][eachKey], dbVarinatInfo['messageContent'] [eachMessageContentKey][eachKey])) else: Logger.log( 'Not Asserting for Key : {}'.format(eachKey)) else: Assertion.constructAssertion( responseVariantInfo['messageContent'] [eachMessageContentKey] == dbVarinatInfo['messageContent'] [eachMessageContentKey], 'MessageContent for key :{} in Response :{} and in DB :{}'. format( eachMessageContentKey, responseVariantInfo['messageContent'] [eachMessageContentKey], dbVarinatInfo['messageContent'] [eachMessageContentKey])) if self.offer: for eachOffer in dbVarinatInfo['messageContent']['offers']: eachOffer.pop('_class') Assertion.constructAssertion( responseVariantInfo['messageContent']['offers'] == dbVarinatInfo['messageContent']['offers'], 'Offers from messageContent in Response :{} and in DB :{}'. format(responseVariantInfo['messageContent']['offers'], dbVarinatInfo['messageContent']['offers']), verify=True)
def test_LUCI_IMC_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 }) LuciHelper.couponPumpAssertion(self, couponSeriesId, isDiscCode=False) # upload the coupon code LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['NONE'], noOfCouponsToBeUpload=10) LuciHelper.issueMultipleCoupon(self, couponSeriesId, self.userIds) couponAlreadyIssued = LuciHelper.issueMultipleCoupon( self, couponSeriesId, self.userIds, expectResponseException=[True, 'user already has a coupon']) Assertion.constructAssertion( len(couponAlreadyIssued) == len(self.userIds), 'Coupon Already issued to List of users Sent')
def getDbInformationForVeneno(self): self.communicationDetailResult = dbCallsAuthorize.getCommunicationDetailsWithId( self.communicationDetailId) if self.communicationDetailResult[ 'expected_delivery_count'] == 0 and self.assertionInitCheck(): Logger.log('Aborting the Case') self.initFailureForStickyList = False return False else: self.initFailureForStickyList = True Assertion.constructAssertion( self.communicationDetailResult['expected_delivery_count'] != 0, 'Veneno not able processed because Expected Delivery Count is : {}' .format( self.communicationDetailResult['expected_delivery_count'])) self.serviceDetailResult = dbCallsAuthorize.getServiceDetails( self.communicationDetailId, self.communicationDetailResult['expected_delivery_count']) self.venenoBatchDetailResult = dbCallsAuthorize.getVenenoBatchDetail( self.communicationDetailId) self.summaryReportVeneno = dbCallsAuthorize.getSummaryReportVeneno( self.communicationDetailId) self.summaryReportNsadmin = dbCallsAuthorize.getSummaryReportNsadmin( self.communicationDetailId)
def test_probCheck_case21(self): DarknightHelper.generateSmsWhitelistingData({ 'not_delivered' : 7, 'delivered' : 19, 'last_failed_on' : self.monthList[0], 'last_success_on' : self.monthList[0] - timedelta(days=1), "monthly_stats": [{ "year": self.monthList[0].year, "month": self.monthList[0].month, "not_delivered": 1, "delivered": 5, "total": 6},{ "year": self.monthList[1].year, "month": self.monthList[1].month, "not_delivered": 1, "delivered": 5, "total": 6}, { "year": self.monthList[2].year, "month": self.monthList[2].month, "not_delivered": 1, "delivered": 5, "total": 6},{ "year": self.monthList[3].year, "month": self.monthList[3].month, "not_delivered": 1, "delivered": 1, "total": 2}, { "year": self.monthList[4].year, "month": self.monthList[4].month, "not_delivered": 1, "delivered": 1, "total": 2},{ "year": self.monthList[5].year, "month": self.monthList[5].month, "not_delivered": 1, "delivered": 1, "total": 2}, { "year": self.monthList[6].year, "month": self.monthList[6].month, "not_delivered": 1, "delivered": 1, "total": 2} ]}) resObj = self.dnObj.getMobileStatus([self.mobile1], self.orgId) Assertion.constructAssertion(resObj[self.mobile1] == True, 'Verifying 10 10 10 10 011111 110111 111110 - 71%')
def test_LUCI_IC_DC_020_sanity(self, description): couponSeriesList = [] couponConfigObjList = [] for i in range(4): if i % 2: mutualCouponSeriesId = '[{}]'.format(couponSeriesList[i - 1]) couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigReq={ 'mutual_exclusive_series_ids': mutualCouponSeriesId }) couponConfigObjList.append(couponConfigObj) couponSeriesList.append(couponSeriesId) else: couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self) couponConfigObjList.append(couponConfigObj) couponSeriesList.append(couponSeriesId) LuciHelper.queuePumpWait(self, couponSeriesId) 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, 'Coupon Code Pumped to Queue') if not i % 2: LuciHelper.issueCouponAndAssertions(self, couponSeriesList[i]) else: mutualExclusiveExp = LuciHelper.issueCouponAndAssertions( self, couponSeriesList[i], expectException=True) Assertion.constructAssertion( mutualExclusiveExp['errorCode'] == constant.COUPON_PRESENT_MUTUAL_EXCLUSIVE_SERIES, 'Luci Exception error code Actual: {} and Expected: {}'. format(mutualExclusiveExp['errorCode'], constant.COUPON_PRESENT_MUTUAL_EXCLUSIVE_SERIES)) Assertion.constructAssertion( mutualExclusiveExp['errorMsg'] == 'coupon present in mutually exclusive series id ', 'Luci Exception Error Msg Actual : {}'.format( mutualExclusiveExp['errorMsg']))
def saveExpiryReminderAssertion(self, actualResponse, expectedResponse): for actual, expected in zip(actualResponse, expectedResponse): Assertion.constructAssertion( actual['numDaysBeforeExpiry'] == expected[0], 'No of days Before Expiry Actual : {} and Expected : {}'. format(actual['numDaysBeforeExpiry'], expected[0])) Assertion.constructAssertion( actual['hourOfDay'] == expected[1], 'Hour of day Actual : {} and Expected : {}'.format( actual['hourOfDay'], expected[1])) Assertion.constructAssertion( actual['minuteOfHour'] == expected[2], 'Minute of Hour Actual : {} and Expected : {}'.format( actual['minuteOfHour'], expected[2])) Assertion.constructAssertion( actual['couponSeriesId'] == self.couponSeriesId, 'Reminder Message CouponSeriesId Actual : {} and Expected : {}' .format(actual['couponSeriesId'], self.couponSeriesId))
def test_addCreditsSMS(self): creditDetails1 = {"orgId": self.orgId, "bulkCredits": 200} creditDetails1 = NSAdminObject.OrgCreditDetails(creditDetails1) currVal = self.masterNsObj.getCreditDetails(self.orgId) resp1 = self.masterNsObj.addCredits(creditDetails1) afterAdd = self.masterNsObj.getCreditDetails(self.orgId) Assertion.constructAssertion(resp1 == True, 'addCredits response') Assertion.constructAssertion( afterAdd.bulkCredits == currVal.bulkCredits + 200, 'increase in bulkCredits') creditDetails2 = {"orgId": self.orgId, "bulkCredits": -100} creditDetails2 = NSAdminObject.OrgCreditDetails(creditDetails2) resp2 = self.masterNsObj.addCredits(creditDetails2) afterDeduc = self.masterNsObj.getCreditDetails(self.orgId) Assertion.constructAssertion(resp2 == True, 'addCredits response') Assertion.constructAssertion( afterDeduc.bulkCredits == currVal.bulkCredits + 100, 'decrease in bulkCredits')
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 pointsRedemptionAndAssertion(self,pointsToRedeem, initialRedeemedPoints, paramDict = {}): time.sleep(2) tmpDict = {'customerID' : self.customerId, 'eventTimeInMillis': Utils.getTime(seconds=(random.randint(0,9)),milliSeconds=True), 'numPointsToBeRedeemed' : pointsToRedeem} tmpDict.update(paramDict) ptsRedemptionObject = EMFObject.PointsRedemptionEventData(tmpDict) redeemPointsResponse = LoyaltyHelper.simplePropertiesParser(self.EMFConnObj.pointsRedemptionEvent(ptsRedemptionObject).__dict__) Assertion.constructAssertion(redeemPointsResponse['uniqueRedemptionId'] != None, 'Unique Redemption Id is not Empty Actual: {}'.format(redeemPointsResponse['uniqueRedemptionId'])) Assertion.constructAssertion(int(redeemPointsResponse['numPoints']) == pointsToRedeem, 'Redeemed points Actual: {} and Expected: {}'.format(redeemPointsResponse['numPoints'] , pointsToRedeem)) Assertion.constructAssertion('REDEEM' in redeemPointsResponse['instructionType'], 'REDEEM Instruction not executed in points redemptions') LoyaltyHelper.assertOnSumOfPoints(self,(initialRedeemedPoints+pointsToRedeem)) return redeemPointsResponse
def test_veneno_replyMessage_CUSTOM_allErrorTypes(self, description, changeCouponConfig): Logger.log(self.Details[description]) if description == 'COUPON_EXPIRED': changeCouponConfig.update( {'fixedExpiryDate': Utils.getTime(days=2, milliSeconds=True)}) self.voucherId = self.Details[description]['voucherId'] self.commDetailsId = self.Details[description][ 'communicationDetailsId'] VenenoHelper.couponConfigChange(self, changeCouponConfig) time.sleep(70) authorize.dbAssertionInSkippedReplyTables(self.commDetailsId) campaignMessage.replyMessage(self) time.sleep(10) campaignReplyStats = dbCallsAuthorize.getVenenoReplyStats( self.Details[description]['communicationDetailsId']) Assertion.constructAssertion( len(campaignReplyStats) != 0, 'Campaign Reply Stats update status {}'.format( len(campaignReplyStats))) authorize.assertUserPresenceInNsAdminTable( self.Details[description]['communicationDetailsId'], self.Details[description]['communicationDetailBucketId'], int(self.Details[description]['communicationDetailExpectedCount']), verify=False, waitForInboxMsg=True) communcationDetailsDict = dbCallsAuthorize.getCommunicationDetailsWithId( self.Details[description]['communicationDetailsId']) Assertion.constructAssertion( communcationDetailsDict['state'] == 'REPLAYED', 'Communication Details MessageId state is Actual: {} and Expected: {}' .format(communcationDetailsDict['state'], 'REPLAYED')) Assertion.constructAssertion( communcationDetailsDict['expected_delivery_count'] == int( self.Details[description]['communicationDetailExpectedCount']), 'Communication Details Expected Delivery count Actual: {} and Expected: {}' .format( communcationDetailsDict['expected_delivery_count'], int(self.Details[description] ['communicationDetailExpectedCount']))) Assertion.constructAssertion( communcationDetailsDict['message_queue_id'] != 0, 'Communication Details Message Queue Id is not 0 Actual: {}'. format(communcationDetailsDict['message_queue_id']))
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 assertAggregationDetail(self): Assertion.constructAssertion( 'LIST_PUBLISHED' in self.SocialInfo['aggregationDetails'], 'Expecting LIST_PUBLISHED in aggregationDetails') Assertion.constructAssertion( 'POST_PROCESS' in self.SocialInfo['aggregationDetails'], 'Expecting POST_PROCESS in aggregationDetails') if self.couponUsed and not self.couponUsedExteranal: Assertion.constructAssertion( 'COUPON_ISSUED' in self.SocialInfo['aggregationDetails'], 'Expecting COUPON_ISSUED in aggregationDetails') for eachJobType in self.SocialInfo['aggregationDetails']: Assertion.constructAssertion( self.SocialInfo['aggregationDetails'][eachJobType] ['job_status'] == 'DONE', 'For JobType :{} , job status is :{}'.format( eachJobType, self.SocialInfo['aggregationDetails'] [eachJobType]['job_status']))
def test_LYT_RED_REVERSE_06(self, description): redemptionId = [] initialRedeemedPoints = LoyaltyDBHelper.getSumOfPointsAwarded( self.customerId)['sumOfRedeemedValue'] uniqueRedemptionId = LoyaltyHelper.pointsRedemptionAndAssertion( self, constant.config['defaultRedeemPts'], initialRedeemedPoints, {'redeemedOnBillId': -1})['uniqueRedemptionId'] prsDBDetails = LoyaltyDBHelper.getPointsRedemptionSummary( self.customerId, self.storeId, {'redemptionIds': uniqueRedemptionId}) Assertion.constructAssertion( len(prsDBDetails) == len([uniqueRedemptionId]), 'No of Records added to prs Actual: {} and Expected: {}'.format( len(prsDBDetails), len(uniqueRedemptionId))) for prs in prsDBDetails: Assertion.constructAssertion( prs['billId'] == -1, 'RedemptionId updated to prs with BillId Actual: {} and Expected: {}' .format(prs['billId'], constant.config['billNumber'])) Assertion.constructAssertion( prs['redemption_id'] in uniqueRedemptionId, 'Unique Redemption Id is match with BillIds Actual: {} and Expected: {}' .format(prs['redemption_id'], uniqueRedemptionId)) Assertion.constructAssertion( prs['redemptionType'] == 'REDEMPTION', 'Redemption type is Matched Actual: {} and Expected: {}'. format(prs['redemptionType'], 'REDEMPTION')) redemptionId.append(prs['prs_id']) parsedResponse = LoyaltyHelper.redemptionReversalAndAssertion( self, [uniqueRedemptionId]) LoyaltyHelper.redemptionReversalDBAssertion( self, redemptionId, parsedResponse['redemptionReversalId'], initialRedeemedPoints) LoyaltyHelper.redemptionReversalAndAssertion( self, listOfRedemptionId=[parsedResponse['redemptionReversalId']], expectException=[ 3804, 'redemption reversal of a reversal not allowed' ])
def assertAggregationDetailAndAudienceListCreated(groupVersionId, communicationId): socialInfo = social_info(groupVersionid=groupVersionId, messageId=communicationId, aggregationDetail=True, socialAudienceList=True).socialInfo Assertion.constructAssertion( socialInfo['audienceList']['message_id'] == communicationId, 'Social Audience List is Published') Assertion.constructAssertion('LIST_DELETE' in socialInfo['aggregationDetails'], 'LIST_DELETE in aggregation Details', verify=True) Assertion.constructAssertion('LIST_PUBLISHED' in socialInfo['aggregationDetails'], 'LIST_PUBLISHED in aggregation Details', verify=True) Assertion.constructAssertion('POST_PROCESS' in socialInfo['aggregationDetails'], 'POST_PROCESS in aggregation Details', verify=True)
def issuedCouponsDBAssertion(self, couponSeriesId, couponCode, numIssued=1, issuedTo=-1): couponsIssuedList = LuciDBHelper.getCouponsIssuedList(couponSeriesId) Assertion.constructAssertion( couponsIssuedList is not None, 'Issued coupons are recorded in coupons_issued') Assertion.constructAssertion( len(couponsIssuedList) == numIssued, 'Issued Count in coupons_iisued Actual : {} and Expected : {}'. format(len(couponsIssuedList), numIssued)) Assertion.constructAssertion( couponsIssuedList[0]['couponCode'] == couponCode, 'Issued coupon Actual: {} and Expected : {}'.format( couponsIssuedList[0]['couponCode'], couponCode)) Assertion.constructAssertion( couponsIssuedList[0]['issuedTo'] == issuedTo, 'Coupon Issued UserId Actual : {} and Expected : {}'.format( couponsIssuedList[0]['issuedTo'], issuedTo))
def test_sendMessage_EMAIL_Sanity(self, priority, gateway): self.nsadminHelper.configureGateway(priority, gateway) msgDict = { "messageClass": "EMAIL", "priority": priority, "message": "test message with priority " + priority } resp = self.nsadminHelper.createAndSendMessage(msgDict) Assertion.constructAssertion(resp > 0, 'sendMessage output') resp = self.nsadminHelper.assertWithWaitUntil( resp, ['RECEIVED_IN_QUEUE', 'SENT'], 'Messages status ACK', 10) Assertion.constructAssertion(resp.gateway == gateway, 'gateway used for sending') Assertion.constructAssertion(resp.priority == priority, 'priority')
def test_veneno_replyMessage_CUSTOM_Sanity(self, description, couponConfig, skippedReason, configChange): couponConfig.update({'description': description}) self.voucherId = VenenoHelper.createCouponLuci(self, couponConfig) communicationDetailsId, communicationDetailBucketId, communicationDetailExpectedCount = VenenoHelper.messageAuthorize( self, skippedError=skippedReason, isSkippedMessage=True) VenenoHelper.couponConfigChange(self, configChange) time.sleep(2) self.commDetailsId = communicationDetailsId authorize.dbAssertionInSkippedReplyTables(communicationDetailsId) campaignMessage.replyMessage(self) time.sleep(10) campaignReplyStats = dbCallsAuthorize.getVenenoReplyStats( communicationDetailsId) Assertion.constructAssertion( len(campaignReplyStats) != 0, 'Campaign Reply Stats update status {}'.format( len(campaignReplyStats))) authorize.assertUserPresenceInNsAdminTable( communicationDetailsId, communicationDetailBucketId, int(communicationDetailExpectedCount), verify=False, waitForInboxMsg=True) communcationDetailsDict = dbCallsAuthorize.getCommunicationDetailsWithId( communicationDetailsId) Assertion.constructAssertion( communcationDetailsDict['state'] == 'REPLAYED', 'Communication Details MessageId state is Actual: {} and Expected: {}' .format(communcationDetailsDict['state'], 'REPLAYED')) Assertion.constructAssertion( communcationDetailsDict['expected_delivery_count'] == int( communicationDetailExpectedCount), 'Communication Details Expected Delivery count Actual: {} and Expected: {}' .format(communcationDetailsDict['expected_delivery_count'], int(communicationDetailExpectedCount))) Assertion.constructAssertion( communcationDetailsDict['message_queue_id'] != 0, 'Communication Details Message Queue Id is not 0 Actual: {}'. format(communcationDetailsDict['message_queue_id']))
def test_LUCI_IC_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) 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 couponCode = LuciHelper.uploadCouponAndAssertions( self, couponSeriesId, self.constructObj.importType['USER_ID'], issuedTo=self.userId, dracraysUpload={'userOnly': True})['coupons'][0] couponCode1 = LuciHelper.issueCouponAndAssertions( self, couponSeriesId, issueCouponParamObj={'storeUnitId': constant.config['adminId']})[0] Assertion.constructAssertion( couponCode.upper() == couponCode1, 'Resend coupon code resend Actual : {} & Expected : {}'.format( couponCode, couponCode1)) couponCode2 = LuciHelper.issueCouponAndAssertions( self, couponSeriesId, couponIssuedCount=2, issueCouponParamObj={'storeUnitId': constant.config['adminId']})[0] Assertion.constructAssertion( couponCode1 == couponCode2, 'Resend coupon code resend Actual : {} & Expected : {}'.format( couponCode1, couponCode2))
def validateEntryInCron(self, cronId, messageVariantId): Assertion.constructAssertion(cronId != 0, 'CronId is :{}'.format(cronId)) cronDetails = message_calls().getCronDetails(cronId) Assertion.constructAssertion( cronDetails['component'] == 'CAMPAIGN', 'Component Name In DB :{} and Expected : CAMPAIGN'.format( cronDetails['component'])) cronParams = json.loads(cronDetails['params']) Assertion.constructAssertion( cronParams['messageVariantId'] == messageVariantId, 'Params Of Cron Details have messageVariantId in DB :{} and expected from Mongo :{}' .format(cronParams['messageVariantId'], messageVariantId))
def test_LUCI_IC_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': 3 }) 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'], noOfCouponsToBeUpload=3) LuciHelper.issueCouponAndAssertions(self, couponSeriesId) LuciHelper.issueCouponAndAssertions(self, couponSeriesId) LuciHelper.issueCouponAndAssertions(self, couponSeriesId) luciExp = LuciHelper.issueCouponAndAssertions(self, couponSeriesId, expectException=True) Assertion.constructAssertion( luciExp['errorCode'] == constant.MAX_COUPON_ISSUAL_PER_USER_EXCEEDED, 'Luci Exception error code Actual: {} and Expected: {}'.format( luciExp['errorCode'], constant.MAX_COUPON_ISSUAL_PER_USER_EXCEEDED)) Assertion.constructAssertion( luciExp['errorMsg'] == 'max coupon per user exceeded', 'Luci Exception Error Msg Actual : {}'.format(luciExp['errorMsg']))