Example #1
0
    def test_campaignShardThrift_dedupList_multipleList_newVersion(
            self, campaignType, audienceTypeFirst, audienceTypeSecond,
            audienceTypeThird, listType):
        existingListFirst = constant.thiriftCampaignShardTestReferenceObject[
            campaignType]['campaign']['lists'][audienceTypeFirst][0]
        existingListSecond = constant.thiriftCampaignShardTestReferenceObject[
            campaignType]['campaign']['lists'][audienceTypeSecond][0]
        existingListThird = constant.thiriftCampaignShardTestReferenceObject[
            campaignType]['campaign']['lists'][audienceTypeThird][1]
        userPayloadInfo = CampaignShardHelper.loyaltyUserDataConstructHelper()
        listOfGroupIdNamePair = [
            self.campaignShardObject.GroupIdNamePair(
                existingListFirst['groupDetails']['id'],
                existingListFirst['groupLabel']),
            self.campaignShardObject.GroupIdNamePair(
                existingListSecond['groupDetails']['id'],
                existingListSecond['groupLabel']),
            self.campaignShardObject.GroupIdNamePair(
                existingListThird['groupDetails']['id'],
                existingListThird['groupLabel'])
        ]

        groupIdsOfListCreated = self.connObj.createList(
            constant.thiriftCampaignShardTestReferenceObject[campaignType]
            ['campaign']['id'], self.campaignShardObject.ListType[listType],
            self.campaignShardObject.ListInfo(
                listType.lower(), {
                    'createNewGroups': False,
                    'groupIdNameList': listOfGroupIdNamePair
                }))

        CampaignShardDBAssertion(
            constant.thiriftCampaignShardTestReferenceObject[campaignType]
            ['campaign']['id'],
            campaignType,
            'upload',
            existingListSecond['groupLabel'],
            groupIdsOfListCreated[0],
            existingListFirst['addRecipientPayload']['schema'],
            list(
                set(userPayloadInfo) -
                set(existingListFirst['addRecipientPayload']['data'])),
            derived=True).check()
        CampaignShardDBAssertion(
            constant.thiriftCampaignShardTestReferenceObject[campaignType]
            ['campaign']['id'],
            campaignType,
            'upload',
            existingListThird['groupLabel'],
            groupIdsOfListCreated[1],
            existingListFirst['addRecipientPayload']['schema'],
            list(
                set(userPayloadInfo) - set(userPayloadInfo) -
                set(existingListFirst['addRecipientPayload']['data'])),
            derived=True).check()
Example #2
0
 def test_campaignShard_upload_paste_mobile_groupTags(
         self, campaignType, userType, numberOfUsers, groupTags):
     createListresponse, createListPayload, campaignId = campaignList.createList(
         {
             'groupTags': groupTags,
             'name': 'CAMPAIGNSHARD_LIST_' + str(int(time.time() * 100000))
         },
         campaignId=self.campaignId[campaignType])
     if createListresponse['statusCode'] != 200:
         Assertion.constructAssertion(False, 'Not Able To Create List')
     addRecipientResponse, addRecipientPayload = campaignList.addRecipient(
         {},
         campaignId,
         createListresponse['json']['entity']['listId'],
         str(userType),
         int(numberOfUsers),
         0,
         newUser=False)
     if addRecipientResponse['statusCode'] != 200:
         Assertion.constructAssertion(False, 'Not Able To Add Recipient')
     CampaignShardDBAssertion(
         self.campaignId[campaignType],
         campaignType,
         'upload',
         createListPayload['name'],
         createListresponse['json']['entity']['listId'],
         addRecipientPayload['schema'],
         addRecipientPayload['data'],
         numberOfCustomTags=0,
         numberOfGroupTags=len(groupTags)).check()
