def est_venenoThrift_inboxUser_WeChat_Sanity(self): actualOrgId = construct.updateOrgId(constant.config['wechat']['orgId']) actualOrgName = construct.updateOrgName(constant.config['wechat']['orgName']) try: details = VenenoHelper.preRequisitesForVenenoWechat(testControlType='skip') campaignMessage.getWeCRMTemplates() subject = { "template_id" : unicodedata.normalize('NFKD', constant.config['templateId']).encode('ascii', 'ignore'), "touser" : "{{wechat_open_id}}", "OriginalId" : constant.config['wechat']['OriginalId'], "Title" : "", "BrandId" : "f", "url" : "http://we.capillarytech-cn.com/web?appid=wxc7bf989decc7e35b&redirect_uri=http://somelink.com/someword?nowAParam=firstParam&second=second.Param&response_type=code&scope=snsapi_base&state=STATE", "TopColor" : "#000000", "data" : {"productType": {"value": "HakeemProduct", "color": "#00000"}, "name": {"value": "Hakeem {{first_name}} Lukka", "color": "#00000"}, "number": {"value": "898767 skdjnjn", "color": "#00000"}, "expDate": {"value": "look down", "color": "#00000"}, "remark": { "value": "Look up", "color": "#00000"}} } cdDetailsBody = { 'campaignId':details['campaignId'], 'communicationType':'WECHAT', 'subject': str(subject), 'body': 'Thrift Created Automation Wechat Body', 'recipientListId':details['groupVersionResult']['TEST']['id'], 'overallRecipientCount':details['groupVersionResult']['TEST']['customer_count'], 'expectedDeliveryCount':details['groupVersionResult']['TEST']['customer_count'], 'groupName':details['groupName'] } communicationDetailObject = VenenoObject.communicationDetail(cdDetailsBody) communicationId = self.connObj.addMessageForRecipients(communicationDetailObject) VenenoDBAssertion(cdDetailsBody['campaignId'], cdDetailsBody['communicationType'], communicationId, cdDetailsBody['overallRecipientCount'], cdDetailsBody['recipientListId'], cdDetailsBody['subject'], testControlType='skip', skippedReasons=['Captured OpenId for user seems to be unsubscribed']).check() except Exception, exp: raise Exception('Wechat Case Failed due to :{}'.format(exp))
def test_pasteList_wrongOrgId(self): response, payload = campaigns.createCampaign(campaignTypeParams=['LIVE', 'ORG']) campaigns.assertCreateCampaign(response, 200) campaignId = response.get('json').get('entity').get('campaignId') previousOrgId = construct.updateOrgId(0) try: responseCreateList, payload, campaignId = campaignList.createList({}, campaignId=campaignId) campaignList.assertCreateList(responseCreateList, 400, 2003, 'Invalid campaign id : ' + str(campaignId)[:3] + ',' + str(campaignId)[3:]) except AssertionError, exp: Logger.log('Assertioin Failed as :', exp)
def setup_class(self): Logger.logSuiteName(str(self).split('.')[-1]) self.actualOrgId = construct.updateOrgId( constant.config['wechat']['orgId']) self.actualOrgName = construct.updateOrgName( constant.config['wechat']['orgName']) VenenoHelper.configRateLimit(enable=True, channel='WECHAT') VenenoHelper.setupStrategy(daily=1, weekly=2, monthly=3, channel='WECHAT') self.testObjectForRateLimit = VenenoHelper.preRequisitesForVenenoRateLimit( 'WECHAT') self.campaignId = self.testObjectForRateLimit['campaign']['id']
def setup_class(self): self.driver = WebDriverFactory().getWebDriverInstance() self.loginPage = loginPage(self.driver) self.createCampaignPage = campaignCreatePage(self.driver) self.incentivePage = incentivePage(self.driver) self.listPage = listPage(self.driver) self.messagePage = messagePage(self.driver) self.loginPage.login(userName=constant.config['intouchUsername'], password=constant.config['intouchPassword']) self.oldOrgId = construct.updateOrgId(constant.config['wechat']['orgId']) self.oldOrgName = construct.updateOrgName(constant.config['wechat']['orgName']) dbHelper.getIntouchShardNameForOrg() self.loginPage.switchOrgUsingCookies(constant.config['wechat']['orgId'])
def test_createCoupon_campaignIdNotInPassedOrg(self): campaignResponse, campaignPayload = campaigns.createCampaign({ 'name': 'IRIS_' + str(int(time.time())), 'goalId': constant.irisGenericValues['goalId'], 'objectiveId': constant.irisGenericValues['objectiveId'] }) previousOrgId = construct.updateOrgId(0) try: response, payload, campaignId = coupons.createCoupons( campaignId=campaignResponse['json']['entity']['campaignId']) coupons.assertCreateCoupon( response, 400, 1007, 'Campaign Id Exception : Invalid Campaign Id Passed {}'.format( campaignId)) except AssertionError, exp: Assertion.constructAssertion(False, exp)
def test_venenoThrift_inboxUser_Line_Sanity(self): actualOrgId = construct.updateOrgId(constant.config['line']['orgId']) actualOrgName = construct.updateOrgName(constant.config['line']['orgName']) try: details = VenenoHelper.preRequisitesForVenenoLine(testControlType='skip') cdDetailsBody = { 'campaignId':details['campaignId'], 'communicationType':'LINE', 'subject':'{"to":"{{line_id}}","messages":[{"type":"text","text":"Automated Call {{user_id_b64}}"}]}', 'body':'', 'recipientListId':details['groupVersionResult']['TEST']['id'], 'overallRecipientCount':details['groupVersionResult']['TEST']['customer_count'], 'expectedDeliveryCount':details['groupVersionResult']['TEST']['customer_count'], 'groupName':details['groupName'] } communicationDetailObject = VenenoObject.communicationDetail(cdDetailsBody) communicationId = self.connObj.addMessageForRecipients(communicationDetailObject) VenenoDBAssertion(cdDetailsBody['campaignId'], cdDetailsBody['communicationType'], communicationId, cdDetailsBody['overallRecipientCount'], cdDetailsBody['recipientListId'], cdDetailsBody['subject'], testControlType='skip').check() except Exception, exp: raise Exception('Line Failure ,due to :{}'.format(exp))
def test_strictOrgUpdate(self): strictOrg = constant.config['strict_org_id'] previousOrgId = construct.updateOrgId(strictOrg) try: updateResponse, createResponse, updatePayload, createPayload = campaigns.updateCampaign( { 'name': 'strict_ORG_ShouldNotBeUpdated' + str(int(time.time())) }, campaignId=int(constant.config['strict_campaign_id'])) Logger.log( 'updateResponse :{} , createResponse :{} , updatePayload :{} ,createPayload :{}' .format(updateResponse, createResponse, updatePayload, createPayload)) campaigns.assertUpdateCampaign( updateResponse, createResponse, 400, 1010, 'CAMPAIGN_UPDATE_EXCEPTION : Campaign Cannot be updated as it has already approved messages' ) except AssertionError, exp: Logger.log('Assertion Failed as :', exp)
def setup_class(self): campaignMessage.getWeCRMTemplates() self.nonWechatOrgId = construct.updateOrgId( constant.config['wechat_org_id']) self.templateIdDict = campaignMessage.setupTemplateId() createListresponse, createListPayload, campaignId = campaignList.createList( { 'customTagCount': 0, 'name': 'IRIS_LIST_' + str(int(time.time() * 100000)) }, campaignId=Test_Wechat_CreateMessage.createCampaign()) campaignList.assertCreateList(createListresponse, 200) groupVersionDetailResult, bucketId = campaignList.assertCreateListDbCalls( createListresponse['json']['entity']['listId'], createListPayload, 'ORG') Logger.log('GroupVersionId : {}, bucketId : {}'.format( groupVersionDetailResult, bucketId)) addRecipientResponse, addRecipientPayload = campaignList.addRecipient( Test_Wechat_CreateMessage.addRecipientPayload(), campaignId, createListresponse['json']['entity']['listId']) campaignList.assertAddRecipient(addRecipientResponse, 200) responseCoupon, payloadCoupon, campaignId = coupons.createCoupons( campaignId=campaignId) self.groupVersionResult = dbCallsList.getGroupVersionDetailsWithGroupId( createListresponse['json']['entity']['listId']) self.bucketId = bucketId self.strategy = construct.constructStrategyIds() self.programeId = self.strategy['programeId'] self.allocationStrategyId = self.strategy['allocationStrategyId'] self.expiryStrategyId = self.strategy['expirationStrategyId'] self.voucherId = responseCoupon['json']['entity']['voucherSeriesId'] self.campaignId = campaignId self.listId = createListresponse['json']['entity']['listId'] campaignMessage.updateDefaultMessageJson(self.campaignId, self.listId, self.voucherId, self.strategy, self.bucketId, self.groupVersionResult) constant.messagesDefault['updated'] = True Logger.log( 'Using CampaignId : {} , listId : {} for Execution of Create Message' .format(self.campaignId, self.listId))
def est_venenoThrift_inboxUser_MobilePush_IOS(self): actualOrgId = construct.updateOrgId(constant.config['mobilepush']['orgId']) actualOrgName = construct.updateOrgName(constant.config['mobilepush']['orgName']) try: details = VenenoHelper.preRequisitesForVenenoMobilePush('ios',testControlType='skip') cdDetailsBody = { 'campaignId':details['campaignId'], 'communicationType':'PUSH', 'subject':'Automation Generated Body ', 'body':'{"templateData":{"ANDROID":{"luid":"{{luid}}","cuid":"{{cuid}}","communicationId":"{{communicationId}}","title":"hi {{first_name}}","message":"{{first_name}}","expandableDetails":{"style":"BIG_TEXT","message":"{{first_name}}"},"custom":[]},"IOS":{"luid":"{{luid}}","cuid":"{{cuid}}","communicationId":"{{communicationId}}","title":"hi {{first_name}}","message":"{{first_name}}","expandableDetails":{"style":"BIG_TEXT","message":"hi {{first_name}}","ctas":[]},"custom":[]}}}', 'recipientListId':details['groupVersionResult']['TEST']['id'], 'overallRecipientCount':details['groupVersionResult']['TEST']['customer_count'], 'expectedDeliveryCount':details['groupVersionResult']['TEST']['customer_count'], 'groupName':details['groupName'] } communicationDetailObject = VenenoObject.communicationDetail(cdDetailsBody) communicationId = self.connObj.addMessageForRecipients(communicationDetailObject) VenenoDBAssertion(cdDetailsBody['campaignId'], cdDetailsBody['communicationType'], communicationId, cdDetailsBody['overallRecipientCount'], cdDetailsBody['recipientListId'], cdDetailsBody['subject'], testControlType='skip').check() except Exception, exp: raise Exception('MobilePush Failure ,due to :{}'.format(exp))
def test_getCampaign_PassingWorngOrg(self): response, payload = campaigns.createCampaign({ 'name': 'IRIS_' + str(int(time.time())), 'goalId': str(dbCallsCampaign.getValidGoalId()), 'objectiveId': dbCallsCampaign.getValidObjectiveId() }) campaigns.assertCreateCampaign(response, 200) previousOrgId = construct.updateOrgId(0) try: getCampaignResponse = campaigns.getCampaignById( campaignId=response.get('json').get('entity').get( 'campaignId')) campaigns.assertGetCampaign( getCampaignResponse, 400, 1007, 'Campaign Id Exception : No Campaign Exists For This Campaign Id' ) except AssertionError, exp: Logger.log('Assertion Failed as :', exp)
self.oldOrgId = construct.updateOrgId(constant.config['wechat']['orgId']) self.oldOrgName = construct.updateOrgName(constant.config['wechat']['orgName']) dbHelper.getIntouchShardNameForOrg() self.loginPage.switchOrgUsingCookies(constant.config['wechat']['orgId']) def teardown_class(self): try: self.driver.quit() except Exception, exp: assert False , 'Exception Occured while Closing Browser , Need to Close Browser manually' finally: Logger.log('Setting up orgId as :{} and orgName as :{} for later Executions'.format(self.oldOrgId,self.oldOrgName)) construct.updateOrgId(self.oldOrgId) construct.updateOrgName(self.oldOrgName) def test_wechat_UI_channel_Sanity(self, request): try: details = VenenoHelper.preRequisitesForVenenoWechat() self.createCampaignPage.goToCampaignSection() self.createCampaignPage.openCampaignWithCampaignName(details['campaignName']) self.createCampaignPage.goToMessagePage('wechat') self.messagePage.chooseRecipient(details['groupName']) self.messagePage.attachIncentive('nodeal') self.messagePage.customizeContent(templateName='',channel='wechat') self.messagePage.deliverySetting() self.createCampaignPage.authorizePresentCampaignOnPage() self.messagePage.verifyAuthorizeCampaign(details['campaignId'], details['groupVersionResult']['TEST']['id']) except Exception,exp:
def teardown_class(self): Logger.log('Disable Rate Limit Config') VenenoHelper.configRateLimit(enable=False, channel='PUSH') construct.updateOrgId(self.actualOrgId) construct.updateOrgName(self.actualOrgName)
communicationDetailObject) VenenoDBAssertion( cdDetailsBody['campaignId'], cdDetailsBody['communicationType'], communicationId, cdDetailsBody['overallRecipientCount'], cdDetailsBody['recipientListId'], cdDetailsBody['subject'], testControlType='custom', skippedReasons=[ 'Captured OpenId for user seems to be unsubscribed' ]).check() except Exception, exp: raise Exception('Wechat Case Failed due to :{}'.format(exp)) finally: construct.updateOrgId(actualOrgId) construct.updateOrgName(actualOrgName) def test_venenoThrift_inboxUser_CallTask_Sanity(self): cdDetailsBody = { 'campaignId': self.details['campaignId'], 'communicationType': 'CALL_TASK', 'subject': 'Automation Generated Body {{first_name}} {{last_name}} {{fullname}} {{optout}}', 'recipientListId': self.details['groupVersionResult']['TEST']['id'], 'overallRecipientCount': self.details['groupVersionResult']['TEST']['customer_count'], 'expectedDeliveryCount':
def test_strictOrgUpdate(self): strictOrg = constant.config['strict_org_id'] previousOrgId = construct.updateOrgId(strictOrg) try: updateResponse, createResponse, updatePayload, createPayload = campaigns.updateCampaign( { 'name': 'strict_ORG_ShouldNotBeUpdated' + str(int(time.time())) }, campaignId=int(constant.config['strict_campaign_id'])) Logger.log( 'updateResponse :{} , createResponse :{} , updatePayload :{} ,createPayload :{}' .format(updateResponse, createResponse, updatePayload, createPayload)) campaigns.assertUpdateCampaign( updateResponse, createResponse, 400, 1010, 'CAMPAIGN_UPDATE_EXCEPTION : Campaign Cannot be updated as it has already approved messages' ) except AssertionError, exp: Logger.log('Assertion Failed as :', exp) finally: construct.updateOrgId(int(previousOrgId)) ''' #This case will be Activate when Create Coupon Automation is done def test_CouponsDateUpdate(self): updateResponse, createResponse, updatePayload, createPayload = campaigns.updateCampaign({'name':'CouponAlsoShouldUpdate' + str(int(time.time())), 'endDate':int(time.time() * 1000 + 10 * 24 * 60 * 60 * 1000)}, campaignId=300654) Logger.log('updateResponse :{} , createResponse :{} , updatePayload :{} ,createPayload :{}'.format(updateResponse, createResponse, updatePayload, createPayload)) '''
def teardown_class(self): construct.updateOrgId(self.nonWechatOrgId) Logger.log('Default Object Set is :', constant.messagesDefault)