Example #1
0
 def setup_class(self):
     self.numberOfUsers = 20
     self.constructObj = LuciObject()
     self.DracarysObj = DracarysObject()
     self.DracraysConnObj = DracarysHelper.getConnObj(newConnection=True)
     self.campaigns = SocialHelper.createCampaignsForSocialThrift(
         testControlType=['ORG'])
     self.groupVersionid, self.groupName = SocialHelper.createListForSocial(
         self.campaigns,
         'ORG',
         numberOfUsers=self.numberOfUsers,
         newUser=True)
     self.remoteCampaignId = SocialHelper.createRemoteCampaignsForSocialThrift(
         self.campaigns['ORG'])
     SocialHelper.updateRemoteCampaignIdInCampaignsBase(
         self.campaigns['ORG'], self.remoteCampaignId)
     self.voucherSeriesId = coupons.createCoupons(
         campaignId=self.campaigns['ORG'],
         payloadData={
             'couponLimit': {
                 'limit': 0,
                 'type': 'UNLIMITED'
             },
             'discountOn': 'BILL',
             'discountType': 'ABS',
             'discountValue': 10
         })[0]['json']['entity']['voucherSeriesId']
     SocialHelper.couponConfigChange(
         {
             'client_handling_type': 'EXTERNAL_ISSUAL',
             'any_user': True
         }, self.campaigns['ORG'], self.voucherSeriesId)
 def setup_class(self):
     Logger.logSuiteName(str(self).split('.')[-1])
     self.constructObj = LuciObject()
     self.DracarysObj = DracarysObject()
     self.userId = constant.config['usersInfo'][0]['userId']
     self.tillId = constant.config['tillIds'][0]
     self.orgDefaultValue = LuciDBHelper.orgDefaultValues()
Example #3
0
 def downloadCouponsRequestAndAssertion(self,
                                        couponSeriesId,
                                        reportType,
                                        couponCode=[]):
     requestObj = DracarysObject.DownloadCouponsRequest({
         'couponSeriesId':
         couponSeriesId,
         'downloadReportType':
         reportType
     })
     dcrResponse = self.DracraysConnObj.downloadCouponsReport(
         requestObj).__dict__
     Assertion.constructAssertion(
         dcrResponse['errorCode'] == 0,
         'Error Code is Actual : {} and Expected : 0'.format(
             dcrResponse['errorCode']))
     Assertion.constructAssertion(
         dcrResponse['errorMessage'] == None,
         'Error Message is Actual : {} and Expected : None'.format(
             dcrResponse['errorMessage']))
     Assertion.constructAssertion(
         dcrResponse['jobId'] != None,
         'JobId is Actual : {} and Expected : not None'.format(
             str(dcrResponse['jobId'])))
     Assertion.constructAssertion(
         dcrResponse['downloadReportType'] == reportType,
         'Download report type is Actual : {} and Expected : {}'.format(
             str(dcrResponse['downloadReportType']), str(reportType)))
     Assertion.constructAssertion(
         dcrResponse['couponSeriesId'] == couponSeriesId,
         'Requested Coupon series Id  is Mismatch Actual : {} and Expected : {}'
         .format(str(dcrResponse['couponSeriesId']), str(couponSeriesId)))
     DracarysHelper.getDownloadStatusAndAssertion(self, couponSeriesId,
                                                  dcrResponse['jobId'],
                                                  reportType, couponCode)
 def setup_class(self):
     Logger.logSuiteName(str(self).split('.')[-1])
     self.constructObj = LuciObject()
     self.DracarysObj = DracarysObject()
     self.userId = constant.config['usersInfo'][0]['userId']
     self.tillId = constant.config['tillIds'][0]
     self.billId = Utils.getTime(milliSeconds=True)
Example #5
0
 def setup_class(self):
     Logger.logSuiteName(str(self).split('.')[-1])
     self.constructObj = LuciObject()
     self.DracarysObj = DracarysObject()
     self.uploadTypeList = ['USER_ID', 'MOBILE', 'EMAIL', 'EXTERNAL_ID']
     self.userId = constant.config['usersInfo'][0]['userId']
     self.userIds = list()
     self.tillId = constant.config['tillIds'][0]
Example #6
0
 def setup_class(self):
     Logger.logSuiteName(str(self).split('.')[-1])
     self.constructObj = LuciObject()
     self.userIds = []
     self.bulkUserIds = []
     self.DracarysObj = DracarysObject()
     for i in range(len(constant.config['usersInfo'])):
         self.userIds.append(constant.config['usersInfo'][i]['userId'])
     self.tillId = constant.config['tillIds'][0]
