def setup_class(self): self.campaignId = SocialHelper.createCampaignsForSocialThrift() self.remoteCampaignId = SocialHelper.createRemoteCampaignsForSocialThrift( self.campaignId['ORG']) self.remoteListId, self.groupVersionId = SocialHelper.createRemoteListForSocialThrift( self.campaignId) self.remoteOfferId = None
def test_socialThrift_getAdset_Sanity(self, socialStatus): adsetName = 'Auto_AdsetName_{}'.format(int(time.time() * 1000)) SocialAdsetInfo = self.connObj.createSocialAdset( constant.config['orgId'], SocialObject().SocialChannel['facebook'], SocialObject.SocialAdsetInfo( adsetName, self.remoteCampaignId, datetime.fromtimestamp( time.time()).strftime('%Y-%m-%dT%H:%M:%S'), datetime.fromtimestamp(time.time() + 25 * 60 * 60).strftime('%Y-%m-%dT%H:%M:%S'), socialStatus, 100000, customAudienceId=self.remoteListId), 'requestId_automationthriftCall_{}'.format(int(time.time() * 1000))) SocialAdSets = self.connObj.getAdSets( SocialObject().SocialChannel['facebook'], constant.config['orgId'], 'requestId_automationthriftCall_{}'.format(int(time.time() * 1000))) SocialHelper.assertGetAdset(SocialAdSets, SocialAdsetInfo, SocialObject().SocialStatus[socialStatus])
def test_socialThrift_integrateOfCreateAndGetList(self, numberOfUsers, identifier, listName, description, channel, testControlType): groupVersionid, groupName = SocialHelper.createListForSocial( self.campaigns, testControlType) messageId = SocialHelper.createMessageForThriftHelp( self.campaigns[testControlType], groupVersionid, numberOfUsers, groupName) listName = listName.format(identifier, testControlType, int(time.time() * 1000)) CreateCustomAudienceListResponse = self.connObj.createCustomList( SocialHelper.createUserListObject(numberOfUsers, identifier), SocialObject.CustomAudienceListDetails(listName, description, messageId), SocialObject.SocialAccountDetails(channel), constant.config['orgId'], str(groupVersionid), 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) Logger.log('Create Audience List , Response Message :{}'.format( CreateCustomAudienceListResponse.message)) GetCustomAudienceListsResponse = self.connObj.getCustomAudienceLists( constant.config['orgId'], SocialObject().SocialChannel['facebook'], True, 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) Logger.log('Message From Get Custom Audience List : {}'.format( GetCustomAudienceListsResponse.message)) SocialHelper.assertNewCreatedListInGetCall( listName, GetCustomAudienceListsResponse)
def test_flow_social_skipped_accountDetailsWrong(self): ckvId = SocialHelper.updateConfigKeyValue(0) try: cdDetailsBody = { 'campaignId': self.campaigns['ORG'], 'targetType': 'SOCIAL', 'communicationType': 'FACEBOOK', 'subject': '', 'recipientListId': self.groupVersionid, 'overallRecipientCount': self.numberOfUsers, 'expectedDeliveryCount': self.numberOfUsers, 'groupName': self.groupName } extraParams = { 'voucher_series': self.voucherSeriesId, 'default_argument': { "entity_id": -1, "is_loyalty_checkbox_enabled": "0", "voucher_series_id": self.voucherSeriesId, "daily_budget": 10000, "create_adset": True, "use_existing_adset": False, "adset_name": 'AutoAdset_{}'.format(int(time.time() * 1000)) } } communicationDetailObject = VenenoObject.communicationDetail( cdDetailsBody, extraParams=extraParams) communicationId = self.connObj.addMessageForRecipients( communicationDetailObject) SocialHelper.assertCommunicationDetailInErrorState( self.groupVersionid, communicationId) except Exception, exp: Assertion.constructAssertion(False, 'Excpetion :{}'.format(exp))
def setup_class(self): self.numberOfUsers = 20 self.campaigns = SocialHelper.createCampaignsForSocialThrift(testControlType=['CUSTOM']) self.groupVersionid,self.groupName = SocialHelper.createListForSocial(self.campaigns,'CUSTOM',numberOfUsers=self.numberOfUsers,newUser=True) self.remoteCampaignId = SocialHelper.createRemoteCampaignsForSocialThrift(self.campaigns['CUSTOM']) SocialHelper.updateRemoteCampaignIdInCampaignsBase(self.campaigns['CUSTOM'],self.remoteCampaignId) self.voucherSeriesId = coupons.createCoupons(campaignId=self.campaigns['CUSTOM'],payloadData={'couponLimit':{'limit':0, 'type':'UNLIMITED'}, 'discountOn':'BILL', 'discountType':'ABS', 'discountValue':10})[0]['json']['entity']['voucherSeriesId']
def est_flow_social_negative_withExternalCoupon(self): cdDetailsBody = { 'campaignId': self.campaigns['ORG'], 'targetType': 'SOCIAL', 'communicationType': 'FACEBOOK', 'subject': '', 'recipientListId': self.groupVersionid, 'overallRecipientCount': self.numberOfUsers, 'expectedDeliveryCount': self.numberOfUsers, 'groupName': self.groupName } extraParams = { 'voucher_series': self.voucherSeriesId, 'default_argument': { "entity_id": -1, "is_loyalty_checkbox_enabled": "0", "voucher_series_id": self.voucherSeriesId, "daily_budget": 10000, "create_adset": True, "use_existing_adset": False, "adset_name": 'AutoAdset_{}'.format(int(time.time() * 1000)) } } communicationDetailObject = VenenoObject.communicationDetail( cdDetailsBody, extraParams=extraParams) communicationId = self.connObj.addMessageForRecipients( communicationDetailObject) SocialHelper.assertCommunicationDetailInErrorState( self.groupVersionid, communicationId) SocialHelper.assertAggregationDetailAndAudienceListCreated( self.groupVersionid, communicationId)
def test_socialThrift_getCustomAudienceLists_Sanity(self): GetCustomAudienceListsResponse = self.connObj.getCustomAudienceLists( constant.config['orgId'], SocialObject().SocialChannel['facebook'], True, 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) Logger.log('Message From Get Custom Audience List : {}'.format( GetCustomAudienceListsResponse.message)) SocialHelper.assertGetCustomAudienceList( GetCustomAudienceListsResponse)
def test_socialThrift_getSocialCampaignDetails_Sanity(self): campaignId = social_user_calls().getCampaignIdWithRemoteId() SocialCampaignDetails = self.connObj.getSocialCampaignDetails( constant.config['orgId'], campaignId, int(constant.config['userId']), SocialObject().SocialChannel['facebook'], 'requestId_automationthriftCall_{}'.format(int(time.time() * 1000))) SocialHelper.validateGetSoicalCampaignDetails(SocialCampaignDetails, campaignId)
def test_socialThrift_updateCustomListInAdset_Sanity(self): remoteAdsetId = social_user_calls().getRemoteAdset() remoteListId = social_user_calls().getRemoteListId() SocialAdsetInfo = self.connObj.updateCustomListInAdset( constant.config['orgId'], SocialObject().SocialChannel['facebook'], remoteAdsetId, remoteListId, 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) SocialHelper.validateSocialAdsetInfo(SocialAdsetInfo, remoteAdsetId, remoteListId)
def test_socialThrift_createCampaign_Sanity(self, socialStatus): SocialCampaign = self.connObj.createCampaign( constant.config['orgId'], SocialObject().SocialChannel['facebook'], SocialObject.SocialCampaign('SocialCampaign_{}'.format( int(time.time() * 1000)), constant.config['orgId'], self.campaigns['ORG'], socialCampaignStatus=socialStatus), 'requestId_automationthriftCall_{}'.format(int(time.time() * 1000))) SocialHelper.assertCreateCampaignForSocial(self.campaigns['ORG'], SocialCampaign)
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 test_flow_social_skippedWithCouponExpired(self): try: SocialHelper.couponConfigChange( { 'fixedExpiryDate': int(time.time() * 1000 - 24 * 60 * 60 * 1000) }, self.campaigns['ORG'], self.voucherSeriesId) cdDetailsBody = { 'campaignId': self.campaigns['ORG'], 'targetType': 'SOCIAL', 'communicationType': 'FACEBOOK', 'subject': '', 'recipientListId': self.groupVersionid, 'overallRecipientCount': self.numberOfUsers, 'expectedDeliveryCount': self.numberOfUsers, 'groupName': self.groupName } extraParams = { 'voucher_series': self.voucherSeriesId, 'default_argument': { "entity_id": -1, "is_loyalty_checkbox_enabled": "0", "voucher_series_id": self.voucherSeriesId, "daily_budget": 10000, "create_adset": True, "use_existing_adset": False, "adset_name": 'AutoAdset_{}'.format(int(time.time() * 1000)) } } communicationDetailObject = VenenoObject.communicationDetail( cdDetailsBody, extraParams=extraParams) communicationId = self.connObj.addMessageForRecipients( communicationDetailObject) SocialDBAssertion(self.campaigns['ORG'], self.groupVersionid, communicationId, self.numberOfUsers, couponUsed=True, skippedReason=['Coupon Could not be issued'], skippedUsers=True, socialAudienceList=False, socialAdsetInfo=False, aggregationDetail=False).check() except Exception, exp: Assertion.constructAssertion( False, 'Failed with Exception :{}'.format(exp))
def setup_class(self): self.numberOfUsers = 20 self.constructObj = LuciObject() self.DracarysObj = DracarysObject() self.DracraysConnObj = DracarysHelper.getConnObj(newConnection=True) self.campaigns = SocialHelper.createCampaignsForSocialThrift( testControlType=['ORG']) self.groupVersionid, self.groupName = SocialHelper.createListForSocial( self.campaigns, 'ORG', numberOfUsers=self.numberOfUsers, newUser=True) self.remoteCampaignId = SocialHelper.createRemoteCampaignsForSocialThrift( self.campaigns['ORG']) SocialHelper.updateRemoteCampaignIdInCampaignsBase( self.campaigns['ORG'], self.remoteCampaignId) self.voucherSeriesId = coupons.createCoupons( campaignId=self.campaigns['ORG'], payloadData={ 'couponLimit': { 'limit': 0, 'type': 'UNLIMITED' }, 'discountOn': 'BILL', 'discountType': 'ABS', 'discountValue': 10 })[0]['json']['entity']['voucherSeriesId'] SocialHelper.couponConfigChange( { 'client_handling_type': 'EXTERNAL_ISSUAL', 'any_user': True }, self.campaigns['ORG'], self.voucherSeriesId)
def test_socialThrift_createCustomList_withSameIdMultipleTimes( self, numberOfUsers, identifier, listName, description, channel, testControlType): groupVersionid, groupName = SocialHelper.createListForSocial( self.campaigns, testControlType) messageId = SocialHelper.createMessageForThriftHelp( self.campaigns[testControlType], groupVersionid, numberOfUsers, groupName) listName = listName.format(identifier, testControlType, int(time.time() * 1000)) preCreatedListId = None for _ in range(2): CreateCustomAudienceListResponse = self.connObj.createCustomList( SocialHelper.createUserListObject(numberOfUsers, identifier), SocialObject.CustomAudienceListDetails(listName, description, messageId), SocialObject.SocialAccountDetails(channel), constant.config['orgId'], str(groupVersionid), 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) SocialHelper.assertCreateCustomList( groupVersionid, messageId, CreateCustomAudienceListResponse, listName, description) if preCreatedListId is None: preCreatedListId = CreateCustomAudienceListResponse.listid else: SocialHelper.assertRemoteListIds( preCreatedListId, CreateCustomAudienceListResponse.listid)
def test_socialThrift_createAdset_withList_withCouponAttached( self, socialStatus): adsetName = 'Auto_AdsetName_{}'.format(int(time.time() * 1000)) SocialOffer = self.connObj.createNativeOffer( constant.config['orgId'], SocialObject().SocialChannel['facebook'], SocialObject.SocialOffer( { 'offerType': 'percentage_off', 'offerText': 'offerText_{}'.format(int(time.time())), 'offerValue': 10, 'socialOfferCouponsCsvFileInfo': None, 'redemptionCode': 'redemptionCode_{}'.format( int(time.time())) }, constant.config['facebook']['pageId'], SocialObject().OfferLocationType['offline'], 'overviewDetails_{}'.format(int(time.time())), datetime.fromtimestamp(time.time() + 25 * 60 * 60).strftime('%Y-%m-%dT%H:%M:%S'), 'generic'), 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) SocialAdsetInfo = self.connObj.createSocialAdset( constant.config['orgId'], SocialObject().SocialChannel['facebook'], SocialObject.SocialAdsetInfo( adsetName, self.remoteCampaignId, datetime.fromtimestamp( time.time()).strftime('%Y-%m-%dT%H:%M:%S'), datetime.fromtimestamp(time.time() + 25 * 60 * 60).strftime('%Y-%m-%dT%H:%M:%S'), socialStatus, 100000, customAudienceId=self.remoteListId, remoteOfferId=SocialOffer.remoteOfferId), 'requestId_automationthriftCall_{}'.format(int(time.time() * 1000))) SocialHelper.assertCreateAdsetSocial( SocialAdsetInfo, self.remoteCampaignId, SocialObject().SocialStatus[socialStatus.upper()], adsetName, expectedRemoteListId=self.remoteListId)
def test_thrift_createNativeOffer_without_socialOfferCouponsCsvFileInfo_Sanity( self, offerType, offerValue, socialCouponType): SocialOffer = self.connObj.createNativeOffer( constant.config['orgId'], SocialObject().SocialChannel['facebook'], SocialObject.SocialOffer( { 'offerType': offerType, 'offerText': 'offerText_{}'.format(int(time.time())), 'offerValue': offerValue, 'socialOfferCouponsCsvFileInfo': None, 'redemptionCode': 'redemptionCode_{}'.format( int(time.time())) }, constant.config['facebook']['pageId'], SocialObject().OfferLocationType['offline'], 'overviewDetails_{}'.format(int(time.time())), datetime.fromtimestamp(time.time() + 25 * 60 * 60).strftime('%Y-%m-%dT%H:%M:%S'), socialCouponType), 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) SocialHelper.assertOfferCreation(SocialOffer)
def test_socialThrift_createCustomList_WithDifferentTestControlType( self, numberOfUsers, identifier, listName, description, channel, testControlType): groupVersionid, groupName = SocialHelper.createListForSocial( self.campaigns, testControlType) messageId = SocialHelper.createMessageForThriftHelp( self.campaigns[testControlType], groupVersionid, numberOfUsers, groupName) listName = listName.format(identifier, testControlType, int(time.time() * 1000)) CreateCustomAudienceListResponse = self.connObj.createCustomList( SocialHelper.createUserListObject(numberOfUsers, identifier), SocialObject.CustomAudienceListDetails(listName, description, messageId), SocialObject.SocialAccountDetails(channel), constant.config['orgId'], str(groupVersionid), 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) Logger.log('Create Audience List , Response Message :{}'.format( CreateCustomAudienceListResponse.message)) SocialHelper.assertCreateCustomList(groupVersionid, messageId, CreateCustomAudienceListResponse, listName, description)
def checkRemoteAdset(self): connObj = SocialHelper.getConnObj(newConnection=True) flag = False SocialAdSets = connObj.getAdSets( SocialObject().SocialChannel['facebook'], constant.config['orgId'], 'requestId_automationthriftCall_{}'.format(int(time.time()*1000)) ) for SocialAdSet in SocialAdSets: if SocialAdSet.id == self.remoteAdsetId: flag=True break Assertion.constructAssertion(flag,'SocialAdsetInfo remoteId found in getSocialAdset')
def test_socialThrift_deleteSocialAudienceList(self): GetCustomAudienceListsResponse = self.connObj.getCustomAudienceLists( constant.config['orgId'], SocialObject().SocialChannel['facebook'], True, 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) for eachList in GetCustomAudienceListsResponse.customAudienceLists: firstListFromGetAudienceList = eachList.remoteListId self.connObj.deleteSocialAudienceList( SocialObject().SocialChannel['facebook'], constant.config['orgId'], firstListFromGetAudienceList, 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) GetCustomAudienceListsResponseForEach = self.connObj.getCustomAudienceLists( constant.config['orgId'], SocialObject().SocialChannel['facebook'], True, 'requestId_automationthriftCall_{}'.format( int(time.time() * 1000))) SocialHelper.assertDeleteSocialAudienceList( GetCustomAudienceListsResponseForEach, firstListFromGetAudienceList)
def checkRemoteList(self): connObj = SocialHelper.getConnObj(newConnection=True) flag=False GetCustomAudienceListsResponse = connObj.getCustomAudienceLists( constant.config['orgId'], SocialObject().SocialChannel['facebook'], True, 'requestId_automationthriftCall_{}'.format(int(time.time()*1000)) ) for each in GetCustomAudienceListsResponse.customAudienceLists: if each.remoteListId == self.remoteListId: flag = True break Assertion.constructAssertion(flag,'New Created List with Name :{} found in GetCustomAudienceListsResponse'.format(self.remoteListId))
def test_socialThrift_createAdset_withList_withoutCouponAttached_Sanity( self, socialStatus): adsetName = 'Auto_AdsetName_{}'.format(int(time.time() * 1000)) SocialAdsetInfo = self.connObj.createSocialAdset( constant.config['orgId'], SocialObject().SocialChannel['facebook'], SocialObject.SocialAdsetInfo( adsetName, self.remoteCampaignId, datetime.fromtimestamp( time.time()).strftime('%Y-%m-%dT%H:%M:%S'), datetime.fromtimestamp(time.time() + 25 * 60 * 60).strftime('%Y-%m-%dT%H:%M:%S'), socialStatus, 100000, customAudienceId=self.remoteListId), 'requestId_automationthriftCall_{}'.format(int(time.time() * 1000))) SocialHelper.assertCreateAdsetSocial( SocialAdsetInfo, self.remoteCampaignId, SocialObject().SocialStatus[socialStatus.upper()], adsetName, expectedRemoteListId=self.remoteListId)
'groupName':self.groupName } extraParams = { 'voucher_series': self.voucherSeriesId, 'default_argument' : { "entity_id":-1, "is_loyalty_checkbox_enabled":"0", "voucher_series_id":self.voucherSeriesId, "daily_budget":10000, "create_adset":True, "use_existing_adset":False, "adset_name": 'AutoAdset_{}'.format(int(time.time()*1000)) } } communicationDetailObject = VenenoObject.communicationDetail(cdDetailsBody,extraParams=extraParams) communicationId = self.connObj.addMessageForRecipients(communicationDetailObject) SocialDBAssertion(self.campaigns['CUSTOM'], self.groupVersionid,communicationId, self.numberOfUsers, couponUsed=True, skippedReason=['Coupon Could not be issued'], skippedUsers=True, socialAudienceList=False, socialAdsetInfo=False, aggregationDetail=False).check() except Exception,exp: Assertion.constructAssertion(False,'Failed with Exception :{}'.format(exp)) finally: SocialHelper.couponConfigChange({'fixedExpiryDate':int(time.time() * 1000 + 24 * 60 * 60 * 1000)},self.campaigns['CUSTOM'],self.voucherSeriesId)
def setup_method(self, method): self.connObj = SocialHelper.getConnObj(newConnection=True) Logger.logMethodName(method.__name__)
'communicationType': 'FACEBOOK', 'subject': '', 'recipientListId': self.groupVersionid, 'overallRecipientCount': self.numberOfUsers, 'expectedDeliveryCount': self.numberOfUsers, 'groupName': self.groupName } extraParams = { 'voucher_series': self.voucherSeriesId, 'default_argument': { "entity_id": -1, "is_loyalty_checkbox_enabled": "0", "voucher_series_id": self.voucherSeriesId, "daily_budget": 10000, "create_adset": True, "use_existing_adset": False, "adset_name": 'AutoAdset_{}'.format(int(time.time() * 1000)) } } communicationDetailObject = VenenoObject.communicationDetail( cdDetailsBody, extraParams=extraParams) communicationId = self.connObj.addMessageForRecipients( communicationDetailObject) SocialHelper.assertCommunicationDetailInErrorState( self.groupVersionid, communicationId) except Exception, exp: Assertion.constructAssertion(False, 'Excpetion :{}'.format(exp)) finally: SocialHelper.updateConfigKeyValue(1, ckvId)
def setup_class(self): self.campaigns = SocialHelper.createCampaignsForSocialThrift()