Esempio n. 1
0
    def test_LYT_RED_REVERSE_01(self, description, requestParams,
                                errorDetails):
        try:
            if requestParams.has_key('pointsToBeReversed'):
                ptsRedemptionObject = EMFObject.PointsRedemptionEventData(
                    {'customerID': constant.config['usersInfo'][0]['userId']})
                response = self.EMFConnObj.pointsRedemptionEvent(
                    ptsRedemptionObject).__dict__
                requestParams.update({
                    'uniqueRedemptionId':
                    LoyaltyHelper.getInstructionsKeyValue(
                        response, 'REDEEM', 'uniqueRedemptionId')
                })

            ptsReverseObject = EMFObject.PointsRedemptionReversalEventData(
                requestParams)
            response = self.EMFConnObj.pointsRedemptionReversalEvent(
                ptsReverseObject).__dict__
            Assertion.constructAssertion(
                False, 'Expected Exception {} and Actual: {}'.format(
                    response, errorDetails))
        except Exception, exp:
            Logger.log(exp)
            exp = LoyaltyHelper.exceptionInstructorParser(exp.__dict__)
            Assertion.constructAssertion(
                errorDetails[1] in exp['errorMessage'],
                'Error Message Actual: {} and Expected: {}'.format(
                    exp['errorMessage'], errorDetails[1]))
            Assertion.constructAssertion(
                exp['statusCode'] == errorDetails[0],
                'Status Code Actual: {} and Expected: {}'.format(
                    exp['statusCode'], errorDetails[0]))
Esempio n. 2
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()
Esempio n. 3
0
 def setup_method(self, method):
     self.EMFConnObj = LoyaltyHelper.getConnObj('emfPort',
                                                newConnection=True)
     self.pointEngineConnObj = LoyaltyHelper.getConnObj('pointsEnginePort',
                                                        newConnection=True)
     self.PEBConnObj = PEBHelper.getConnObj(newConnection=True)
     constant.config['serverReqId'] = 'emf_auto_' + str(
         random.randint(11111, 99999))
     # LoyaltyHelper.addTransaction()
     LoyaltyDBHelper.getBillNumber()
     # LoyaltyDBHelper.getCustomerPointsSummary()
     self.customerId = constant.config['usersInfo'][0]['userId']
     self.storeId = constant.config['storeIds'][0]
     constant.config['defaultRedeemPts'] = 10
     Logger.log('Printing Constant file: ', constant.config)
     Logger.logMethodName(method.__name__)
Esempio n. 4
0
 def test_LYT_RED_REVERSE_05(self, description, pointsToBeReversed):
     time.sleep(1)
     billId = int(
         LoyaltyHelper.simplePropertiesParser(
             self.EMFConnObj.newBillEvent(
                 EMFObject.NewBillEvent()).__dict__)['sourceId'])
     initialRedeemedPoints = LoyaltyDBHelper.getSumOfPointsAwarded(
         self.customerId)['sumOfRedeemedValue']
     redemptionId = []
     uniqueRedemptionId = LoyaltyHelper.pointsRedemptionAndAssertion(
         self, constant.config['defaultRedeemPts'], initialRedeemedPoints,
         {'redeemedOnBillId': billId})['uniqueRedemptionId']
     prsDBDetails = LoyaltyDBHelper.getPointsRedemptionSummary(
         self.customerId, self.storeId,
         {'redemptionIds': uniqueRedemptionId})
     Assertion.constructAssertion(
         len(prsDBDetails) == len([uniqueRedemptionId]),
         'No of Records added to prs Actual: {} and Expected: {}'.format(
             len(prsDBDetails), len(uniqueRedemptionId)))
     for prs in prsDBDetails:
         Assertion.constructAssertion(
             prs['billId'] == billId,
             'RedemptionId updated to prs with BillId Actual: {} and Expected: {}'
             .format(prs['billId'], billId))
         Assertion.constructAssertion(
             prs['redemption_id'] in uniqueRedemptionId,
             'Unique Redemption Id is match with BillIds Actual: {} and Expected: {}'
             .format(prs['redemption_id'], uniqueRedemptionId))
         Assertion.constructAssertion(
             prs['redemptionType'] == 'REDEMPTION',
             'Redemption type is Matched Actual: {} and Expected: {}'.
             format(prs['redemptionType'], 'REDEMPTION'))
         redemptionId.append(prs['prs_id'])
     parsedResponse = LoyaltyHelper.redemptionReversalAndAssertion(
         self, [uniqueRedemptionId],
         {'pointsToBeReversed': pointsToBeReversed})
     LoyaltyHelper.redemptionReversalDBAssertion(
         self, redemptionId, parsedResponse['redemptionReversalId'],
         initialRedeemedPoints, pointsToBeReversed)
