def setup_method(self, method): messageClass = 'SMS' if 'EMAIL' in method.__name__: messageClass = 'EMAIL' self.nsObj = NSAdminHelper.getConnObj(newConnection=True) self.nsadminHelper = NSAdminHelper(self.orgId, messageClass) self.nsadminHelper.disableDomainPropertiesGatewayMap() Logger.logMethodName(method.__name__)
def setup_method(self, method): self.nsObj = NSAdminHelper.getConnObj(newConnection=True) if self.cluster in ['nightly']: self.orgId = 780 elif self.cluster == 'china': self.orgId = 200017 self.nsadminHelper = NSAdminHelper(self.orgId, 'WECHAT') Logger.logMethodName(method.__name__)
def createNewDummyGateway(channel): messageClass = 'SMS' if channel.lower() in ['mobile', 'sms'] else channel nsObj = NSAdminHelper.getConnObj(newConnection=True) nsadminHelper = NSAdminHelper(constant.config['orgId'], messageClass) for eachType in [('HIGH', 'localmail_HIGH_{}'.format(int(time.time())),["capillary", "otp"]),('BULK', 'localmail_BULK_{}'.format(int(time.time())),["capillary", "campaigns"])]: try: nsadminHelper.configureGateway(eachType[0], eachType[1] + '_2', False, eachType[2]) except Exception,exp: Logger.log('Exception While Creating Dummy Gateway :{}'.format(exp))
def updateEmailStatus(listObject): nsObj = NSAdminHelper.getConnObj() for eachList in listObject: allusersInList = [ eachUser.split(',')[2] for eachUser in listObject[eachList] ['addRecipientPayload']['data'] ] if not nsObj.whitelistEmailIds(allusersInList): raise Exception("Not Able To Whitelist New Created users ")
def setup_class(self): Logger.logSuiteName(str(self).split('.')[-1]) self.orgId = constant.config['orgId'] self.cluster = constant.config['cluster'] self.nsObj = NSAdminHelper.getConnObj(newConnection=True) self.nsadminHelper = NSAdminHelper(self.orgId, 'EMAIL') self.nsadminHelper.disableDomainPropertiesGatewayMap() self.nsadminHelper.configureGateway('HIGH', 'sendgrid_HIGH') self.nsadminHelper.configureGateway('BULK', 'sendgrid_BULK') self.DR = DeliveryReceipt() self.msgDict = { "messageClass": "EMAIL", "priority": 'HIGH', "message": "test message for DLR" }
def getDomainGatewayMapId(messageClass='SMS'): nsObj = NSAdminHelper.getConnObj(newConnection=True) domainGateway = nsObj.getDomainPropertiesGatewayMapByOrg(int(constant.config['orgId']), NSAdminObject.MessageClass[messageClass])[0] domainMap = { 'mapId': domainGateway.id } if messageClass == 'SMS': for eachContactInfo in domainGateway.domainProperties.contactInfo: if eachContactInfo.type == 'cdma_sender_id': domainMap.update({'cdma_sender_id': eachContactInfo.value}) if eachContactInfo.type == 'gsm_sender_id': domainMap.update({'gsm_sender_id': eachContactInfo.value}) elif messageClass == 'EMAIL': for eachContactInfo in domainGateway.domainProperties.contactInfo: if eachContactInfo.type == 'reply_to_id': domainMap.update({'reply_to_id': eachContactInfo.value}) if eachContactInfo.type == 'sender_id': domainMap.update({'sender_id': eachContactInfo.value}) else: raise Exception('OtherChannelsNotSupportedForDomainMapping') return domainMap
def setup_method(self, method): self.nsObj = NSAdminHelper.getConnObj(newConnection=True) self.nsadminHelper = NSAdminHelper(self.orgId, 'EMAIL') self.nsadminHelper.disableDomainPropertiesGatewayMap() Logger.logMethodName(method.__name__)
def updateCredit(credit=0,channel='EMAIL'): try: nsObj = NSAdminHelper.getMasterConnObj() if constant.config['cluster'] in ['nightly','staging','china'] else NSAdminHelper.getConnObj(newConnection=True) messageClass = 1 if channel == 'EMAIL' else 0 creditDetails1 = { "orgId": int(constant.config['orgId']), "bulkCredits": int(credit), 'messageClass': messageClass } creditDetails1 = NSAdminObject.OrgCreditDetails(creditDetails1) if credit == 0: currVal = nsObj.getCreditDetailsByOrgAndChannel(constant.config['orgId'], messageClass, 'test_{}'.format(int(time.time()))) currVal = int(currVal.bulkCredits) * -1 creditDetails1.bulkCredits = currVal nsObj.addCredits(creditDetails1) except Exception,exp: raise Exception('NotAbleToUpdateCreditTo:{}'.format(credit)) Logger.log(exp)
def disableDomainGatewayMapId(channel): messageClass = 'SMS' if channel.lower() in ['mobile','sms'] else channel nsObj = NSAdminHelper.getConnObj(newConnection=True) nsadminHelper = NSAdminHelper(constant.config['orgId'], messageClass) nsadminHelper.disableDomainPropertiesGatewayMap()
def logCurrentCredit(messageClass): nsObj = NSAdminHelper.getConnObj(newConnection=True) currVal = nsObj.getCreditDetailsByOrgAndChannel(constant.config['orgId'], messageClass, 'test_{}'.format(int(time.time()))) Logger.log('Current Credit :{}'.format(currVal.bulkCredits)) return int(currVal.bulkCredits)
def setup_method(self, method): self.nsObj = NSAdminHelper.getConnObj(newConnection=True) self.nsadminHelper = NSAdminHelper(constant.config['orgId'], 'SMS') Logger.logMethodName(method.__name__)