Example #3
0
 def test_campaignShardThrift_mergeList_upload_filterBased(
         self, campaignType, audienceTypeFirst, audienceTypeSecond,
         listType):
     existingListFirst = constant.thiriftCampaignShardTestReferenceObject[
         campaignType]['campaign']['lists'][audienceTypeFirst][0]
     existingListSecond = constant.thiriftCampaignShardTestReferenceObject[
         campaignType]['campaign']['lists'][audienceTypeSecond][0]
     userPayloadInfo = CampaignShardHelper.loyaltyUserDataConstructHelper()
     groupIdsOfListCreated = self.connObj.createList(
         constant.thiriftCampaignShardTestReferenceObject[campaignType]
         ['campaign']['id'], self.campaignShardObject.ListType[listType],
         self.campaignShardObject.ListInfo(
             listType.lower(), {
                 'newGroupName':
                 'Merge_' + existingListFirst['groupLabel'] + '_And_' +
                 existingListSecond['groupLabel'],
                 'oldGroupIdList': [
                     existingListFirst['groupDetails']['id'],
                     existingListSecond['groupDetails']['id']
                 ]
             }))
     CampaignShardDBAssertion(
         constant.thiriftCampaignShardTestReferenceObject[campaignType]
         ['campaign']['id'],
         campaignType,
         'upload',
         'Merge_' + existingListFirst['groupLabel'] + '_And_' +
         existingListSecond['groupLabel'],
         groupIdsOfListCreated[0],
         existingListFirst['addRecipientPayload']['schema'],
         list(
             set(existingListFirst['addRecipientPayload']['data'] +
                 userPayloadInfo)),
         derived=True).check()
Example #4
0
 def test_campaignShardThrfit_splitList_filterBased(self, campaignType,
                                                    audienceType, listType):
     existingList = constant.thiriftCampaignShardTestReferenceObject[
         campaignType]['campaign']['lists'][audienceType][0]
     splitA = self.campaignShardObject.SplitGroup(
         'splitA_{}'.format(existingList['groupLabel']), 50)
     splitB = self.campaignShardObject.SplitGroup(
         'splitB_{}'.format(existingList['groupLabel']), 50)
     listOfSplit = [splitA, splitB]
     userPayloadInfo = CampaignShardHelper.loyaltyUserDataConstructHelper()
     groupIdsOfListCreated = self.connObj.createList(
         constant.thiriftCampaignShardTestReferenceObject[campaignType]
         ['campaign']['id'], self.campaignShardObject.ListType[listType],
         self.campaignShardObject.ListInfo(
             listType.lower(), {
                 'oldGroupId': existingList['groupDetails']['id'],
                 'splitGroupsList': listOfSplit
             }))
     groupIndex = 0
     for eachCreatedListData in CampaignShardHelper.splitListUsers(
             campaignType, userPayloadInfo):
         CampaignShardDBAssertion(
             constant.thiriftCampaignShardTestReferenceObject[campaignType]
             ['campaign']['id'],
             campaignType,
             'loyalty',
             listOfSplit[groupIndex].newGroupName,
             groupIdsOfListCreated[groupIndex],
             'firstName,lastName,mobile',
             eachCreatedListData,
             derived=True).check()
         groupIndex = groupIndex + 1
    def test_campaignShardThrift_AudienceGroup_Async_CreateAudience_Reload_Sanity(
            self, audienceType):
        createAudienceRequest = campaignShardObject.createAudienceRequest(
            audienceType=audienceType)
        audiencecGroupEntity = self.connObj.createAudienceGroup(
            createAudienceRequest).__dict__
        createAudienceWithGroupId = campaignShardObject.createAudienceRequest(
            {'groupId': audiencecGroupEntity['id']}, audienceType=audienceType)
        createAudienceResponse = self.connObj.createAudience(
            createAudienceWithGroupId).__dict__

        groupDetailsVersionInfo = dbCallsList.getGroupVersionDetailsWithGroupId(
            audiencecGroupEntity['id'])
        s3InfoForUsedList = CampaignShardHelper.getS3Info(
            createAudienceResponse['uuId'])
        thriftCampaignGroup = lambda campaignTargetType: campaignShardObject(
        ).CampaignGroup({
            'groupId':
            audiencecGroupEntity['id'],
            'groupLabel':
            createAudienceResponse['label'],
            'params':
            str(),
            'campaignGroupType':
            'FILTER_BASED',
            'campaignTargetType':
            'TEST',
            'customerCount':
            groupDetailsVersionInfo['TEST']['customer_count'],
            'uuId':
            createAudienceResponse['uuId'],
            'versionNumber':
            1,
            's3Path':
            s3InfoForUsedList['response']['data']['s3Path'],
            's3Headers':
            s3InfoForUsedList['response']['data']['s3Header'],
            's3BucketTag':
            s3InfoForUsedList['response']['data']['s3Path'].split('/')[2]
        })

        for eachTargetType in ['TEST']:
            if not self.connObj.reloadGroup(
                    thriftCampaignGroup(eachTargetType)):
                Logger.log(
                    'For TargetType :{} , reload was unsuccesfull'.format(
                        eachTargetType))
        userPayloadInfo = CampaignShardHelper.loyaltyUserDataConstructHelper()
        CampaignShardDBAssertion(99999,
                                 'org',
                                 'FILTER_BASED',
                                 createAudienceResponse['label'],
                                 audiencecGroupEntity['id'],
                                 'firstName,lastName,mobile',
                                 userPayloadInfo,
                                 newFlow=True).check()
