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