Пример #1
0
    def test_downloadCoupon_Generic(self, description):
        try:
            couponCode = LuciHelper.generateCouponCode()
            couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
                self, {
                    'client_handling_type': 'GENERIC',
                    'genericCode': couponCode
                })

            couponCode1 = LuciHelper.issueCouponAndAssertions(
                self, couponSeriesId)[0]
            self.userId = constant.config['usersInfo'][1]['userId']
            couponCode2 = LuciHelper.issueCouponAndAssertions(
                self, couponSeriesId)[0]
            DracarysHelper.downloadCouponsRequestAndAssertion(
                self, couponSeriesId,
                self.DracarysObj.DownloadReportType['ISSUED'],
                [couponCode1, couponCode2])
            LuciHelper.redeemCouponAndAssertions(self, couponSeriesId,
                                                 couponCode)
            DracarysHelper.downloadCouponsRequestAndAssertion(
                self, couponSeriesId,
                self.DracarysObj.DownloadReportType['REDEEMED'], [couponCode])
        finally:
            self.userId = constant.config['usersInfo'][0]['userId']
Пример #2
0
 def test_downloadCoupon_001_sanity(self, description):
     couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self)[1]
     couponCode = LuciHelper.issueCouponAndAssertions(self,
                                                      couponSeriesId)[0]
     DracarysHelper.downloadCouponsRequestAndAssertion(
         self, couponSeriesId,
         self.DracarysObj.DownloadReportType['ISSUED'], [couponCode])
     LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode)
     DracarysHelper.downloadCouponsRequestAndAssertion(
         self, couponSeriesId,
         self.DracarysObj.DownloadReportType['REDEEMED'], [couponCode])
Пример #3
0
 def setBaseState():
     module = constant.config['module']
     if module == 'nsadmin':
         NSAdminHelper.checkCommServerConn()
     if module == 'iris':
         NSAdminHelper.checkCommServerConn(ignoreConnectionError=True)
         LuciHelper.checkLuciConn(ignoreConnectionError=False)
     if module == 'irisv2':
         LuciHelper.checkLuciConn(ignoreConnectionError=True)
         ReonHelper.checkReonConnection(ignoreConnectionError=True)
         NSAdminHelper.checkCommServerConn()
         CampaignShardHelper.checkCampaignShardConnection()
     if module == 'luci':
         LuciHelper.loginAndGetCookies()
         LuciHelper.checkLuciConn()
         DracarysHelper.checkDracarysConn()
         LuciHelper.setBaseDetails()
     if module == 'veneno':
         LuciHelper.checkLuciConn(ignoreConnectionError=True)
         LuciDBHelper.getAdminUserId()
         VenenoHelper.checkVenenoServerConnection()
         NSAdminHelper.checkCommServerConn(ignoreConnectionError=True)
         CampaignShardHelper.checkCampaignShardConnection()
     if module == 'campaign_shard':
         CampaignShardHelper.checkCampaignShardConnection()
     if module == 'darknight':
         DarknightHelper.checkDarknightConn()
     if module == 'campaignsui':
         NSAdminHelper.checkCommServerConn(ignoreConnectionError=True)
         TemporalHelper.checkTemporalServerConnection(ignoreConnectionError=True)
         try:
             status, version = ChromeDriverManager.checkChromeDriverCompatibility()
             if not status:
                 ChromeDriverManager.downloadChromeDriver(version)
         except:
             Logger.log(traceback.format_exc())
     if module == 'emf' or module == 'peb':
         LoyaltyHelper.checkEMFConn()
         PEBHelper.checkPEBConn()
     if module == 'peb':
         PEBHelper.checkPEBConn()
     if module == 'social':
         SocialHelper.checkSocialConn()
         VenenoHelper.checkVenenoServerConnection()
         LuciHelper.checkLuciConn(ignoreConnectionError=True)
         LuciDBHelper.getAdminUserId()
         DracarysHelper.checkDracarysConn(ignoreConnectionError=True)
         LuciHelper.loginAndGetCookies()
         LuciHelper.setBaseDetails()