Example #6
0
    def test_campaignShardThrift_reloadFilterBasedList_newBucket_partiallyDistributedBucket(
            self, campaignType, audienceType):
        self.bucketDetails = CampaignShardHelper.updateBucketIdRowCount(
            rows_count=14999990)
        existingList = constant.thiriftCampaignShardTestReferenceObject[
            campaignType]['campaign']['lists'][audienceType][1]
        userPayloadInfo = CampaignShardHelper.loyaltyUserDataConstructHelper()
        s3InfoForUsedList = CampaignShardHelper.getS3Info(existingList['uuid'])

        thriftCampaignGroup = lambda campaignTargetType: self.campaignShardObject.CampaignGroup(
            {
                'campaignId':
                constant.thiriftCampaignShardTestReferenceObject[campaignType][
                    'campaign']['id'],
                'groupId':
                existingList['groupDetails']['id'],
                'groupLabel':
                existingList['groupLabel'],
                'params':
                str(),
                'campaignGroupType':
                'LOYALTY',
                'campaignTargetType':
                'TEST',
                'customerCount':
                existingList['groupVersionDetails'][campaignTargetType][
                    'customer_count'],
                'uuId':
                existingList['uuid'],
                'versionNumber':
                1,
                's3Path':
                s3InfoForUsedList['response']['data']['s3Path'],
                's3Headers':
                s3InfoForUsedList['response']['data']['s3Header'],
                's3BucketTag':
                s3InfoForUsedList['response']['data']['s3Path'].split('/')[2]
            })

        for eachTargetType in ['TEST']:
            if not self.connObj.reloadGroup(
                    thriftCampaignGroup(eachTargetType)):
                Logger.log(
                    'For TargetType :{} , reload was unsuccesfull'.format(
                        eachTargetType))

        CampaignShardHelper.validateBucketIdWhenBucketUpdated(
            existingList['groupDetails']['id'],
            self.bucketDetails['oldBucket'])

        CampaignShardDBAssertion(
            constant.thiriftCampaignShardTestReferenceObject[campaignType]
            ['campaign']['id'], campaignType, 'loyalty',
            existingList['groupLabel'], existingList['groupDetails']['id'],
            'firstName,lastName,mobile', userPayloadInfo).check()
