Esempio n. 1
0
    def assertFileCreatedAndS3File(self, fileName, s3FilePath):
        filePath = constant.autoTempFilePath + fileName
        dataFromS3 = AWSHelper.readFileFromS3(
            '{}{}'.format(self.bucketUsed, constant.config['cluster']),
            s3FilePath)
        dataFromFile = FileHelper.readFile(filePath).split('\n')

        Assertion.constructAssertion(
            len(dataFromFile) == len(dataFromS3),
            'Data in File :{} and in s3 :{}'.format(dataFromFile, dataFromS3))
        for eachLine in dataFromS3:
            Assertion.constructAssertion(
                eachLine in dataFromFile,
                'line :{} Found in File used to Create List'.format(eachLine))
Esempio n. 2
0
    def assertErrorFileCreateAndS3File(self, uploadObject, errorReasons):
        fileName = uploadObject['fileName']
        s3fileUrl = uploadObject['fileUrl']
        errorCount = uploadObject['errorCount']
        s3errorFileUrl = uploadObject['errorFileUrl']

        dataFromFile = filter(
            None,
            FileHelper.readFile(constant.autoTempFilePath +
                                fileName).split('\n'))
        correctDataFromS3 = filter(
            None,
            AWSHelper.readFileFromS3(
                '{}{}'.format(self.bucketUsed, constant.config['cluster']),
                s3fileUrl))
        errorDataFromoS3 = filter(
            None,
            AWSHelper.readFileFromS3(
                '{}{}'.format(self.bucketUsed, constant.config['cluster']),
                s3errorFileUrl))[1:]

        Logger.log(
            'DataList Of File :{} , Correct Data From s3 :{} and errorDataFroms3 :{}'
            .format(dataFromFile, correctDataFromS3, errorDataFromoS3))

        Assertion.constructAssertion(
            len(dataFromFile) == len(correctDataFromS3),
            'Total Error Count :{} and in s3 correct Data :{} , error Data :{}'
            .format(len(dataFromFile), len(correctDataFromS3),
                    len(errorDataFromoS3)))
        Assertion.constructAssertion(
            len(errorDataFromoS3) == errorReasons[fileName]['numberOfUser'],
            'In S3 Number Of Error Users are :{} and Expected :{}'.format(
                len(errorDataFromoS3), errorReasons[fileName]['numberOfUser']))
        maxLineCheck = 100
        for eachUser in errorDataFromoS3:
            if maxLineCheck == 0: break
            Assertion.constructAssertion(
                eachUser.split(',')[-1] in errorReasons[fileName]['reason'],
                'Error :{} in File for line :{} , is in Expected List :{} '.
                format(
                    eachUser.split(',')[-1], eachUser, errorReasons[fileName]))
            maxLineCheck = maxLineCheck - 1
Esempio 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')