Ejemplo n.º 1
0
 def revokes3FileAndRequestObject(self, couponSeriesId, couponData,
                                  revokeTypeIndex):
     invalidateDict = {
         'uploadedFileName':
         constant.config['uploadedFileName'] + '_revokeFile'
     }
     filehandle = FileHelper(constant.luciS3FilePath)
     filehandle.eraseContentFromFile()
     revokeType = [
         'COUPON_SERIES', 'ONLY_UNISSUED', 'userId', 'couponCode',
         'couponId', 'CUSTOMER_AND_COUPON'
     ]
     if revokeType[revokeTypeIndex] == 'userId':
         filehandle.appendToFile(revokeType[revokeTypeIndex])
         invalidateDict.update({'revokeHeaders': {'userId': 0}})
     elif revokeType[revokeTypeIndex] == 'couponCode':
         filehandle.appendToFile(revokeType[revokeTypeIndex])
         invalidateDict.update({'revokeHeaders': {'couponCode': 0}})
     elif revokeType[revokeTypeIndex] == 'couponId':
         filehandle.appendToFile(revokeType[revokeTypeIndex])
         invalidateDict.update({'revokeHeaders': {'couponId': 0}})
     elif revokeType[revokeTypeIndex] == 'CUSTOMER_AND_COUPON':
         filehandle.appendToFile('userId,couponCode')
         invalidateDict.update(
             {'revokeHeaders': {
                 'userId': 1,
                 'couponCode': 0
             }})
     for eachData in couponData:
         filehandle.appendToFile(eachData)
     invalidateDict.update(
         {'S3FilePath': DracarysHelper.s3FileUpload(self, couponSeriesId)})
     return invalidateDict
Ejemplo n.º 2
0
    def generateCouponUploadFile(self,
                                 identifier='userId',
                                 isUserTagged=False,
                                 isOnlyUser=False,
                                 noOfRecords=1,
                                 is_Invalid=[False, False],
                                 couponCodeCAPS=True):
        couponUploadFile = constant.luciS3FilePath
        filehandle = FileHelper(couponUploadFile)
        First = True
        data = []
        filehandle.eraseContentFromFile()
        if isUserTagged and not isOnlyUser:
            filehandle.appendToFile('Coupon Code, issuedTo')
            for i in range(noOfRecords):
                if not couponCodeCAPS:
                    couponCode = DracarysHelper.generateCouponCode().lower()
                else:
                    couponCode = DracarysHelper.generateCouponCode()
                    if First:
                        duplicateCoupon = couponCode + ', ' + str(
                            constant.config['usersInfo'][i][identifier])
                        First = False
                filehandle.appendToFile(
                    couponCode + ', ' +
                    str(constant.config['usersInfo'][i][identifier]))
                data.append(couponCode)
            if is_Invalid[0]:
                filehandle.appendToFile(duplicateCoupon)
            elif is_Invalid[1]:
                couponCode = DracarysHelper.generateCouponCode()
                if identifier == 'mobile':
                    filehandle.appendToFile(
                        couponCode + ', ' +
                        str(randValues.getRandomMobileNumber()))
                elif identifier == 'email':
                    filehandle.appendToFile(couponCode + ', ' +
                                            str(randValues.randomEmailId()))
                elif identifier in ['userId', 'externalId']:
                    filehandle.appendToFile(
                        couponCode + ', ' +
                        str(randValues.randomInteger(digits=8)))
        elif isOnlyUser:
            filehandle.appendToFile('issuedTo')
            for i in range(noOfRecords):
                filehandle.appendToFile(
                    str(constant.config['usersInfo'][i][identifier]))
            if is_Invalid[0]:
                filehandle.appendToFile(
                    str(constant.config['usersInfo'][0][identifier]))
            elif is_Invalid[1]:
                if identifier == 'mobile':
                    filehandle.appendToFile(
                        str(randValues.getRandomMobileNumber()))
                elif identifier == 'email':
                    filehandle.appendToFile(str(randValues.randomEmailId()))
                elif identifier in ['userId', 'externalId']:
                    filehandle.appendToFile(
                        str(randValues.randomInteger(digits=8)))
        else:
            filehandle.appendToFile('Coupon Code')
            for _ in range(noOfRecords):
                if not couponCodeCAPS:
                    couponCode = DracarysHelper.generateCouponCode().lower()
                else:
                    couponCode = DracarysHelper.generateCouponCode()
                if First:
                    duplicateCoupon = couponCode
                    filehandle.appendToFile(duplicateCoupon)
                    data.append(duplicateCoupon)
                    First = False
                else:
                    filehandle.appendToFile(couponCode)
                    data.append(couponCode)
            if is_Invalid[0]:
                filehandle.appendToFile(duplicateCoupon)
            elif is_Invalid[1]:
                filehandle.appendToFile(
                    DracarysHelper.generateCouponCode(size=21))

        return data