Example #7
0
 def test_campaignShard_loyalty_generic(self, campaignType):
     detailsOfFilterListCreated = CampaignShardHelper.createFilterList(
         self.campaignId[campaignType],
         'test_list_{}_{}'.format(campaignType, int(time.time())))
     userPayloadInfo = CampaignShardHelper.loyaltyUserDataConstructHelper()
     CampaignShardDBAssertion(
         self.campaignId[campaignType], campaignType,
         detailsOfFilterListCreated['listType'],
         detailsOfFilterListCreated['groupLabel'],
         detailsOfFilterListCreated['groupDetails']['id'],
         'firstName,lastName,mobile', userPayloadInfo).check()
 def test_campaignShardThrift_AudienceGroup_Async_CreateAudience_Sanity(
         self, audienceType):
     createAudienceRequest = campaignShardObject.createAudienceRequest(
         audienceType=audienceType)
     audiencecGroupEntity = self.connObj.createAudienceGroup(
         createAudienceRequest).__dict__
     createAudienceWithGroupId = campaignShardObject.createAudienceRequest(
         {'groupId': audiencecGroupEntity['id']}, audienceType=audienceType)
     time.sleep(20)
     createAudienceResponse = self.connObj.createAudience(
         createAudienceWithGroupId).__dict__
     userPayloadInfo = CampaignShardHelper.loyaltyUserDataConstructHelper()
     CampaignShardDBAssertion(99999,
                              'org',
                              audienceType,
                              createAudienceResponse['label'],
                              audiencecGroupEntity['id'],
                              'firstName,lastName,mobile',
                              userPayloadInfo,
                              newFlow=True).check()
Example #9
0
 def test_campaignShard_upload_paste_email_customTag(
         self, campaignType, userType, numberOfUsers, customTagCount):
     mergeListresponse, mergeListPayload, campaignId = campaignList.mergeList(
         {},
         campaignId=self.campaignId[campaignType],
         campaignType=['LIVE', campaignType, 'List', 'TAGS', 0],
         userType=userType,
         numberOfUsers=numberOfUsers,
         numberOfCustomTags=customTagCount,
         newUser=False)
     campaignList.assertMergeList(mergeListresponse, 200)
     CampaignShardDBAssertion(self.campaignId[campaignType],
                              campaignType,
                              'upload',
                              mergeListPayload['name'],
                              mergeListresponse['json']['entity']['listId'],
                              mergeListPayload['recipients']['schema'],
                              mergeListPayload['recipients']['data'],
                              numberOfCustomTags=customTagCount,
                              numberOfGroupTags=0).check()
Example #10
0
 def test_campaignShardThrfit_duplicateList_uploadBased(
         self, campaignType, audienceType, listType):
     existingList = constant.thiriftCampaignShardTestReferenceObject[
         campaignType]['campaign']['lists'][audienceType][0]
     groupIdsOfListCreated = self.connObj.createList(
         constant.thiriftCampaignShardTestReferenceObject[campaignType]
         ['campaign']['id'], self.campaignShardObject.ListType[listType],
         self.campaignShardObject.ListInfo(
             listType.lower(), {
                 'oldGroupId': existingList['groupDetails']['id'],
                 'newGroupName': 'duplicate_' + existingList['groupLabel']
             }))
     CampaignShardDBAssertion(
         constant.thiriftCampaignShardTestReferenceObject[campaignType]
         ['campaign']['id'],
         campaignType,
         'upload',
         'duplicate_' + existingList['groupLabel'],
         groupIdsOfListCreated[0],
         existingList['addRecipientPayload']['schema'],
         existingList['addRecipientPayload']['data'],
         derived=True).check()
Example #11
0
 def test_campaignShardThrfit_duplicateList_filterBased(
         self, campaignType, audienceType, listType):
     existingList = constant.thiriftCampaignShardTestReferenceObject[
         campaignType]['campaign']['lists'][audienceType][0]
     groupIdsOfListCreated = self.connObj.createList(
         constant.thiriftCampaignShardTestReferenceObject[campaignType]
         ['campaign']['id'], self.campaignShardObject.ListType[listType],
         self.campaignShardObject.ListInfo(
             listType, {
                 'oldGroupId': existingList['groupDetails']['id'],
                 'newGroupName': 'duplicate_' + existingList['groupLabel']
             }))
     userPayloadInfo = CampaignShardHelper.loyaltyUserDataConstructHelper()
     CampaignShardDBAssertion(
         constant.thiriftCampaignShardTestReferenceObject[campaignType]
         ['campaign']['id'],
         campaignType,
         'loyalty',
         'duplicate_' + existingList['groupLabel'],
         groupIdsOfListCreated[0],
         'firstName,lastName,mobile',
         userPayloadInfo,
         derived=True).check()