Esempio n. 5
0
 def test_LYT_RED_REVERSE_04(self, description, isValid):
     time.sleep(1)
     billId1 = LoyaltyHelper.simplePropertiesParser(
         self.EMFConnObj.newBillEvent(
             EMFObject.NewBillEvent()).__dict__)['sourceId']
     time.sleep(1)
     billId2 = LoyaltyHelper.simplePropertiesParser(
         self.EMFConnObj.newBillEvent(
             EMFObject.NewBillEvent({
                 'customerID':
                 constant.config['usersInfo'][1]['userId'],
                 'userDetails':
                 EMFObject.constructUserDetailsObject(1)
             })).__dict__)['sourceId']
     initialRedeemCus1 = LoyaltyDBHelper.getSumOfPointsAwarded(
         self.customerId)['sumOfRedeemedValue']
     uniqueRedemptionId1 = LoyaltyHelper.pointsRedemptionAndAssertion(
         self, constant.config['defaultRedeemPts'], initialRedeemCus1,
         {'redeemedOnBillId': int(billId1)})['uniqueRedemptionId']
     self.customerId = constant.config['usersInfo'][1]['userId']
     initialRedeemCus1 = LoyaltyDBHelper.getSumOfPointsAwarded(
         self.customerId)['sumOfRedeemedValue']
     uniqueRedemptionId2 = LoyaltyHelper.pointsRedemptionAndAssertion(
         self, constant.config['defaultRedeemPts'], initialRedeemCus1, {
             'redeemedOnBillId': int(billId2),
             'userDetails': EMFObject.constructUserDetailsObject(1)
         })['uniqueRedemptionId']
     LoyaltyHelper.redemptionReversalAndAssertion(
         self, uniqueRedemptionId1,
         {'userDetails': EMFObject.constructUserDetailsObject(1)},
         [3803, 'prs record not found for the unique redemption id'])
     self.customerId = constant.config['usersInfo'][0]['userId']
     LoyaltyHelper.redemptionReversalAndAssertion(
         self,
         uniqueRedemptionId2,
         expectException=[
             3803, 'prs record not found for the unique redemption id'
         ])
Esempio n. 6
0
    def test_LYT_RED_REVERSE_02(self, description, pointToReverse):
        uniqueRedemptionId = []
        redemptionId = []
        initialRedeemedPoints = LoyaltyDBHelper.getSumOfPointsAwarded(
            self.customerId)['sumOfRedeemedValue']
        noOfRedeem = 2
        for i in range(noOfRedeem):
            redeemPointsResponse = LoyaltyHelper.pointsRedemptionAndAssertion(
                self, pointToReverse,
                (initialRedeemedPoints + (i * pointToReverse)))
            uniqueRedemptionId.append(
                redeemPointsResponse['uniqueRedemptionId'])

        time.sleep(1)
        LoyaltyHelper.simplePropertiesParser(
            self.EMFConnObj.newBillEvent(
                EMFObject.NewBillEvent(
                    {'uniqueRedemptionId': uniqueRedemptionId})).__dict__)
        prsDBDetails = LoyaltyDBHelper.getPointsRedemptionSummary(
            self.customerId, self.storeId,
            {'redemptionIds': uniqueRedemptionId})
        Assertion.constructAssertion(
            len(prsDBDetails) == len(uniqueRedemptionId),
            'No of Records added to prs Actual: {} and Expected: {}'.format(
                len(prsDBDetails), len(uniqueRedemptionId)))
        for prs in prsDBDetails:
            Assertion.constructAssertion(
                prs['billId'] == constant.config['billNumber'],
                'RedemptionId updated to prs with BillId Actual: {} and Expected: {}'
                .format(prs['billId'], constant.config['billNumber']))
            Assertion.constructAssertion(
                prs['redemption_id'] in uniqueRedemptionId,
                'Unique Redemption Id is match with BillIds Actual: {} and Expected: {}'
                .format(prs['redemption_id'], uniqueRedemptionId))
            Assertion.constructAssertion(
                prs['redemptionType'] == 'REDEMPTION',
                'Redemption type is Matched Actual: {} and Expected: {}'.
                format(prs['redemptionType'], 'REDEMPTION'))
            redemptionId.append(prs['prs_id'])

        parsedResponse = LoyaltyHelper.redemptionReversalAndAssertion(
            self, [uniqueRedemptionId[0]])
        LoyaltyHelper.redemptionReversalDBAssertion(
            self, redemptionId, parsedResponse['redemptionReversalId'],
            (initialRedeemedPoints + pointToReverse))
        self.pointEngineConnObj.getPointsRedemptionSummaryForCustomer(
            self.orgId, self.customerId, True)