Example #7
0
    def test_downloadCoupon_002(self):
        self.couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self)[1]
        tmpListOfUsers = []
        for _ in range(2500):
            tmpListOfUsers.append(randValues.randomInteger(7))
        listOfUsers = list(set(tmpListOfUsers))
        limit = 1000
        for i in range(0, len(listOfUsers)):
            if limit > len(listOfUsers):
                limit = len(listOfUsers)
            Logger.log(listOfUsers[i:limit])
            LuciHelper.issueMultipleCoupon(
                self,
                self.couponSeriesId,
                listOfUsers[i:limit],
                expectResponseException=[True, 'coupons exhausted'])
            i = limit
            limit = limit + 1000

        requestObj = DracarysObject.DownloadCouponsRequest(
            {'couponSeriesId': self.couponSeriesId})
        jobRes = self.DracraysConnObj.downloadCouponsReport(
            requestObj).__dict__
        requestsStatusObj = DracarysObject.GetDownloadStatus({
            'couponSeriesId':
            self.couponSeriesId,
            'jobId':
            jobRes['jobId']
        })
        statusRes = self.DracraysConnObj.getDownloadStatus(
            requestsStatusObj).__dict__
        for _ in range(10):
            if statusRes['downloadReportJobStatus'] != 2 and statusRes[
                    'downloadReportJobStatus'] != 1:
                time.sleep(1)
                statusRes = self.DracraysConnObj.getDownloadStatus(
                    requestsStatusObj).__dict__
            else:
                break
Example #8
0
 def test_downloadCoupon_Invalid_001(self, description, requestParam,
                                     expectedError):
     try:
         couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self)[1]
         LuciHelper.issueCouponAndAssertions(self, couponSeriesId)
         request = {
             'couponSeriesId': couponSeriesId,
             'downloadReportType': 1
         }
         request.update(requestParam)
         requestObj = DracarysObject.DownloadCouponsRequest(request)
         self.DracraysConnObj.downloadCouponsReport(requestObj)
     except Exception, luciExp:
         luciExp = luciExp.__dict__
         Assertion.constructAssertion(
             luciExp['errorCode'] == expectedError[0],
             'Error Code Mismatched Actual : {} and Expected : {}'.format(
                 luciExp['errorCode'], expectedError[0]))
         Assertion.constructAssertion(
             luciExp['errorMsg'] == expectedError[1],
             'Error Msg Mismatched Actual : {} and Expected : {}'.format(
                 luciExp['errorMsg'], expectedError[0]))
Example #9
0
 def messageConstruct(self, reminderMessages):
     # SMS = 0; EMAIL = 1; WECHAT = 2; MOBILE_PUSH = 3
     reminderMessageList = []
     for reminderMessageDict in reminderMessages:
         reminderMessageRequest = {'type': reminderMessageDict['type']}
         if reminderMessageDict['type'] is 0:
             messageObj = {
                 'smsMessage':
                 DracarysObject.smsMessage(reminderMessageDict['message'])
             }
             reminderMessageRequest.update(messageObj)
         elif reminderMessageDict['type'] is 1:
             messageObj = {
                 'emailMessage':
                 DracarysObject.emailMessage(reminderMessageDict['message'])
             }
             reminderMessageRequest.update(messageObj)
         elif reminderMessageDict['type'] is 2:
             messageObj = {
                 'wechatMessage':
                 DracarysObject.wechatMessage(
                     reminderMessageDict['message'])
             }
             reminderMessageRequest.update(messageObj)
         elif reminderMessageDict['type'] is 3:
             messageObj = {
                 'mobilePushMessage':
                 DracarysObject.mobilePushMessage(
                     reminderMessageDict['message'])
             }
             reminderMessageRequest.update(messageObj)
         reminderMessageList.append(
             DracarysObject.CouponReminderMessageDetails({
                 'reminderMessage':
                 DracarysObject.reminderMessage(reminderMessageRequest)
             }))
     return reminderMessageList