Пример #4
0
 def setup_method(self, method):
     self.connObj = LuciHelper.getConnObj(newConnection=True)
     Logger.logMethodName(method.__name__)
     constant.config['uploadedFileName'] = method.__name__
     self.DracraysConnObj = DracarysHelper.getConnObj(newConnection=True)
     constant.config['requestId'] = 'luci_auto_' + str(
         random.randint(11111, 99999))
Пример #5
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
Пример #6
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)
Пример #7
0
    def test_downloadCoupon_DCP(self, description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self, {'client_handling_type': 'DISC_CODE_PIN'})

        LuciHelper.uploadCouponAndAssertions(self,
                                             couponSeriesId,
                                             2,
                                             noOfCouponsToBeUpload=2)
        # Issue Coupon Code
        couponCode = LuciHelper.issueCouponAndAssertions(self,
                                                         couponSeriesId)[0]
        DracarysHelper.downloadCouponsRequestAndAssertion(
            self, couponSeriesId,
            self.DracarysObj.DownloadReportType['ISSUED'], [couponCode])
        LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode)
        DracarysHelper.downloadCouponsRequestAndAssertion(
            self, couponSeriesId,
            self.DracarysObj.DownloadReportType['REDEEMED'], [couponCode])
Пример #8
0
    def test_downloadCoupon_issued_24HR(self, description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self, {'client_handling_type': 'DISC_CODE_PIN'})

        LuciHelper.uploadCouponAndAssertions(self,
                                             couponSeriesId,
                                             2,
                                             noOfCouponsToBeUpload=2)
        # Issue Coupon Code
        couponCode, couponDetails = LuciHelper.issueCouponAndAssertions(
            self, couponSeriesId)
        changeDate = Utils.getTime(days=-1, minutes=-5, milliSeconds=True)
        self.connObj.changeCouponIssuedDate(couponDetails['id'], changeDate)
        DracarysHelper.downloadCouponsRequestAndAssertion(
            self, couponSeriesId,
            self.DracarysObj.DownloadReportType['ISSUED'], [])
        LuciHelper.redeemCouponAndAssertions(self, couponSeriesId, couponCode)
        DracarysHelper.downloadCouponsRequestAndAssertion(
            self, couponSeriesId,
            self.DracarysObj.DownloadReportType['REDEEMED'], [couponCode])
Пример #9
0
    def test_downloadCoupon_External(self, description):
        couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(
            self,
            couponConfigReq={
                'client_handling_type': 'DISC_CODE_PIN',
                'any_user': True,
                'isExternalIssual': True
            })

        couponCode = LuciHelper.uploadCouponAndAssertions(
            self, couponSeriesId, 2, noOfCouponsToBeUpload=2)['coupons'][0]
        self.userId = -1
        DracarysHelper.downloadCouponsRequestAndAssertion(
            self, couponSeriesId,
            self.DracarysObj.DownloadReportType['ISSUED'],
            [couponCode, 'DummyCode'])
        self.userId = constant.config['usersInfo'][0]['userId']
        LuciHelper.redeemCouponAndAssertions(self,
                                             couponSeriesId,
                                             couponCode,
                                             couponIssuedTo=[-1])
        DracarysHelper.downloadCouponsRequestAndAssertion(
            self, couponSeriesId,
            self.DracarysObj.DownloadReportType['REDEEMED'], [couponCode])
Пример #10
0
 def downloadFile(self, s3File):
     data = DracarysHelper.s3FileDownload(self, s3File).splitlines()
     dataiters = iter(data)
     valuesToReturn = []
     isHeader = True
     for x in dataiters:
         if isHeader:
             isHeader = False
         else:
             y = x.split(',')
             valuesToReturn.append({
                 'errorMsg':
                 y[0],
                 'couponCode':
                 y[1],
                 'couponId':
                 y[2].strip() if y[2].strip() == 'NA' else int(y[2]),
                 'userId':
                 y[3].strip() if y[3].strip() == 'NA' else int(y[3])
             })
     return valuesToReturn
