Example #1
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 #2
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')