Example #10
0
    def getDownloadStatusAndAssertion(self,
                                      couponSeriesId,
                                      jobId,
                                      reportType,
                                      couponCode=[]):
        requestsStatusObj = DracarysObject.GetDownloadStatus({
            'couponSeriesId': couponSeriesId,
            'jobId': jobId
        })
        statusRes = self.DracraysConnObj.getDownloadStatus(
            requestsStatusObj).__dict__
        for _ in range(10):
            if statusRes['downloadReportJobStatus'] == 2:
                Assertion.constructAssertion(
                    statusRes['errorCode'] == 0,
                    'Error Code is Actual : {} and Expected : 0'.format(
                        statusRes['errorCode']))
                Assertion.constructAssertion(
                    statusRes['errorMessage'] == None,
                    'Error Message is Actual : {} and Expected : None'.format(
                        statusRes['errorMessage']))
                Assertion.constructAssertion(
                    statusRes['s3FilePath'] != None,
                    's3FilePath is not None Actual : {}'.format(
                        statusRes['s3FilePath']))
                Assertion.constructAssertion(
                    statusRes['jobId'] == jobId,
                    'JobId is Actual : {} and Expected : {}'.format(
                        str(statusRes['jobId']), str(jobId)))
                Assertion.constructAssertion(
                    statusRes['downloadReportType'] == reportType,
                    'Download report type is Actual : {} and Expected : {}'.
                    format(str(statusRes['downloadReportType']),
                           str(reportType)))
                Assertion.constructAssertion(
                    statusRes['couponSeriesId'] == couponSeriesId,
                    'Requested Coupon series Id  is Mismatch Actual : {} and Expected : {}'
                    .format(str(statusRes['couponSeriesId']),
                            str(couponSeriesId)))
                Assertion.constructAssertion(
                    statusRes['totalDownloadCount'] == len(couponCode),
                    'Download Coupon Count  is Mismatch Actual : {} and Expected : {}'
                    .format(str(statusRes['totalDownloadCount']),
                            str(len(couponCode))))
                break
            else:
                time.sleep(1)
                statusRes = self.DracraysConnObj.getDownloadStatus(
                    requestsStatusObj).__dict__

        Assertion.constructAssertion(
            statusRes['downloadReportJobStatus'] == 2,
            'Download Report Failed status is Actual : {} and Expected : 2'.
            format(str(statusRes['downloadReportJobStatus'])))
        data = DracarysHelper.s3FileDownload(self, statusRes['s3FilePath'])
        dataSplited = data.split('\n')
        if len(couponCode) > 0:
            row1 = couponCode[0] + ',' + str(self.userId)
            Assertion.constructAssertion(
                row1 in dataSplited,
                'Coupon Code  and UserId not Available in downloaded s3File')
Example #11
0
    def saveCouponExpiryReminder(self,
                                 reminderInfoList=[],
                                 isConfigupdate=False,
                                 updateConfigScheduler={}):
        couponReminderDetailsObjList = []
        couponReminderResponseDict = []
        reminderIds = []
        messageIds = []

        if not isConfigupdate:
            for reminderInfo in reminderInfoList:
                if len(reminderInfo) == 4:
                    couponReminderRequestDict = {
                        'couponSeriesId':
                        self.couponSeriesId,
                        'numDaysBeforeExpiry':
                        reminderInfo[0],
                        'hourOfDay':
                        reminderInfo[1],
                        'minuteOfHour':
                        reminderInfo[2],
                        'reminderMessages':
                        DracarysHelper.messageConstruct(self, reminderInfo[3])
                    }
                else:
                    couponReminderRequestDict = {
                        'couponSeriesId': self.couponSeriesId,
                        'numDaysBeforeExpiry': reminderInfo[0],
                        'hourOfDay': reminderInfo[1],
                        'minuteOfHour': reminderInfo[2]
                    }
                couponReminderDetailsObjList.append(
                    DracarysObject.CouponReminderDetails(
                        couponReminderRequestDict))
        else:
            for couponReminderDetails, updateSchedule in zip(
                    updateConfigScheduler['couponReminderDetails'],
                    updateConfigScheduler['updateScheduler']):
                couponReminderDetails.update({
                    'numDaysBeforeExpiry':
                    updateSchedule[0],
                    'hourOfDay':
                    updateSchedule[1],
                    'minuteOfHour':
                    updateSchedule[2]
                })
                couponReminderDetailsObjList.append(
                    DracarysObject.CouponReminderDetails(
                        couponReminderDetails))

        saveCouponReminderRequest = DracarysObject.SaveCouponReminderRequest({
            'couponSeriesId':
            self.couponSeriesId,
            'couponReminderDetails':
            couponReminderDetailsObjList
        })
        couponsReminderResponseObj = self.DracraysConnObj.saveCouponReminder(
            saveCouponReminderRequest)
        for k in couponsReminderResponseObj:
            couponReminderResponseDict.append(k.__dict__)
        for k in couponReminderResponseDict:
            if k['reminderMessages'] != []:
                reminderIds.append(k['id'])
                for l in k['reminderMessages']:
                    l = l.__dict__
                    messageIds.append(l['id'])
        return couponReminderResponseDict, reminderIds, messageIds