Пример #11
0
    def uploadCouponAndAssertions(self,
                                  couponSeriesId,
                                  uploadType,
                                  issuedTo='-1',
                                  noOfCouponsToBeUpload=1,
                                  couponCode=None,
                                  dracraysUpload={}):
        isTaggedCoupon = True
        if uploadType == 2:
            isTaggedCoupon = False
        if False:  #Change as True for old upload flow
            couponCodeVsUserMap = {}
            for _ in range(noOfCouponsToBeUpload):
                if couponCode == None or noOfCouponsToBeUpload != 1:
                    couponCode = LuciHelper.generateCouponCode()
                if uploadType != 2:
                    couponCodeVsUserMap.update({couponCode: str(issuedTo)})
                else:
                    couponCodeVsUserMap.update({couponCode: issuedTo})

            uploadCouponRequest = {
                'couponCodeVsUserMap': couponCodeVsUserMap,
                'couponSeriesId': couponSeriesId,
                's3Location': constant.config['requestId'],
                'importType': uploadType
            }
            uploadCouponRes = self.connObj.uploadCoupons(
                LuciObject.uploadCouponsRequest(uploadCouponRequest))
            if len(uploadCouponRes) == 0:
                # Get Coupon Configuration
                if issuedTo != '-1':
                    LuciHelper.getCouponConfigAndAssertion(
                        self, couponSeriesId, len(couponCodeVsUserMap), 0)
                else:
                    LuciHelper.getCouponConfigAndAssertion(
                        self, couponSeriesId, 0, 0)
            else:
                Assertion.constructAssertion(
                    uploadCouponRes[couponCode] == 'duplicate coupon code',
                    'Duplicate Coupon Code is not uploaded')
            return {'coupons': [couponCode]}
        else:
            tmpDict = {
                'errorCount': 0,
                'userOnly': False,
                'invalidCase': [False, False],
                'couponCodeCAPS': True
            }
            tmpDict.update(dracraysUpload)
            uploadDict = DracarysHelper.uploadCoupons(
                self,
                couponSeriesId,
                onlyUser=tmpDict['userOnly'],
                is_invalidCase=tmpDict['invalidCase'],
                identifierType=self.constructObj.
                CustomerIdentifierDracarys[uploadType],
                userTaggedCoupons=isTaggedCoupon,
                noOfCouponUpload=noOfCouponsToBeUpload,
                expectedError=tmpDict['errorCount'],
                couponISCAPS=tmpDict['couponCodeCAPS'])
            couponIssuedDBDetails = LuciDBHelper.getIssuedCoupons(
                couponSeriesId)
            if len(couponIssuedDBDetails) != 0:
                issuedCouponList = list()
                for cc in couponIssuedDBDetails:
                    issuedCouponList.append(cc['couponCode'])
                uploadDict['coupons'] = issuedCouponList
                return uploadDict
            else:
                return uploadDict