Esempio n. 7
0
 def test_LYT_RED_REVERSE_03(self, description):
     initialRedeemedPoints = LoyaltyDBHelper.getSumOfPointsAwarded(
         self.customerId)['sumOfRedeemedValue']
     ptsRedemptionResponse = LoyaltyHelper.pointsRedemptionAndAssertion(
         self, constant.config['defaultRedeemPts'], initialRedeemedPoints)
     time.sleep(1)
     self.EMFConnObj.newBillEvent(
         EMFObject.NewBillEvent({
             'uniqueRedemptionId':
             ptsRedemptionResponse['uniqueRedemptionId']
         }))
     parsedResponse = LoyaltyHelper.redemptionReversalAndAssertion(
         self, [ptsRedemptionResponse['uniqueRedemptionId']])
     LoyaltyHelper.redemptionReversalDBAssertion(
         self, ptsRedemptionResponse['pointsRedemptionSummaryId'],
         parsedResponse['redemptionReversalId'], initialRedeemedPoints)
     LoyaltyHelper.redemptionReversalAndAssertion(
         self, [ptsRedemptionResponse['uniqueRedemptionId']],
         expectException=[3802, "all redeemed points already reversed"])
Esempio n. 8
0
    def test_LYT_RED_REVERSE_06(self, description):
        redemptionId = []
        initialRedeemedPoints = LoyaltyDBHelper.getSumOfPointsAwarded(
            self.customerId)['sumOfRedeemedValue']
        uniqueRedemptionId = LoyaltyHelper.pointsRedemptionAndAssertion(
            self, constant.config['defaultRedeemPts'], initialRedeemedPoints,
            {'redeemedOnBillId': -1})['uniqueRedemptionId']

        prsDBDetails = LoyaltyDBHelper.getPointsRedemptionSummary(
            self.customerId, self.storeId,
            {'redemptionIds': uniqueRedemptionId})
        Assertion.constructAssertion(
            len(prsDBDetails) == len([uniqueRedemptionId]),
            'No of Records added to prs Actual: {} and Expected: {}'.format(
                len(prsDBDetails), len(uniqueRedemptionId)))
        for prs in prsDBDetails:
            Assertion.constructAssertion(
                prs['billId'] == -1,
                'RedemptionId updated to prs with BillId Actual: {} and Expected: {}'
                .format(prs['billId'], constant.config['billNumber']))
            Assertion.constructAssertion(
                prs['redemption_id'] in uniqueRedemptionId,
                'Unique Redemption Id is match with BillIds Actual: {} and Expected: {}'
                .format(prs['redemption_id'], uniqueRedemptionId))
            Assertion.constructAssertion(
                prs['redemptionType'] == 'REDEMPTION',
                'Redemption type is Matched Actual: {} and Expected: {}'.
                format(prs['redemptionType'], 'REDEMPTION'))
            redemptionId.append(prs['prs_id'])

        parsedResponse = LoyaltyHelper.redemptionReversalAndAssertion(
            self, [uniqueRedemptionId])
        LoyaltyHelper.redemptionReversalDBAssertion(
            self, redemptionId, parsedResponse['redemptionReversalId'],
            initialRedeemedPoints)
        LoyaltyHelper.redemptionReversalAndAssertion(
            self,
            listOfRedemptionId=[parsedResponse['redemptionReversalId']],
            expectException=[
                3804, 'redemption reversal of a reversal not allowed'
            ])
Esempio n. 9
0
 def setup_method(self, method):
     self.connObj = PEBHelper.getConnObj(newConnection=True)
     self.PERconnObj = LoyaltyHelper.getConnObj('pointsEngineRulesPort',
                                                newConnection=True)
     Logger.logMethodName(method.__name__)
Esempio n. 10
0
 def setup_class(self):
     Logger.logSuiteName(str(self).split('.')[-1])
     self.orgId = constant.config['orgId']
     self.programId = constant.config['programId']
     LoyaltyHelper.addTransaction()