Example #12
0
    def uploadCoupons(self,
                      couponSeriesId,
                      onlyUser=False,
                      identifierType='userId',
                      userTaggedCoupons=False,
                      noOfCouponUpload=1,
                      is_invalidCase=[False, False],
                      expectedError=0,
                      couponISCAPS=True):
        if is_invalidCase[0] and is_invalidCase[1]:
            couponCodeList = []
            is_invalidCase = [False, False]
        else:
            couponCodeList = DracarysHelper.generateCouponUploadFile(
                self,
                identifier=identifierType,
                isOnlyUser=onlyUser,
                isUserTagged=userTaggedCoupons,
                noOfRecords=noOfCouponUpload,
                is_Invalid=is_invalidCase,
                couponCodeCAPS=couponISCAPS)
        s3UploadFileName = DracarysHelper.s3FileUpload(self, couponSeriesId)
        valuesToReturn = {'coupons': couponCodeList, 'errors': []}
        uploadRequestDict = {
            'S3FilePath':
            s3UploadFileName,
            'couponSeriesId':
            couponSeriesId,
            'uploadedFileName':
            constant.config['uploadedFileName'],
            'custIdentifierType':
            self.DracarysObj.CustomerIdentifierType[identifierType]
        }
        if onlyUser:
            uploadRequestDict.update({'uploadHeaders': {identifierType: 0}})
        elif identifierType == 'notTagged':
            uploadRequestDict.update({'uploadHeaders': {'couponCode': 0}})
        else:
            uploadRequestDict.update(
                {'uploadHeaders': {
                    'couponCode': 0,
                    identifierType: 1
                }})

        response = self.DracraysConnObj.uploadCoupons(
            DracarysObject.couponUploadRequest(uploadRequestDict)).__dict__
        jobId = response['jobId']
        for _ in range(10):
            getUploadStatus = self.DracraysConnObj.getUploadStatusForCouponSeries(
                DracarysObject.getCouponUploadStatus(
                    {'couponSeriesId': couponSeriesId})).__dict__
            uploadStatusResponse = None
            for uploadStatus in getUploadStatus['uploadJobStatuses']:
                uploadStatus = uploadStatus.__dict__
                if jobId == uploadStatus['jobId']:
                    uploadStatusResponse = uploadStatus
            if uploadStatusResponse['uploadStatus'] == 3:
                if uploadStatusResponse['errorCount'] != 0:
                    errorFile = uploadStatusResponse['errorFileUrl']
                    data = DracarysHelper.s3FileDownload(
                        self, errorFile).splitlines()
                    dataiters = iter(data)
                    isHeader = True
                    for x in dataiters:
                        if isHeader:
                            header = x.split(',')
                            isHeader = False
                        else:
                            if 'issued, ' in x:
                                x = x.replace('issued, ', 'issued ')
                            y = x.split(',')
                            if len(header) == 3:
                                valuesToReturn['errors'].append({
                                    'ErrorMsg':
                                    y[0],
                                    'CouponCode':
                                    y[1],
                                    'UserId':
                                    y[2].strip()
                                    if y[2].strip() == 'NA' else int(y[2])
                                })
                            elif len(header) == 2:
                                valuesToReturn['errors'].append({
                                    'ErrorMsg':
                                    y[0],
                                    'CouponCode':
                                    y[1]
                                })
                if is_invalidCase[0] or is_invalidCase[1]:
                    Assertion.constructAssertion(
                        uploadStatusResponse['totalUploadedCount'] == (
                            noOfCouponUpload + 1),
                        'Total uploaded count Mismatch Actual: {} & Expected: {}'
                        .format(uploadStatusResponse['totalUploadedCount'],
                                (noOfCouponUpload + 1)))
                else:
                    Assertion.constructAssertion(
                        uploadStatusResponse['totalUploadedCount'] ==
                        noOfCouponUpload,
                        'Total uploaded count Mismatch Actual: {} & Expected: {}'
                        .format(uploadStatusResponse['totalUploadedCount'],
                                noOfCouponUpload))
                Assertion.constructAssertion(
                    uploadStatusResponse['errorCount'] == expectedError,
                    'ErrorCount count Mismatch Actual: {} & Expected: {}'.
                    format(uploadStatusResponse['errorCount'], expectedError))
                return valuesToReturn
            elif uploadStatusResponse['uploadStatus'] == 4:
                Assertion.constructAssertion(
                    False,
                    'Upload File status for coupon Series: {} is ERRORED '.
                    format(couponSeriesId))
            time.sleep(1)
        return valuesToReturn
Example #13
0
 def getCouponReminder(self):
     getCouponReminderRequest = DracarysObject.GetCouponReminderRequest(
         {'couponSeriesId': self.couponSeriesId})
     self.DracraysConnObj.getCouponReminders(getCouponReminderRequest)