Пример #12
0
    def initializeConstants(args):
        module = constant.config['module'] = args.module.lower()
        runId = args.runId
        collectOnly = constant.config['collectOnly'] = args.collectOnly
        tcFilter = args.tcFilter
        cluster = constant.config['cluster'] = args.cluster.lower()
        if collectOnly:
            if 'cluster' in args.cluster.lower():
                cluster = constant.config['cluster'] = 'nightly'
            constant.config['campaignId'] = 1

        if module.lower() == 'nsadmin':
            if tcFilter != '':
                tcFilter += ' and'
            if cluster.lower() in ['nightly', 'staging']:
                tcFilter += ' not Prod'
            else:
                tcFilter += ' Prod and ' + str(cluster.title())
            if args.prodEmail1 != '':
                constant.prodNumbers['prodEmail1'] = args.prodEmail1
        constant.config['tcFilter'] = tcFilter

        if not module in runId.lower():
            runId = module.title() + '_' + runId
        msg = 'Initializing Suite for Cluster: ' + cluster + ' Module: ' + module
        if tcFilter != '':
            msg += ' Filter: ' + tcFilter
        print msg

        constant.config['runId'] = runId
        constant.config['logDir'] = constant.logDirectory + runId
        constant.config['currentTimestamp'] = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
        constant.config.update(constant.portsUsed[cluster])
        constant.config.update(constant.clusterUrl[cluster])
        constant.config.update(constant.auth[cluster])
        constant.config.update(constant.intouchEndpoints)
        constant.config.update(constant.endpoints)
        BaseState.updateOrgDetails(module)
        if module in ['iris','irisv2', 'veneno', 'darknight', 'campaign_shard', 'campaignsui', 'social']:
            constant.config.update(constant.wechatMobilepush[cluster])
            if constant.config['cluster'] in ['nightly', 'staging', 'china']: constant.config['wecrm_details'] = \
                constant.config['wechat']['wecrm_details']
            constant.config.update(constant.aryaEndpoints)
            constant.config.update({'campaignDefaultObjectCopy': copy.deepcopy(constant.campaignDefaultValues)})
            try:
                authResponse = auth.authLogin()
                if authResponse['cookies'].get_dict() != {}:
                    constant.config['aryaCookiesDict'] = authResponse['cookies'].get_dict()
                    constant.config['token'] = authResponse['json']['token']
                else:
                    raise Exception('')
            except:
                print '------------------------------Arya Cookies Not Set------------------------------'

        if module in ['emf', 'peb']:
            orgId = constant.config['orgId']
            constant.config.update(constant.emfConstants[cluster][orgId])
        if module in ['luci', 'veneno', 'social']:
            constant.config['requestId'] = 'requestId_' + str(randValues.randomInteger(5))
            constant.config['dateTime'] = DracarysHelper.getValueOfDay()
        if not collectOnly:
            Utils.createFolder(constant.config['logDir'])
            Logger.configureLogging(constant.config['logDir'])
        if constant.config['os'] != 'windows':
            dbHelper.getIntouchShardNameForOrg(module)
            dbHelper.buildDBToTunnelPortMapping()
        if module == 'veneno' and not collectOnly:
            if constant.config['cluster'] == 'nightly': VenenoHelper.updateStartegyForRateLimit()
        if module == 'irisv2':
            constant.irisGenericValues = {'goalId': '1', 'objectiveId': '1', 'existingUserId': '1',
                                          'existingUserExternalId': '1'}
        if module in ['iris', 'veneno', 'campaign_shard', 'campaignsui', 'darknight', 'social']:
            constant.config['skipped_errors'] = dbCallsList.getSkippedErrorTypes()
            constant.config.update(constant.irisDetails[cluster])
            if collectOnly:
                constant.irisGenericValues = {'goalId': '1', 'objectiveId': '1', 'existingUserId': '1',
                                              'existingUserExternalId': '1'}
            else:
                try:
                    goalId = str(dbCallsCampaign.getValidGoalId())
                    objectiveId = str(dbCallsCampaign.getValidObjectiveId())
                    existingUserDetail = dbCallsMessage.getUsersInformation(1)[0]
                    constant.irisGenericValues = {'goalId': goalId, 'objectiveId': objectiveId,
                                                  'existingUserId': existingUserDetail[0],
                                                  'existingUserExternalId': existingUserDetail[5]}
                except Exception, exp:
                    constant.irisGenericValues = {'goalId': '1', 'objectiveId': '1', 'existingUserId': '1',
                                                  'existingUserExternalId': '1'}
                    Logger.log(
                        'Exception :{} occured while setting irisGeneric Values , so setting the values by Default as :{}'.format(
                            exp, constant.irisGenericValues))