def test_irisV2_editCampaign_NegativeCase_Lapsed(self, campaignTypeFirst, testControlTypeFirst, campaignTypeSecond, testControlTypeSecond, statusCode, errorCode): campaignInfo1 = CreateCampaign.create(campaignTypeFirst, testControlTypeFirst, updateNode=True, lockNode=True) campaignInfo = CreateCampaign.create(campaignTypeSecond, testControlTypeSecond, updateNode=True, lockNode=True) editInfo = CreateCampaign.edit(campaignInfo, {'name': campaignInfo1['NAME']}) Assertion.constructAssertion( editInfo['RESPONSE']['statusCode'] == statusCode, 'Actual Status Code :{} and Expected : {}'.format( editInfo['RESPONSE']['statusCode'], statusCode)) Assertion.constructAssertion( editInfo['RESPONSE']['json']['errors'][0]['code'] in errorCode, 'Actual Error Code :{} and Expected : {}'.format( editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode)) Assertion.constructAssertion( 'Campaign Date Exception : Campaign is already expired on' in editInfo['RESPONSE']['json']['errors'][0]['message'] or "Campaign Name Exception : Campaign Name already exists" in editInfo['RESPONSE']['json']['errors'][0]['message'] or "Campaign Name Exception : Changing campaign name is not allowed." in editInfo['RESPONSE']['json']['errors'][0]['message'], 'Actual Error Code :{} and Expected : {}'.format( editInfo['RESPONSE']['json']['errors'][0]['message'], editInfo['RESPONSE']['json']['errors'][0]['message']))
def test_irisv2_getMessageVariant_create_upload_mobile_immediate_plain_lapsed( self, campaignType, testControlType, listType, channel, messageInfo): CreateCampaign.create( campaignType, testControlType, endDate=int(time.time() * 1000) + 5 * 60 * 1000) # Extending Campaign for 5 Mins to set message CreateMessage.create(campaignType, testControlType, listType, channel, messageInfo) campaignId = constant.config['node'][campaignType][testControlType][ 'CAMPAIGN']['ID'] messageId = constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'][ messageInfo['scheduleType']['type']][messageInfo['offerType']][ 'RESPONSE']['json']['entity']['id'] for eachType in ['MESSAGE_TARGET_AUDIENCE', 'VARIANT_CREATION']: status = message_calls().waitForJobDetailsStatusToClose( messageId, eachType, maxNumberOfAttempts=20) if status: getMessageResponse = GetMessage.getMessageVariantById( campaignId, message_calls().getVariantIdByMessageId(messageId)) GetMessage.assertResponse(getMessageResponse, 200) VariantDBAssertion(campaignId, messageId, [getMessageResponse['json']['entity']]).check() else: Assertion.constructAssertion( False, 'Variant_Creation is Not Closed in Specified time')
def irisv2_message_create_upload_mobile_immediate_plain_lapsed(self, campaignType, testControlType, listType, channel, messageInfo): CreateCampaign.create(campaignType, testControlType, endDate=int( time.time() * 1000) + 5 * 60 * 1000) # Extending Campaign for 5 Mins to set message messageDetails = CreateMessage.create(campaignType, testControlType, listType, channel, messageInfo) CreateMessage.assertResponse(messageDetails['RESPONSE'], 200) CreateMessageDBAssertion(constant.config['node'][campaignType][testControlType]['CAMPAIGN']['ID'], messageDetails['RESPONSE']['json']['entity']['id'], messageDetails['PAYLOAD']).check()
def irisv2_message_execute_upload_mobile_immediate_plain_lapsed(self, campaignType, testControlType, listType, channel, messageInfo): CreateCampaign.create(campaignType, testControlType, endDate=int( time.time() * 1000) + 1 * 60 * 1000) messageDetails = CreateMessage.create(campaignType, testControlType, listType, channel, messageInfo) approveRespone = AuthorizeMessage.approve(campaignType, testControlType, listType, channel, messageInfo, messageCreateResponse=messageDetails) AuthorizeMessage.assertResponse(approveRespone, 400, expectedErrorCode=3036, expectedErrorMessage=['Campaign expired'])
def test_irisv2_message_edit_recurring_live_create_plain_mobile_editMessage_with_campaignId_of_another_campaign( self, campaignType, testControlType, listType, channel, messageInfo, statusCode, errorCode, errorDescription): messageDetails = CreateMessage.create(campaignType, testControlType, listType, channel, messageInfo, updateNode=True, lockNode=True) CreateMessage.assertResponse(messageDetails['RESPONSE'], 200) message_calls().waitForJobDetailsStatusToClose( messageDetails['RESPONSE']['json']['entity']['id'], 'VARIANT_CREATION') campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) editInfo = CreateMessage.edit( campaignInfo['ID'], messageDetails['RESPONSE']['json']['entity']['id'], messageDetails['PAYLOAD']) CreateMessage.assertResponse( editInfo['RESPONSE'], 400, expectedErrorCode=[errorCode], expectedErrorMessage=errorDescription.format( messageDetails['RESPONSE']['json']['entity']['id']))
def test_irisV2_editCampaignStartDate_AftereCreatingMessage( self, description, campaignType, testControlType, channel, messageInfo, editInfo, statusCode, errorCode, errorDescription): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) messageDetails = CreateMessage.create(campaignType, testControlType, 'LOYALTY', channel, messageInfo, campaignId=campaignInfo['ID'], updateNode=True) campaignInfo = constant.config['node'][campaignType][testControlType][ 'CAMPAIGN'] CreateMessage.assertResponse(messageDetails['RESPONSE'], 200) editInfo = CreateCampaign.edit(campaignInfo, editInfo) Assertion.constructAssertion( editInfo['RESPONSE']['statusCode'] == statusCode, 'Actual Status Code :{} and Expected : {}'.format( editInfo['RESPONSE']['statusCode'], statusCode)) Assertion.constructAssertion( editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode, 'Actual Error Code :{} and Expected : {}'.format( editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode)) Assertion.constructAssertion( editInfo['RESPONSE']['json']['errors'][0]['message'] in errorDescription, 'Actual Error Code :{} and Expected : {}'.format( editInfo['RESPONSE']['json']['errors'][0]['message'], errorDescription))
def test_irisV2_editCampaign_NegativeOrgId(self, description, campaignType, testControlType, editInfo, statusCode, errorCode, errorDescription): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) actualOrgId = constant.config['orgId'] try: constant.config['orgId'] = -99999 editInfo = CreateCampaign.edit(campaignInfo, editInfo) Assertion.constructAssertion( editInfo['RESPONSE']['statusCode'] == statusCode, 'Actual Status Code :{} and Expected : {}'.format( editInfo['RESPONSE']['statusCode'], statusCode)) Assertion.constructAssertion( editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode, 'Actual Error Code :{} and Expected : {}'.format( editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode)) Assertion.constructAssertion( errorDescription == editInfo['RESPONSE']['json']['errors'][0] ['message'], 'Expected Error message :{} and Actual : {}'.format( errorDescription, editInfo['RESPONSE']['json']['errors'][0]['message'])) finally: constant.config['orgId'] = actualOrgId
def test_irisv2_message_execute_loyalty_mobile_email_recurring_immediate_particulardate_allOffer_live_current( self, campaignType, testControlType, listType, channel, messageInfo): campaignId = CreateCampaign.create(campaignType, testControlType, updateNode=True, lockNode=True)['ID'] approveRespone = AuthorizeMessage.approve(campaignType, testControlType, listType, channel, messageInfo, campaignId=campaignId) AuthorizeMessage.assertResponse(approveRespone, 200) campaignId = campaignId response = constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'][messageInfo['scheduleType'][ 'type']][messageInfo['offerType']]['RESPONSE'] payload = constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'][messageInfo['scheduleType'][ 'type']][messageInfo['offerType']]['PAYLOAD'] AuthorizeMessageDBAssertion(campaignId, response, payload, testControlType).check()
def test_irisv2_message_execute_loyalty_mobile_coupon_recurring_ProdSanity( self, campaignType, testControlType, listType, channel, messageInfo): campaignId = CreateCampaign.create(campaignType, testControlType, updateNode=True, lockNode=True)['ID'] couponSeriesId = CreateMessage.getCouponSeriesId(campaignId) approveRespone = AuthorizeMessage.approve( campaignType, testControlType, listType, channel, messageInfo, campaignId=campaignId, couponSeriesId=couponSeriesId) AuthorizeMessage.assertResponse(approveRespone, 200) campaignId = campaignId response = constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'][messageInfo['scheduleType'][ 'type']][messageInfo['offerType']]['RESPONSE'] payload = constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'][messageInfo['scheduleType'][ 'type']][messageInfo['offerType']]['PAYLOAD'] AuthorizeMessageDBAssertion(campaignId, response, payload, testControlType).check()
def test_irisV2_editCampaign_Sanity(self, description, campaignType, testControlType, editInfo): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) editInfo = CreateCampaign.edit(campaignInfo, editInfo) CreateCampaign.assertResponse(editInfo['RESPONSE'], 200) CampaignCheckDBAssertion(campaignInfo['ID'], editInfo['PAYLOAD']).check()
def test_irisv2_getMessage_create_mobilePush_id_immediate_plain_lapsed( self, campaignType, testControlType, listType, channel, messageInfo): CreateCampaign.create(campaignType, testControlType, endDate=int(time.time() * 1000) + 5 * 60 * 1000) CreateMessage.create(campaignType, testControlType, listType, channel, messageInfo) campaignId = constant.config['node'][campaignType][testControlType][ 'CAMPAIGN']['ID'] messageId = constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'][ messageInfo['scheduleType']['type']][messageInfo['offerType']][ 'RESPONSE']['json']['entity']['id'] getMessageResponse = GetMessage.getMessageById(campaignId, messageId) GetMessage.assertResponse(getMessageResponse, 200) CreateMessageDBAssertion(campaignId, messageId, getMessageResponse['json']['entity']).check()
def test_irisV2_editCampaign_name(self, description, campaignType, testControlType, editInfo): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) editInfo = CreateCampaign.edit(campaignInfo, editInfo) CreateCampaign.assertResponse( editInfo['RESPONSE'], 400, expectedErrorCode=1003, expectedErrorMessage= "Campaign Name Exception : Changing campaign name is not allowed.")
def test_getMessage_negative_validationMessage_withCampaignId_differentCampaign( self): campaignInfo = CreateCampaign.create('LIVE', 'CUSTOM') diffId = campaignInfo['ID'] response = GetMessage.getMessageById( diffId, self.messageDetails['RESPONSE']['json']['entity']['id'], queryParam=[('includeAudience', '$$$$$$')]) GetMessage.assertResponse( response, 400, 3023, 'Message with message id {} does not exists'.format( self.messageDetails['RESPONSE']['json']['entity']['id']))
def test_irisV2_getCampaign_ID_wrongAuth(self): previousUserName = None try: payload = copy.deepcopy(constant.payload['createcampaignv2']) payload.update({'name': 'test_irisV2_getCampaign_ID_wrongAuth_{}'.format(int(time.time()))}) payload["testControl"].pop("testPercentage") campaignInfo = CreateCampaign.create('LIVE', 'ORG', payload=payload, updateNode=True, lockNode=True) previousUserName = IrisHelper.updateUserName('WrongName') getCampaignInfoResponse = GetCampaign.getById(campaignInfo['ID']) GetCampaign.assertResponse(getCampaignInfoResponse, 401, 999999, 'Unauthorized') except Exception, exp: Assertion.constructAssertion(False, 'Exception :{}'.format(exp))
def test_irisv2_messageStatus_push_particulardate_Approved_Stopt( self, campaignType, testControlType, listType, channel, messageInfo): try: actualOrgId = IrisHelper.updateOrgId( constant.config['mobilepush']['orgId']) actualOrgName = IrisHelper.updateOrgName( constant.config['mobilepush']['orgName']) campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True, lockNode=True) messageDetails = CreateMessage.create( campaignType, testControlType, listType, channel, messageInfo, campaignId=campaignInfo['ID'], updateNode=True) CreateMessage.assertResponse(messageDetails['RESPONSE'], 200) message_calls().waitForJobDetailsStatusToClose( messageDetails['RESPONSE']['json']['entity']['id'], 'VARIANT_CREATION') approveRespone = AuthorizeMessage.approve( campaignType, testControlType, listType, channel, messageInfo, campaignId=campaignInfo['ID'], messageCreateResponse=messageDetails) AuthorizeMessage.assertResponse(approveRespone, 200) stopResponse = CreateMessage.stop( campaignInfo['ID'], approveRespone['json']['entity']['messageId']) CreateMessage.assertResponse(stopResponse, 200) CreateMessageDBAssertion( campaignInfo['ID'], messageDetails['RESPONSE']['json']['entity']['id'], messageDetails['PAYLOAD'], reject={ 'status': 'CLOSED' }, approved='STOPPED').check() finally: IrisHelper.updateOrgId(actualOrgId) IrisHelper.updateOrgName(actualOrgName)
def setup_class(self): messageInfo = { 'scheduleType': { 'type': 'IMMEDIATE' }, 'offerType': 'PLAIN', 'messageStrategy': { 'type': 'DEFAULT' }, 'channels': ['SMS', 'EMAIL'], 'useTinyUrl': False, 'encryptUrl': False, 'skipRateLimit': True } self.campaignInfo = CreateCampaign.create('LIVE', 'ORG') self.messageDetails = CreateMessage.create('LIVE', 'ORG', 'UPLOAD', 'EMAIL', messageInfo)
def test_approveMessage_negative_validationMessage_different_campaignId( self): campaignInfo = CreateCampaign.create('LIVE', 'CUSTOM') diffId = campaignInfo['ID'] responseAuthorize = AuthorizeMessage.approveWithCampaignAndMessageId( diffId, self.messageDetails['RESPONSE']['json']['entity']['id']) messageId = self.messageDetails['RESPONSE']['json']['entity']['id'] AuthorizeMessage.assertResponse( responseAuthorize, 400, expectedErrorCode=3023, expectedErrorMessage=[ 'Message with message id {} does not exists'.format(messageId) ])
def test_irisV2_getCampaign_byId_for_Objective_and_GA(self, campaignType, testControlType): payload = copy.deepcopy(constant.payload['createcampaignv2']) payload.update({ "name": "Automation_IRISV2_{}".format(int(time.time() * 1000)), "objective": { "objectiveName": "Boost_Sales" }, "gaEnabled": "true", "gaSource": "test gaSource", "gaName": "test gaName" }) payload["testControl"].pop("testPercentage") campaignInfo = CreateCampaign.create(campaignType, testControlType, payload=payload, updateNode=True, lockNode=True) getCampaignInfoResponse = GetCampaign.getById(campaignInfo['ID']) GetCampaign.assertResponse(getCampaignInfoResponse, 200) GetCampaignDBAssertion(campaignInfo['ID'], getCampaignInfoResponse).check()
def test_irisV2_editCampaign_WrongAuth(self, description, campaignType, testControlType, editInfo, statusCode, errorCode, errorDescription): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) previousUserName = None try: previousUserName = IrisHelper.updateUserName('WrongName') editInfo = CreateCampaign.edit(campaignInfo, editInfo) Assertion.constructAssertion( editInfo['RESPONSE']['statusCode'] == statusCode, 'Actual Status Code :{} and Expected : {}'.format( editInfo['RESPONSE']['statusCode'], statusCode)) finally: if previousUserName is not None: IrisHelper.updateUserName(previousUserName)
def create(campaignType, testControlType, channel, numberOfIdentifiers, numberOfCustomTag=0, campaignId=None, payload=None, messageBody=None, couponEnabled=None, pointsEnabled=None): campaignInfo = CreateCampaign.create(campaignType, testControlType) campaignId = campaignInfo['ID'] if campaignId is None else campaignId endPoint = IrisHelper.constructUrl('testpreview').replace('{campaignId}', str(campaignId)) payload = TestPreview.createPayload(campaignType, testControlType, channel, numberOfIdentifiers, numberOfCustomTag=numberOfCustomTag, messageBody=messageBody, couponEnabled=couponEnabled, pointsEnabled=pointsEnabled) if payload is None else payload response = IrisHelper.constructResponse( Utils.makeRequest(url=endPoint, data=payload, auth=IrisHelper.constructAuthenticate(), headers=IrisHelper.constructHeaders(), method='POST') ) return response, payload
def test_irisv2_recurring_campaign_performance(self, campaignType, testControlType, listType, channel, messageInfo): #campaignId = CreateCampaign.create(campaignType, testControlType, updateNode=True, lockNode=True)['ID'] #couponSeriesId = CreateMessage.getCouponSeriesId(campaignId) #approveRespone = AuthorizeMessage.approve(campaignType, testControlType, listType, channel, messageInfo,lockNode=True) #AuthorizeMessage.assertResponse(approveRespone, 200) campaignId = CreateCampaign.create(campaignType, testControlType)['ID'] #listInfo = CreateAudience.FilterList(campaignType, testControlType, lockNode=True) detailsOfFilterListCreated = CampaignShardHelper.createFilterListWithCreateGroupRecipient( ) listInfo = detailsOfFilterListCreated['groupDetails'] approveRespone = AuthorizeMessage.approve(campaignType, testControlType, listType, channel, messageInfo, campaignId=campaignId, listInfo=listInfo, lockNode=True) AuthorizeMessage.assertResponse(approveRespone, 200)
def test_irisv2_message_execute_upload_push_immediate_coupon_live_pushThread( self, campaignType, testControlType, listType, channel, messageInfo): try: actualOrgId = IrisHelper.updateOrgId( constant.config['mobilepush']['orgId']) actualOrgName = IrisHelper.updateOrgName( constant.config['mobilepush']['orgName']) campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True, lockNode=True) couponSeriesId = CreateMessage.getCouponSeriesId( campaignInfo['ID']) approveRespone = AuthorizeMessage.approve( campaignType, testControlType, listType, channel, messageInfo, campaignId=campaignInfo['ID'], couponSeriesId=couponSeriesId) AuthorizeMessage.assertResponse(approveRespone, 200) campaignId = campaignInfo['ID'] response = constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'][ messageInfo['scheduleType']['type']][ messageInfo['offerType']]['RESPONSE'] payload = constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'][ messageInfo['scheduleType']['type']][ messageInfo['offerType']]['PAYLOAD'] AuthorizeMessageDBAssertion(campaignId, response, payload, testControlType).check() finally: IrisHelper.updateOrgId(actualOrgId) IrisHelper.updateOrgName(actualOrgName)
def test_irisV2_editCampaign_NegativeCase_EditStartDate( self, description, campaignType, testControlType, editInfo, statusCode, errorCode, errorDescription): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) CampaignCheckDBAssertion(campaignInfo['ID'], campaignInfo['PAYLOAD']).check() editInfo = CreateCampaign.edit(campaignInfo, editInfo) Assertion.constructAssertion( editInfo['RESPONSE']['statusCode'] == statusCode, 'Actual Status Code :{} and Expected : {}'.format( editInfo['RESPONSE']['statusCode'], statusCode)) Assertion.constructAssertion( editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode, 'Actual Error Code :{} and Expected : {}'.format( editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode)) Assertion.constructAssertion( errorDescription == editInfo['RESPONSE']['json']['errors'][0] ['message'], 'Expected Error message :{} and Actual : {}'.format( errorDescription, editInfo['RESPONSE']['json']['errors'][0]['message']))
def test_irisV2_editCampaign_NegativeCase_EditEndDate( self, description, campaignType, testControlType, editInfo, statusCode, errorCode, errorDescription): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) CampaignCheckDBAssertion(campaignInfo['ID'], campaignInfo['PAYLOAD']).check() editInfo = CreateCampaign.edit(campaignInfo, editInfo) Assertion.constructAssertion( statusCode == editInfo['RESPONSE']['statusCode'], 'Error status actual {} and expected {}'.format( statusCode, editInfo['RESPONSE']['statusCode'])) Assertion.constructAssertion( errorCode == editInfo['RESPONSE']['json']['errors'][0]['code'], 'Error status actual {} and expected {}'.format( errorCode, editInfo['RESPONSE']['json']['errors'][0]['code'])) Assertion.constructAssertion( errorDescription in editInfo['RESPONSE']['json']['errors'][0]['message'], 'Error message expected {} and actual {}'.format( errorDescription, editInfo['RESPONSE']['json']['errors'][0]['message']))
def test_irisV2_editCampaign_AftereCreatingMessage(self, description, campaignType, testControlType, channel, messageInfo, editInfo): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) messageDetails = CreateMessage.create(campaignType, testControlType, 'LOYALTY', channel, messageInfo, campaignId=campaignInfo['ID'], updateNode=True) campaignInfo = constant.config['node'][campaignType][testControlType][ 'CAMPAIGN'] CreateMessage.assertResponse(messageDetails['RESPONSE'], 200) editInfo = CreateCampaign.edit(campaignInfo, editInfo) CreateCampaign.assertResponse(editInfo['RESPONSE'], 200) CampaignCheckDBAssertion(campaignInfo['ID'], editInfo['PAYLOAD']).check()
def test_irisV2_editCampaign_Name_AftereCreatingMessage( self, description, campaignType, testControlType, channel, messageInfo, editInfo): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True) messageDetails = CreateMessage.create(campaignType, testControlType, 'LOYALTY', channel, messageInfo, campaignId=campaignInfo['ID'], updateNode=True) campaignInfo = constant.config['node'][campaignType][testControlType][ 'CAMPAIGN'] CreateMessage.assertResponse(messageDetails['RESPONSE'], 200) editInfo = CreateCampaign.edit(campaignInfo, editInfo) CreateCampaign.assertResponse( editInfo['RESPONSE'], 400, expectedErrorCode=1003, expectedErrorMessage= "Campaign Name Exception : Changing campaign name is not allowed.")
def create(campaignType, testControlType, listType, channel, messageInfo={}, listInfo=None, campaignId=None, newUser=True, messageType='OUTBOUND', payload=None, targetAudience=None, scheduleType=None, messageStrategy=None, messageContent=None, updateNode=False, lockNode=False, storeType='REGISTERED_STORE', numberOfCustomTag=0, derivedListInfo=None, maxUser=[], remindParams=None, couponSeriesId=None): if not CreateMessage.checkMessageAvialable( campaignType, testControlType, listType, channel, messageInfo['scheduleType']['type'], messageInfo['offerType']) or updateNode: campaignInfo = CreateCampaign.create(campaignType, testControlType) listInfo = CreateMessage.getListInfo( campaignType, testControlType, listType, channel, newUser, derivedListInfo) if listInfo is None else listInfo if listType == 'REMIND': if 'parentMessageId' not in remindParams and remindParams[ 'parentMessageId'] is None and 'reminderStrategy' not in remindParams and remindParams[ 'reminderStrategy'] is None: raise Exception('RequiredParamsMissingToConstructReminder') targetAudience = { 'isDef': True, 'includeDefinition': { 'defType': 'parentMsgReminder', 'parentMessageId': remindParams['parentMessageId'], 'reminderStrategy': remindParams['reminderStrategy'] }, 'orgUsers': [] if 'orgUsers' not in remindParams else remindParams['orgUsers'] } if listType == 'ORG_USERS': targetAudience = { 'include': [constant.config['FilterListID']], 'orgUsers': [listInfo['ID']], 'exclude': [] } campaignId = str( campaignInfo['ID']) if campaignId is None else campaignId endPoint = IrisHelper.constructUrl('createmessage').replace( '{campaignId}', str(campaignId)) payload = CreateMessage.constructPayload( campaignType, testControlType, messageInfo, listInfo, channel, messageType, numberOfCustomTag=numberOfCustomTag, targetAudience=targetAudience, scheduleType=scheduleType, messageStrategy=messageStrategy, messageContent=messageContent, storeType=storeType, maxUser=maxUser, remindParams=remindParams, couponSeriesId=couponSeriesId) if payload is None else payload Logger.log( 'Final Payload Used to Create Message :{}'.format(payload)) if campaignType == 'UPCOMING' and messageInfo['scheduleType'][ 'type'] == 'IMMEDIATE': for _ in range(30): Logger.log( 'Upcoming Campaign , is not Yet Live current time :{} and startDate of Campaign is :{}' .format(int(time.time() * 1000), campaignInfo['PAYLOAD']['startDate'])) if campaignInfo['PAYLOAD']['startDate'] > int( time.time() * 1000): time.sleep(5) else: break timeout = 30 if remindParams is None else 180 response = IrisHelper.constructResponse( Utils.makeRequest(url=endPoint, data=payload, auth=IrisHelper.constructAuthenticate(), headers=IrisHelper.constructHeaders(), timeout=timeout, method='POST')) if response['statusCode'] == 200: CreateMessage.validateCreateMessageResponse(response) if not lockNode: CreateMessage.updateMessageNode( campaignType, testControlType, listType, channel, messageInfo['scheduleType']['type'], messageInfo['offerType'], response, payload) if campaignType == 'LAPSED': time.sleep(2 * 60) return {'PAYLOAD': payload, 'RESPONSE': response} else: return {'RESPONSE': response, 'PAYLOAD': payload} else: return constant.config['node'][campaignType][testControlType][ 'LIST'][listType][channel]['MESSAGE'] [messageInfo['scheduleType']['type']][messageInfo['offerType']]
def test_irisV2_getCampaign_ID_differentTestPercentage(self, campaignType, testControlType, testPercentage): campaignInfo = CreateCampaign.create('LIVE', 'ORG', testControlPercentage=testPercentage, updateNode=True, lockNode=True) getCampaignInfoResponse = GetCampaign.getById(campaignInfo['ID']) GetCampaign.assertResponse(getCampaignInfoResponse, 200) GetCampaignDBAssertion(campaignInfo['ID'], getCampaignInfoResponse).check()
def test_irisv2_getStatusBy_campaignId_Sanity(self, campaignType, testControlType, channel, messageInfo, queryParam): campaignInfo = CreateCampaign.create(campaignType, testControlType, updateNode=True, lockNode=True) Logger.log('campaign id is', campaignInfo['ID']) messageDetails = CreateMessage.create(campaignType, testControlType, 'LOYALTY', channel, messageInfo, campaignId=campaignInfo['ID'], 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, campaignId=campaignInfo['ID']) AuthorizeMessage.assertResponse(approveRespone, 200) messageDetails = CreateMessage.create(campaignType, testControlType, 'LOYALTY', channel, messageInfo, campaignId=campaignInfo['ID'], 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, campaignId=campaignInfo['ID']) AuthorizeMessage.assertResponse(approveRespone, 200) time.sleep(150) message_calls().getCommunicationDetailsWithOnlyMessageId( approveRespone['json']['entity']['messageId']) response = GetMonitoringDetails.getByCampaignId( campaignInfo['ID'], queryParam) actualResponse, expectedResponse = GetMonitoringDetails.formatingMonitorDetails( response, isScheduledMsg=False, isDeliveryBreakEnabled=True) Assertion.constructAssertion( actualResponse == expectedResponse, 'Monitoring Details response Matched Actual: {} and Expected: {}'. format(actualResponse, expectedResponse))
def test_irisV2_getCampaign_ID(self, campaignType, testControlType): campaignInfo = CreateCampaign.create(campaignType, testControlType) getCampaignInfoResponse = GetCampaign.getById(campaignInfo['ID']) GetCampaign.assertResponse(getCampaignInfoResponse, 200) GetCampaignDBAssertion(campaignInfo['ID'], getCampaignInfoResponse).check()