Ejemplo n.º 1
0
    def test_sendMultipleMessageEmailWithBulkGateway(self):
        self.nsadminHelper.configureGateway('BULK', 'localmail_BULK')
        params = [[
            0, "BULK", "test message 1",
            "autoemail" + randValues.getRandomMobileNumber() + "@gmail.com",
            ['RECEIVED_IN_QUEUE', 'SENT']
        ],
                  [
                      1, "BULK", "test message 2", "autoemail" +
                      randValues.getRandomMobileNumber() + "@gmail.com",
                      ['RECEIVED_IN_QUEUE', 'SENT']
                  ],
                  [
                      2, "HIGH", "test message 3", "autoemail" +
                      randValues.getRandomMobileNumber() + "@gmail.com",
                      ['RECEIVED_IN_QUEUE', 'FAILED']
                  ]]
        self.nsObj.whitelistEmailIds(
            [params[0][3], params[1][3], params[2][3]])
        msgObjList = []
        for p in params:
            msgObj = NSAdminObject.message({
                "messageClass": "EMAIL",
                "inboxId": p[0],
                "priority": p[1],
                "message": p[2],
                "receiver": p[3],
                "body": "test body"
            })
            msgObjList.append(msgObj)
        resp = self.nsObj.sendMultipleMessages(msgObjList)
        for i in range(0, 3):
            msgId = resp[i]
            msgResp = self.nsObj.getMessagesById([msgId])[0]
            #inboxId = msgResp.inboxId
            msgParams = params[i]
            Assertion.constructAssertion(msgResp.status in msgParams[4],
                                         'Messages status')
            Assertion.constructAssertion(msgResp.priority == msgParams[1],
                                         'Messages priority')
            Assertion.constructAssertion(msgResp.message == msgParams[2],
                                         'Message')
            Assertion.constructAssertion(msgResp.receiver == msgParams[3],
                                         'Messages receiver')
            currentMonthTable = NSAdminHelper.getDataTableName()
            query = 'select nsadmin_id from ' + currentMonthTable + ' where nsadmin_id=' + str(
                msgId)
            dbResp = dbHelper.queryDB(query, 'nsadmin')
            Assertion.constructAssertion(dbResp[0][0] == msgId, 'Messages id')

        for p in params:
            msg = self.nsObj.getMessagesByReceiver(self.orgId, p[3])
            Assertion.constructAssertion(msg[0].message == p[2],
                                         'Assert getMessagesByReceiver')
Ejemplo n.º 2
0
 def test_sendMessage_EMAIL_ValidSender(self, priority, gateway):
     self.nsadminHelper.configureGateway(priority, gateway)
     msgDict = {
         "messageClass": "EMAIL",
         "priority": priority,
         'sender': '*****@*****.**',
         "message": "test message with priority " + priority
     }
     msgId = self.nsadminHelper.createAndSendMessage(msgDict)
     resp = self.nsadminHelper.assertWithWaitUntil(
         msgId, ['RECEIVED_IN_QUEUE', 'SENT'], 'Messages status ACK', 10)
     currentMonthTable = NSAdminHelper.getDataTableName()
     query = 'select sender from ' + currentMonthTable + ' where nsadmin_id=' + str(
         msgId)
     resp = dbHelper.queryDB(query, 'nsadmin')
     Assertion.constructAssertion(resp[0][0] == '*****@*****.**', 'sender')
Ejemplo n.º 3
0
 def test_sendMessage_EMAIL_withHTMLContentAndAttachment(self):
     filePath = constant.rootPath + '/src/modules/nsadmin/html'
     body = FileHelper.readFile(filePath)
     self.nsadminHelper.configureGateway('BULK', 'localmail_BULK')
     msgDict = {
         "messageClass": "EMAIL",
         "priority": "BULK",
         "receiver": "*****@*****.**",
         "message": "test message with html content",
         "body": body,
         "attachmentId": [23303]
     }
     msgObj = NSAdminObject.message(msgDict)
     msgId = self.nsObj.sendMessage(msgObj)
     resp = self.nsadminHelper.assertWithWaitUntil(
         msgId, ['RECEIVED_IN_QUEUE', 'SENT'], 'Messages status ACK', 10)
     currentMonthTable = NSAdminHelper.getDataTableName()
     query = 'select attachment_id from ' + currentMonthTable + ' where nsadmin_id=' + str(
         msgId)
     resp = dbHelper.queryDB(query, 'nsadmin')
     Assertion.constructAssertion(resp[0][0] == '23303',
                                  'Messages attachmentId')