Exemplo n.º 1
0
 def PointsTransferEventData(updateDict={}):
     tmpDict = {
         'orgID': constant.config['orgId'],
         'transferredAtStoreUnitID': '',
         'eventTimeInMillis': Utils.getTime(milliSeconds=True),
         'numPointsToBeTransferred': 0,
         'fromCustomerDetails': '',
         'toCustomerDetails': '',
         'uniqueId': randValues.randomString(8),
         'serverReqId': randValues.randomString(15),
         'source': 'INSTORE'
     }
     tmpDict.update(updateDict)
     return emf.PointsTransferEventData(**tmpDict)
Exemplo n.º 2
0
 def PointsRedemptionEventData(paramDict={}):
     constant.config['uniqueId'] = randValues.randomString(8)
     tmpDict = {
         'orgID':
         constant.config['orgId'],
         'customerID':
         0,
         'numPointsToBeRedeemed':
         constant.config['defaultRedeemPts'],
         'redeemedAtStoreUnitId':
         constant.config['storeIds'][0],
         'redeemedOnBillNumber':
         '-1',
         'redeemedOnBillId':
         constant.config['billNumber'],
         'eventTimeInMillis':
         Utils.getTime(seconds=(randValues.randomInteger(2)),
                       milliSeconds=True),
         'userDetails':
         EMFObject.constructUserDetailsObject(0),
         'uniqueId':
         constant.config['uniqueId'],
         'serverReqId':
         constant.config['serverReqId'],
         'source':
         'INSTORE',
         'accountId':
         str(constant.config['programId']),
     }
     constant.config['defaultRedeemPts'] = paramDict[
         'numPointsToBeRedeemed'] if paramDict.has_key(
             'numPointsToBeRedeemed') else 100
     tmpDict.update(paramDict)
     return emf.PointsRedemptionEventData(**tmpDict)
Exemplo n.º 3
0
 def ReturnBillLineitemsEventData(paramDict={'returnLineItem': {}}):
     constant.config['uniqueId'] = randValues.randomString(8)
     tmpDict = {
         'orgID':
         constant.config['orgId'],
         'customerID':
         constant.config['usersInfo'][0]['userId'],
         'returnBillID':
         constant.config['billNumber'],
         'storeUnitID':
         constant.config['storeIds'][0],
         'eventTimeInMillis':
         Utils.getTime(milliSeconds=True),
         'uniqueId':
         constant.config['uniqueId'],
         'serverReqId':
         constant.config['serverReqId'],
         'returnLineItems':
         [EMFObject.ReturnLineItem(paramDict['returnLineItem'])],
         'userDetails':
         EMFObject.constructUserDetailsObject(0),
         'source':
         'INSTORE',
         'accountId':
         str(constant.config['programId']),
     }
     paramDict.pop('returnLineItem')
     tmpDict.update(paramDict)
     return emf.ReturnBillLineitemsEventData(**tmpDict)
Exemplo n.º 4
0
 def createAudience(channel, numberOfIdentifier, numberOfCustomTag=0,pointsEnabled=False):
     audience = dict()
     identifiers = list()
     for _ in range(numberOfIdentifier):
         if numberOfCustomTag == 0:
             identifiers.append(
                 {
                     "identifier": TestPreview.getIdentiferValue(channel,pointsEnabled),
                     'identifierType':'MOBILE' if channel == 'SMS' else channel
                 }
             )
         else:
             customTagFormation = list()
             for _ in range(numberOfCustomTag):
                 customTagFormation.append(randValues.randomString(10))
             identifiers.append(
                 {
                     "identifier": TestPreview.getIdentiferValue(channel,pointsEnabled),
                     'identifierType': 'MOBILE' if channel == 'SMS' else channel,
                     "customTag": customTagFormation
                 }
             )
     audience.update({
         'testAudiences': identifiers
     })
     return audience
Exemplo n.º 5
0
 def PointsRedemptionReversalEventData(paramDict={}):
     constant.config['uniqueId'] = randValues.randomString(8)
     tmpDict = {
         'orgID':
         constant.config['orgId'],
         'storeUnitID':
         constant.config['storeIds'][0],
         'eventTimeInMillis':
         Utils.getTime(seconds=randValues.randomInteger(2),
                       milliSeconds=True),
         'userDetails':
         EMFObject.constructUserDetailsObject(0),
         'uniqueRedemptionId':
         None,
         'uniqueId':
         constant.config['uniqueId'],
         'serverReqId':
         constant.config['serverReqId'],
         'source':
         'INSTORE',
         'accountId':
         str(constant.config['programId']),
         'notes':
         'Auto points reversal'
     }
     tmpDict.update(paramDict)
     return emf.PointsRedemptionReversalEventData(**tmpDict)
Exemplo n.º 6
0
 def smsTemplateFill(self, templateValue):
     try:
         self.implicitWaitOnReactPage()
         self.waitForElement(self.reminder_sms_blank_template_xpath,
                             locatorType='xpath')
         self.elementClick(self.reminder_sms_blank_template_xpath,
                           locatorType='xpath')
         self.waitForElement(self.inp_sms_editor_id)
         script = "document.getElementById('{}').value='{}'"
         self.executeScript(
             script.format(self.inp_sms_editor_id, templateValue))
         element = self.getElement(self.inp_sms_editor_id)
         hackKey = randValues.randomString(size=1)
         element.send_keys(hackKey)
         self.waitForElement(self.btn_sms_config_save_xpath,
                             locatorType='xpath')
         self.isClickable(
             self.getElement(self.btn_sms_config_save_xpath,
                             locatorType='xpath'))
         self.elementClick(self.btn_sms_config_save_xpath,
                           locatorType='xpath')
         if self.isVisible(
                 self.getElement(self.error_msg_xpath,
                                 locatorType='xpath')):
             self.waitUntillElementFound(self.error_msg_xpath)
             self.elementClick(self.btn_sms_config_save_xpath,
                               locatorType='xpath')
     except Exception, exp:
         raise Exception(
             'Edit SMS template coupon series Exception :{}'.format(exp))
Exemplo n.º 7
0
 def createFileForSkippedUsers(users):
     filePath = constant.autoTempFilePath + 'AutoList_{}_{}'.format(randValues.randomString(8),
                                                                    int(time.time() * 1000))
     file = FileHelper(filePath)
     for eachUser in users:
         file.appendToFile('{},{}'.format(eachUser,'Skip_{}'.format(eachUser)))
     Logger.log('FilePath Create for Skipped User :{}'.format(filePath))
     return filePath
Exemplo n.º 8
0
 def getDeepLinkValue():
     deepLinkValue = message_calls().getDeepLinkvalue(
         message_calls().getAccountIdFromMeta(
             constant.config['mobilepush']['account']),
         message_calls().getKeyOfDeepLink())
     randomKeyFromDeepLink = random.choice(list(deepLinkValue.keys()))
     linkFormed = deepLinkValue[randomKeyFromDeepLink]['link'] + '?'
     keysFrommLinked = deepLinkValue[randomKeyFromDeepLink]['keys']
     for eachKey in keysFrommLinked:
         linkFormed = linkFormed + '{}={}&'.format(
             eachKey, randValues.randomString(5))
     return linkFormed
Exemplo n.º 9
0
 def ReturnBillAmountEventData(paramDict={}):
     constant.config['uniqueId'] = randValues.randomString(8)
     tmpDict = {
         'orgID': constant.config['orgId'],
         'customerID': 0,
         'returnBillID': 0,
         'storeUnitID': constant.config['storeIds'][0],
         'eventTimeInMillis': Utils.getTime(milliSeconds=True),
         'uniqueId': constant.config['uniqueId'],
         'serverReqId': constant.config['serverReqId'],
         'returnAmount': 0,
         'userDetails': EMFObject.constructUserDetailsObject(0),
         'source': 'INSTORE',
         'accountId': str(constant.config['programId']),
     }
     tmpDict.update(paramDict)
     return emf.ReturnBillAmountEventData(**tmpDict)
Exemplo n.º 10
0
 def NewBillEvent(billDetails={}):
     tmpDict = {
         'orgID': constant.config['orgId'],
         'customerID': constant.config['usersInfo'][0]['userId'],
         'billID': constant.config['billNumber'],
         'storeUnitID': constant.config['storeIds'][0],
         'eventTimeInMillis': Utils.getTime(milliSeconds=True),
         'ignorePoints': False,
         'billAmount': 1000,
         'lifetimePurchase': 0,
         'prevLifetimePurchase': 0,
         'numberOfVisits': 1,
         'uniqueId': randValues.randomString(8),
         'serverReqId': constant.config['serverReqId'],
         'nonLoyalty': False,
         'userDetails': EMFObject.constructUserDetailsObject(0),
         'source': 'INSTORE',
         'accountId': str(constant.config['programId']),
     }
     tmpDict.update(billDetails)
     return emf.NewBillEvent(**tmpDict)
Exemplo n.º 11
0
 def templateName(self, templateName, channel='sms'):
     try:
         Logger.log('Giving Template Name as :{} for Channel : {}'.format(
             templateName, channel))
         if channel == 'email':
             self.waitForElement(self.tempalate_body_xpath,
                                 locatorType='xpath')
         self.waitForElement(self.input_templateName_id)
         if self.isElementPresent(self.input_templateName_id):
             script = "document.getElementById('{}').value='{}'"
             self.executeScript(
                 script.format(self.input_templateName_id, templateName))
             element = self.getElement(self.input_templateName_id)
             hackKey = randValues.randomString(size=1)
             element.send_keys(hackKey)
             return templateName + hackKey
         else:
             assert False, 'Channel :{} main content page not loaded'.format(
                 channel)
     except Exception, exp:
         raise Exception('TemplateName Exception :{}'.format(exp))
Exemplo n.º 12
0
class Test_EditCampaigns():
    def setup_method(self, method):
        Logger.logMethodName(method.__name__)

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo', [
            ('Edit start date', 'LIVE', 'ORG', {
                'startDate': Utils.getTime(hours=23, milliSeconds=True)
            }),
            ('Edit end date', 'LIVE', 'ORG', {
                'endDate': Utils.getTime(days=2, milliSeconds=True)
            }),
            ('Edit description', 'LIVE', 'ORG', {
                'description': randValues.randomString(10)
            }),
            ('Edit type', 'LIVE', 'ORG', {
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 10
                }
            }),
            ('Edit type', 'LIVE', 'ORG', {
                'testControl': {
                    'type': 'SKIP'
                }
            }),
            ('Edit start date', 'LIVE', 'SKIP', {
                'startDate': Utils.getTime(hours=23, milliSeconds=True)
            }),
            ('Edit end date', 'LIVE', 'SKIP', {
                'endDate': Utils.getTime(days=2, milliSeconds=True)
            }),
            ('Edit description', 'LIVE', 'SKIP', {
                'description': randValues.randomString(10)
            }),
            ('Edit testPercentage', 'LIVE', 'SKIP', {
                'testControl': {
                    'type': 'ORG'
                }
            }),
            ('Edit type', 'LIVE', 'SKIP', {
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 50
                }
            }),
            ('Edit type', 'LIVE', 'SKIP', {
                'testControl': {
                    'type': 'ORG'
                }
            }),
            ('Edit start date', 'LIVE', 'CUSTOM', {
                'startDate': Utils.getTime(hours=23, milliSeconds=True)
            }),
            ('Edit end date', 'LIVE', 'CUSTOM', {
                'endDate': Utils.getTime(days=2, milliSeconds=True)
            }),
            ('Edit description', 'LIVE', 'CUSTOM', {
                'description': randValues.randomString(10)
            }),
            ('Edit testPercentage', 'LIVE', 'CUSTOM', {
                'testControl': {
                    'type': 'SKIP'
                }
            }),
            ('Edit type', 'LIVE', 'CUSTOM', {
                'testControl': {
                    'type': 'SKIP'
                }
            }),
            ('Edit type', 'LIVE', 'CUSTOM', {
                'testControl': {
                    'type': 'ORG'
                }
            }),
        ])
    def test_irisV2_editCampaign_Sanity(self, description, campaignType,
                                        testControlType, editInfo):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        CreateCampaign.assertResponse(editInfo['RESPONSE'], 200)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 editInfo['PAYLOAD']).check()

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo',
        [('Edit name', 'LIVE', 'ORG', {
            'name':
            'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                       randValues.randomString(10))
        }),
         ('Edit name', 'LIVE', 'SKIP', {
             'name':
             'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                        randValues.randomString(10))
         }),
         ('Edit name', 'LIVE', 'CUSTOM', {
             'name':
             'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                        randValues.randomString(10))
         })])
    def test_irisV2_editCampaign_name(self, description, campaignType,
                                      testControlType, editInfo):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        CreateCampaign.assertResponse(
            editInfo['RESPONSE'],
            400,
            expectedErrorCode=1003,
            expectedErrorMessage=
            "Campaign Name Exception : Changing campaign name is not allowed.")

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,channel,messageInfo,editInfo',
        [('Edit end date', 'LIVE', 'ORG', 'MOBILE', {
            'scheduleType': {
                'type': 'IMMEDIATE'
            },
            'offerType': 'PLAIN',
            'messageStrategy': {
                'type': 'DEFAULT'
            },
            'channels': ['SMS', 'EMAIL'],
            'useTinyUrl': False,
            'encryptUrl': False,
            'skipRateLimit': True
        }, {
            'endDate': Utils.getTime(days=2, milliSeconds=True)
        }),
         ('Edit description', 'LIVE', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'PARTICULARDATE'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'description': randValues.randomString(10)
         }),
         ('Edit end date', 'UPCOMING', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'IMMEDIATE'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'endDate': Utils.getTime(days=2, milliSeconds=True)
         }),
         ('Edit description', 'UPCOMING', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'IMMEDIATE'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'description': randValues.randomString(10)
         }),
         ('Edit end date', 'UPCOMING', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'PARTICULARDATE'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'endDate': Utils.getTime(days=2, milliSeconds=True)
         }),
         ('Edit description', 'UPCOMING', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'RECURRING'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'description': randValues.randomString(10)
         })])
    def test_irisV2_editCampaign_AftereCreatingMessage(self, description,
                                                       campaignType,
                                                       testControlType,
                                                       channel, messageInfo,
                                                       editInfo):

        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        messageDetails = CreateMessage.create(campaignType,
                                              testControlType,
                                              'LOYALTY',
                                              channel,
                                              messageInfo,
                                              campaignId=campaignInfo['ID'],
                                              updateNode=True)
        campaignInfo = constant.config['node'][campaignType][testControlType][
            'CAMPAIGN']
        CreateMessage.assertResponse(messageDetails['RESPONSE'], 200)
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        CreateCampaign.assertResponse(editInfo['RESPONSE'], 200)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 editInfo['PAYLOAD']).check()

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,channel,messageInfo,editInfo',
        [('Edit name', 'UPCOMING', 'ORG', 'MOBILE', {
            'scheduleType': {
                'type': 'PARTICULARDATE'
            },
            'offerType': 'PLAIN',
            'messageStrategy': {
                'type': 'DEFAULT'
            },
            'channels': ['SMS', 'EMAIL'],
            'useTinyUrl': False,
            'encryptUrl': False,
            'skipRateLimit': True
        }, {
            'name':
            'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                       randValues.randomString(10))
        }),
         ('Edit name', 'UPCOMING', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'IMMEDIATE'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'name':
             'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                        randValues.randomString(10))
         }),
         ('Edit name', 'LIVE', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'RECURRING'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'name':
             'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                        randValues.randomString(10))
         })])
    def test_irisV2_editCampaign_Name_AftereCreatingMessage(
            self, description, campaignType, testControlType, channel,
            messageInfo, editInfo):

        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        messageDetails = CreateMessage.create(campaignType,
                                              testControlType,
                                              'LOYALTY',
                                              channel,
                                              messageInfo,
                                              campaignId=campaignInfo['ID'],
                                              updateNode=True)
        campaignInfo = constant.config['node'][campaignType][testControlType][
            'CAMPAIGN']
        CreateMessage.assertResponse(messageDetails['RESPONSE'], 200)
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        CreateCampaign.assertResponse(
            editInfo['RESPONSE'],
            400,
            expectedErrorCode=1003,
            expectedErrorMessage=
            "Campaign Name Exception : Changing campaign name is not allowed.")

    @pytest.mark.parametrize(
        'editInfo,campaignType,testControlType,channel,messageInfo,statusCode,errorCode,errorDescription',
        [
            ({
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 50
                }
            }, 'LIVE', 'ORG', 'MOBILE', {
                'scheduleType': {
                    'type': 'IMMEDIATE'
                },
                'offerType': 'PLAIN',
                'messageStrategy': {
                    'type': 'DEFAULT'
                },
                'channels': ['SMS', 'EMAIL'],
                'useTinyUrl': False,
                'encryptUrl': False,
                'skipRateLimit': True
            }, 400, 1013,
             'Campaign edit Exception : Test control ratio cannot be edited'),
            ({
                'testControl': {
                    'type': 'ORG',
                    'testPercentage': 50
                }
            }, 'LIVE', 'ORG', 'MOBILE', {
                'scheduleType': {
                    'type': 'IMMEDIATE'
                },
                'offerType': 'PLAIN',
                'messageStrategy': {
                    'type': 'DEFAULT'
                },
                'channels': ['SMS', 'EMAIL'],
                'useTinyUrl': False,
                'encryptUrl': False,
                'skipRateLimit': True
            }, 400, 102, 'Invalid request : test percentage must be null'),
            ({
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 10
                }
            }, 'LIVE', 'CUSTOM', 'MOBILE', {
                'scheduleType': {
                    'type': 'IMMEDIATE'
                },
                'offerType': 'PLAIN',
                'messageStrategy': {
                    'type': 'DEFAULT'
                },
                'channels': ['SMS', 'EMAIL'],
                'useTinyUrl': False,
                'encryptUrl': False,
                'skipRateLimit': True
            }, 400, 1013,
             'Campaign edit Exception : Test control ratio cannot be edited'),
        ])
    def test_irisv2_editCampaign_After_Creating_Message(
            self, editInfo, campaignType, testControlType, channel,
            messageInfo, statusCode, errorCode, errorDescription):
        messageDetails = CreateMessage.create(campaignType,
                                              testControlType,
                                              'LOYALTY',
                                              channel,
                                              messageInfo,
                                              updateNode=True)
        campaignInfo = constant.config['node'][campaignType][testControlType][
            'CAMPAIGN']
        CreateMessage.assertResponse(messageDetails['RESPONSE'], 200)
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        Assertion.constructAssertion(
            editInfo['RESPONSE']['statusCode'] == statusCode,
            'Actual Status Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['statusCode'], statusCode))
        Assertion.constructAssertion(
            editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode,
            'Actual Error Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode))
        Assertion.constructAssertion(
            errorDescription
            in editInfo['RESPONSE']['json']['errors'][0]['message'],
            'Expected Error message :{} and Actual : {}'.format(
                errorDescription,
                editInfo['RESPONSE']['json']['errors'][0]['message']))

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo', [
            ('Edit end date', 'UPCOMING', 'ORG', {
                'endDate': Utils.getTime(days=1, milliSeconds=True)
            }),
            ('Edit description', 'UPCOMING', 'ORG', {
                'description': randValues.randomString(10)
            }),
            ('Edit testPercentage', 'UPCOMING', 'ORG', {
                'testControl': {
                    'type': 'ORG'
                }
            }),
            ('Edit type', 'UPCOMING', 'ORG', {
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 50
                }
            }),
            ('Edit end date', 'UPCOMING', 'SKIP', {
                'endDate': Utils.getTime(days=1, milliSeconds=True)
            }),
            ('Edit description', 'UPCOMING', 'SKIP', {
                'description': randValues.randomString(10)
            }),
            ('Edit testPercentage', 'UPCOMING', 'SKIP', {
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 50
                }
            }),
            ('Edit type', 'UPCOMING', 'SKIP', {
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 50
                }
            }),
            ('Edit end date', 'UPCOMING', 'CUSTOM', {
                'endDate': Utils.getTime(days=1, milliSeconds=True)
            }),
            ('Edit description', 'UPCOMING', 'CUSTOM', {
                'description': randValues.randomString(10)
            }),
            ('Edit testPercentage', 'UPCOMING', 'CUSTOM', {
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 50
                }
            }),
            ('Edit type', 'UPCOMING', 'CUSTOM', {
                'testControl': {
                    'type': 'CUSTOM',
                    'testPercentage': 50
                }
            }),
            ('Edit start and end date', 'LAPSED', 'ORG', {
                'startDate': Utils.getTime(minutes=30, milliSeconds=True),
                'endDate': Utils.getTime(minutes=40, milliSeconds=True)
            }),
            ('Edit start and end date', 'LAPSED', 'SKIP', {
                'startDate': Utils.getTime(minutes=30, milliSeconds=True),
                'endDate': Utils.getTime(minutes=50, milliSeconds=True)
            }),
            ('Edit start and end date', 'LAPSED', 'CUSTOM', {
                'startDate': Utils.getTime(minutes=30, milliSeconds=True),
                'endDate': Utils.getTime(minutes=50, milliSeconds=True)
            }),
        ])
    def test_irisV2_editCampaign__OtheTypes(self, description, campaignType,
                                            testControlType, editInfo):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 campaignInfo['PAYLOAD']).check()
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        CreateCampaign.assertResponse(editInfo['RESPONSE'], 200)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 editInfo['PAYLOAD']).check()

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo',
        [('Edit start date', 'UPCOMING', 'ORG', {
            'startDate': Utils.getTime(minutes=5, milliSeconds=True)
        }),
         ('Edit start date', 'UPCOMING', 'SKIP', {
             'startDate': Utils.getTime(minutes=5, milliSeconds=True)
         }),
         ('Edit start date', 'UPCOMING', 'CUSTOM', {
             'startDate': Utils.getTime(minutes=5, milliSeconds=True)
         })])
    def test_irisV2_editCampaign_startDate(self, description, campaignType,
                                           testControlType, editInfo):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 campaignInfo['PAYLOAD']).check()
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        CreateCampaign.assertResponse(editInfo['RESPONSE'], 200)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 editInfo['PAYLOAD']).check()

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo',
        [('Edit name', 'UPCOMING', 'ORG', {
            'name':
            'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                       randValues.randomString(10))
        }),
         ('Edit name', 'UPCOMING', 'SKIP', {
             'name':
             'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                        randValues.randomString(10))
         }),
         ('Edit name', 'UPCOMING', 'CUSTOM', {
             'name':
             'IrisV2_Auto_{}_{}'.format(randValues.randomString(5),
                                        randValues.randomString(10))
         })])
    def test_irisV2_editCampaign_Name_OtheTypes(self, description,
                                                campaignType, testControlType,
                                                editInfo):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 campaignInfo['PAYLOAD']).check()
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        CreateCampaign.assertResponse(
            editInfo['RESPONSE'],
            400,
            expectedErrorCode=1003,
            expectedErrorMessage=
            "Campaign Name Exception : Changing campaign name is not allowed.")

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo,statusCode,errorCode,errorDescription',
        [('Edit description', 'LAPSED', 'ORG', {
            'description': randValues.randomString(10)
        }, 400, 1006,
          'Campaign Date Exception : Campaign is already expired on'),
         ('Edit type', 'LAPSED', 'ORG', {
             'testControl': {
                 'type': 'CUSTOM',
                 'testPercentage': 50
             }
         }, 400, 1006,
          'Campaign Date Exception : Campaign is already expired on'),
         ('Edit description', 'LAPSED', 'SKIP', {
             'description': randValues.randomString(10)
         }, 400, 1006,
          'Campaign Date Exception : Campaign is already expired on'),
         ('Edit testPercentage', 'LAPSED', 'SKIP', {
             'testControl': {
                 'type': 'CUSTOM',
                 'testPercentage': 50
             }
         }, 400, 1006,
          'Campaign Date Exception : Campaign is already expired on'),
         ('Edit type', 'LAPSED', 'SKIP', {
             'testControl': {
                 'type': 'CUSTOM',
                 'testPercentage': 50
             }
         }, 400, 1006,
          'Campaign Date Exception : Campaign is already expired on'),
         ('Edit description', 'LAPSED', 'CUSTOM', {
             'description': randValues.randomString(10)
         }, 400, 1006,
          'Campaign Date Exception : Campaign is already expired on'),
         ('Edit testPercentage', 'LAPSED', 'CUSTOM', {
             'testControl': {
                 'type': 'CUSTOM',
                 'testPercentage': 50
             }
         }, 400, 1006,
          'Campaign Date Exception : Campaign is already expired on'),
         ('Edit type', 'LAPSED', 'CUSTOM', {
             'testControl': {
                 'type': 'CUSTOM',
                 'testPercentage': 50
             }
         }, 400, 1006,
          'Campaign Date Exception : Campaign is already expired on')])
    def test_irisV2_editCampaign_LapsedOtheTypes(self, description,
                                                 campaignType, testControlType,
                                                 editInfo, statusCode,
                                                 errorCode, errorDescription):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 campaignInfo['PAYLOAD']).check()
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        Assertion.constructAssertion(
            editInfo['RESPONSE']['statusCode'] == statusCode,
            'Actual Status Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['statusCode'], statusCode))
        Assertion.constructAssertion(
            editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode,
            'Actual Error Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode))
        Assertion.constructAssertion(
            errorDescription
            in editInfo['RESPONSE']['json']['errors'][0]['message'],
            'Expected Error message :{} and Actual : {}'.format(
                errorDescription,
                editInfo['RESPONSE']['json']['errors'][0]['message']))

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo,statusCode,errorCode,errorDescription',
        [
            ('Edit start and end date with same date', 'LIVE', 'ORG', {
                'startDate': int(time.time() * 1000) + 20000,
                'endDate': int(time.time() * 1000) + 20000
            }, 400, 1006,
             'Campaign Date Exception : Campaign end date is less or equal than start date'
             ),
            ('Edit start date where start date is greater than end date',
             'LIVE', 'ORG', {
                 'startDate': Utils.getTime(days=2, milliSeconds=True)
             }, 400, 1006,
             'Campaign Date Exception : Campaign end date is less or equal than start date'
             ),
        ])
    def test_irisV2_editCampaign_NegativeCase_EditStartDate(
            self, description, campaignType, testControlType, editInfo,
            statusCode, errorCode, errorDescription):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 campaignInfo['PAYLOAD']).check()
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        Assertion.constructAssertion(
            editInfo['RESPONSE']['statusCode'] == statusCode,
            'Actual Status Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['statusCode'], statusCode))
        Assertion.constructAssertion(
            editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode,
            'Actual Error Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode))
        Assertion.constructAssertion(
            errorDescription == editInfo['RESPONSE']['json']['errors'][0]
            ['message'], 'Expected Error message :{} and Actual : {}'.format(
                errorDescription,
                editInfo['RESPONSE']['json']['errors'][0]['message']))

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo,statusCode,errorCode,errorDescription',
        [
            ('Edit start date where start date is less than current date and time',
             'LIVE', 'ORG', {
                 'startDate': Utils.getTime(days=-2, milliSeconds=True)
             }, 400, 1006,
             'Campaign Date Exception : Campaign start date is less than current date'
             ),
        ])
    def test_irisV2_editCampaign_NegativeCase_EditStartDate(
            self, description, campaignType, testControlType, editInfo,
            statusCode, errorCode, errorDescription):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 campaignInfo['PAYLOAD']).check()
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        Assertion.constructAssertion(
            editInfo['RESPONSE']['statusCode'] == statusCode,
            'Actual Status Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['statusCode'], statusCode))
        Assertion.constructAssertion(
            editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode,
            'Actual Error Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode))
        Assertion.constructAssertion(
            errorDescription
            in editInfo['RESPONSE']['json']['errors'][0]['message'],
            'Expected Error message :{} and Actual : {}'.format(
                errorDescription,
                editInfo['RESPONSE']['json']['errors'][0]['message']))

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo,statusCode,errorCode,errorDescription',
        [
            ('Edit end date where end date is less than current date and time',
             'LIVE', 'ORG', {
                 'endDate': Utils.getTime(days=-2, milliSeconds=True)
             }, 400, 1006,
             'Campaign Date Exception : Campaign is already expired on'),
        ])
    def test_irisV2_editCampaign_NegativeCase_EditEndDate(
            self, description, campaignType, testControlType, editInfo,
            statusCode, errorCode, errorDescription):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        CampaignCheckDBAssertion(campaignInfo['ID'],
                                 campaignInfo['PAYLOAD']).check()
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        Assertion.constructAssertion(
            statusCode == editInfo['RESPONSE']['statusCode'],
            'Error status actual {} and expected {}'.format(
                statusCode, editInfo['RESPONSE']['statusCode']))
        Assertion.constructAssertion(
            errorCode == editInfo['RESPONSE']['json']['errors'][0]['code'],
            'Error status actual {} and expected {}'.format(
                errorCode, editInfo['RESPONSE']['json']['errors'][0]['code']))
        Assertion.constructAssertion(
            errorDescription
            in editInfo['RESPONSE']['json']['errors'][0]['message'],
            'Error message expected {} and actual {}'.format(
                errorDescription,
                editInfo['RESPONSE']['json']['errors'][0]['message']))

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo,statusCode,errorCode,errorDescription',
        [('Invalid orgId', 'LIVE', 'ORG', {
            'endDate': Utils.getTime(days=2, milliSeconds=True)
        }, 500, 101, 'Generic error: HTTP 401 Unauthorized')])
    def test_irisV2_editCampaign_InvalidOrgId(self, description, campaignType,
                                              testControlType, editInfo,
                                              statusCode, errorCode,
                                              errorDescription):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        actualOrgId = constant.config['orgId']
        try:
            constant.config['orgId'] = 999999
            editInfo = CreateCampaign.edit(campaignInfo, editInfo)
            Assertion.constructAssertion(
                editInfo['RESPONSE']['statusCode'] == statusCode,
                'Actual Status Code :{} and Expected : {}'.format(
                    editInfo['RESPONSE']['statusCode'], statusCode))
            Assertion.constructAssertion(
                editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode,
                'Actual Error Code :{} and Expected : {}'.format(
                    editInfo['RESPONSE']['json']['errors'][0]['code'],
                    errorCode))
            Assertion.constructAssertion(
                errorDescription == editInfo['RESPONSE']['json']['errors'][0]
                ['message'],
                'Expected Error message :{} and Actual : {}'.format(
                    errorDescription,
                    editInfo['RESPONSE']['json']['errors'][0]['message']))
        finally:
            constant.config['orgId'] = actualOrgId

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo,statusCode,errorCode,errorDescription',
        [('Invalid orgId', 'LIVE', 'ORG', {
            'endDate': Utils.getTime(days=2, milliSeconds=True)
        }, 401, 999999, 'Invalid org id')])
    def test_irisV2_editCampaign_NegativeOrgId(self, description, campaignType,
                                               testControlType, editInfo,
                                               statusCode, errorCode,
                                               errorDescription):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        actualOrgId = constant.config['orgId']
        try:
            constant.config['orgId'] = -99999
            editInfo = CreateCampaign.edit(campaignInfo, editInfo)
            Assertion.constructAssertion(
                editInfo['RESPONSE']['statusCode'] == statusCode,
                'Actual Status Code :{} and Expected : {}'.format(
                    editInfo['RESPONSE']['statusCode'], statusCode))
            Assertion.constructAssertion(
                editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode,
                'Actual Error Code :{} and Expected : {}'.format(
                    editInfo['RESPONSE']['json']['errors'][0]['code'],
                    errorCode))
            Assertion.constructAssertion(
                errorDescription == editInfo['RESPONSE']['json']['errors'][0]
                ['message'],
                'Expected Error message :{} and Actual : {}'.format(
                    errorDescription,
                    editInfo['RESPONSE']['json']['errors'][0]['message']))
        finally:
            constant.config['orgId'] = actualOrgId

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,editInfo,statusCode,errorCode,errorDescription',
        [('Wrong auth', 'LIVE', 'ORG', {
            'endDate': Utils.getTime(days=2, milliSeconds=True)
        }, 401, 999999, 'Unauthorized')])
    def test_irisV2_editCampaign_WrongAuth(self, description, campaignType,
                                           testControlType, editInfo,
                                           statusCode, errorCode,
                                           errorDescription):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        previousUserName = None
        try:
            previousUserName = IrisHelper.updateUserName('WrongName')
            editInfo = CreateCampaign.edit(campaignInfo, editInfo)
            Assertion.constructAssertion(
                editInfo['RESPONSE']['statusCode'] == statusCode,
                'Actual Status Code :{} and Expected : {}'.format(
                    editInfo['RESPONSE']['statusCode'], statusCode))
        finally:
            if previousUserName is not None:
                IrisHelper.updateUserName(previousUserName)

    @pytest.mark.parametrize(
        'description,campaignType,testControlType,channel,messageInfo,editInfo,statusCode,errorCode,errorDescription',
        [('Edit start date', 'LIVE', 'ORG', 'MOBILE', {
            'scheduleType': {
                'type': 'IMMEDIATE'
            },
            'offerType': 'PLAIN',
            'messageStrategy': {
                'type': 'DEFAULT'
            },
            'channels': ['SMS', 'EMAIL'],
            'useTinyUrl': False,
            'encryptUrl': False,
            'skipRateLimit': True
        }, {
            'startDate': Utils.getTime(hours=23, milliSeconds=True)
        }, 400, 1006,
          'Campaign Date Exception : Campaign start date cannot be modified '),
         ('Edit start date', 'UPCOMING', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'PARTICULARDATE'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'startDate': Utils.getTime(hours=23, milliSeconds=True)
         }, 400, 1006,
          'Campaign Date Exception : Campaign start date cannot be modified '),
         ('Edit start date', 'LIVE', 'ORG', 'MOBILE', {
             'scheduleType': {
                 'type': 'RECURRING'
             },
             'offerType': 'PLAIN',
             'messageStrategy': {
                 'type': 'DEFAULT'
             },
             'channels': ['SMS', 'EMAIL'],
             'useTinyUrl': False,
             'encryptUrl': False,
             'skipRateLimit': True
         }, {
             'startDate': Utils.getTime(hours=23, milliSeconds=True)
         }, 400, 1006,
          'Campaign Date Exception : Campaign start date cannot be modified ')]
    )
    def test_irisV2_editCampaignStartDate_AftereCreatingMessage(
            self, description, campaignType, testControlType, channel,
            messageInfo, editInfo, statusCode, errorCode, errorDescription):
        campaignInfo = CreateCampaign.create(campaignType,
                                             testControlType,
                                             updateNode=True)
        messageDetails = CreateMessage.create(campaignType,
                                              testControlType,
                                              'LOYALTY',
                                              channel,
                                              messageInfo,
                                              campaignId=campaignInfo['ID'],
                                              updateNode=True)
        campaignInfo = constant.config['node'][campaignType][testControlType][
            'CAMPAIGN']
        CreateMessage.assertResponse(messageDetails['RESPONSE'], 200)
        editInfo = CreateCampaign.edit(campaignInfo, editInfo)
        Assertion.constructAssertion(
            editInfo['RESPONSE']['statusCode'] == statusCode,
            'Actual Status Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['statusCode'], statusCode))
        Assertion.constructAssertion(
            editInfo['RESPONSE']['json']['errors'][0]['code'] == errorCode,
            'Actual Error Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode))
        Assertion.constructAssertion(
            editInfo['RESPONSE']['json']['errors'][0]['message']
            in errorDescription,
            'Actual Error Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['json']['errors'][0]['message'],
                errorDescription))

    @pytest.mark.parametrize(
        'campaignTypeFirst,testControlTypeFirst,campaignTypeSecond,testControlTypeSecond,statusCode,errorCode',
        [('LIVE', 'ORG', 'LAPSED', 'ORG', 400, [1003, 1006]),
         ('LAPSED', 'ORG', 'LAPSED', 'ORG', 400, [1003, 1006])])
    def test_irisV2_editCampaign_NegativeCase_Lapsed(self, campaignTypeFirst,
                                                     testControlTypeFirst,
                                                     campaignTypeSecond,
                                                     testControlTypeSecond,
                                                     statusCode, errorCode):
        campaignInfo1 = CreateCampaign.create(campaignTypeFirst,
                                              testControlTypeFirst,
                                              updateNode=True,
                                              lockNode=True)
        campaignInfo = CreateCampaign.create(campaignTypeSecond,
                                             testControlTypeSecond,
                                             updateNode=True,
                                             lockNode=True)
        editInfo = CreateCampaign.edit(campaignInfo,
                                       {'name': campaignInfo1['NAME']})
        Assertion.constructAssertion(
            editInfo['RESPONSE']['statusCode'] == statusCode,
            'Actual Status Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['statusCode'], statusCode))
        Assertion.constructAssertion(
            editInfo['RESPONSE']['json']['errors'][0]['code'] in errorCode,
            'Actual Error Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['json']['errors'][0]['code'], errorCode))
        Assertion.constructAssertion(
            'Campaign Date Exception : Campaign is already expired on'
            in editInfo['RESPONSE']['json']['errors'][0]['message']
            or "Campaign Name Exception : Campaign Name already exists"
            in editInfo['RESPONSE']['json']['errors'][0]['message'] or
            "Campaign Name Exception : Changing campaign name is not allowed."
            in editInfo['RESPONSE']['json']['errors'][0]['message'],
            'Actual Error Code :{} and Expected : {}'.format(
                editInfo['RESPONSE']['json']['errors'][0]['message'],
                editInfo['RESPONSE']['json']['errors'][0]['message']))
Exemplo n.º 13
0
 def generateCouponCode(isAlphaNumeric=True, size=9):
     if isAlphaNumeric:
         return randValues.randomString(size).upper()
     else:
         return str(randValues.randomInteger(size))
Exemplo n.º 14
0
class Test_PointsReversal():
    def setup_class(self):
        Logger.logSuiteName(str(self).split('.')[-1])
        self.orgId = constant.config['orgId']
        self.programId = constant.config['programId']
        LoyaltyHelper.addTransaction()
        # self.emfObject = EMFObject()

    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__)

    @pytest.mark.parametrize('description, requestParams, errorDetails', [
        ('Points Reversal with org which not Enabled for reversal', {
            'orgID': 0,
            'uniqueRedemptionId': randValues.randomString(8)
        }, [4101, 'points redemption reversal is disabled for this org']),
        ('Points Reversal with invalid uniqueRedemptionId', {
            'uniqueRedemptionId': randValues.randomString(8)
        }, [3803, 'prs record not found for the unique redemption id']),
        ('Points Reversal with negative pointsToBeReversed', {
            'pointsToBeReversed': -10
        }, [4102, 'points redemption reversal not allowed for invalid points'
            ]),
        ('Points Reversal with More than redeemed pointsToBeReversed', {
            'pointsToBeReversed': 1000
        }, [
            3801,
            'points to be reversed should not be greater than total points redeemed against the redemption summary id'
        ]),
    ])
    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]))
Exemplo n.º 15
0
    def createCoupons(payloadData={},
                      campaignId=None,
                      campaignType=[],
                      process='update',
                      key=True,
                      timeout=5.0):
        updateDefault = False
        if campaignId == None:
            if len(campaignType) == 0:
                response, payload = campaigns.createCampaign({
                    'name':
                    'IRIS_COUPON' + randValues.randomString(5) +
                    str(int(time.time() * 100000)),
                    'goalId':
                    constant.irisGenericValues['goalId'],
                    'objectiveId':
                    constant.irisGenericValues['objectiveId']
                })
            else:
                response, payload = campaigns.createCampaign(
                    {}, campaignTypeParams=[campaignType[0], campaignType[1]])
                updateDefault = True

            if response['statusCode'] == 200:
                campaignId = response['json']['entity']['campaignId']
            else:
                Assertion.constructAssertion(
                    False,
                    'Error : While Creating Campaign , Status Code : {}'.
                    format(response['statusCode']))

        Logger.log('CampaignId getting used to create list :', campaignId)

        if key:
            createCouponConstructedEndPoint = construct.constructUrl(
                'createcoupon')
            payload = construct.constructBody(payloadData, process,
                                              'createcoupon')
            payload.update({'campaignId': campaignId})
            try:
                response = Utils.makeRequest(
                    url=createCouponConstructedEndPoint,
                    data=payload,
                    auth=construct.constructAuthenticate(),
                    headers=construct.constructHeaders(),
                    method='POST')
                if updateDefault:
                    constant.campaignDefaultValues[campaignType[0]][
                        campaignType[1]]['Coupon'].update({
                            'response': response,
                            'payload': payload
                        })
            except:
                return {}, payload, campaignId

            return construct.constructResponse(response), payload, campaignId
        else:
            couponResponse = constant.campaignDefaultValues[campaignType[0]][
                campaignType[1]]['Coupon']['response']
            couponPayload = constant.campaignDefaultValues[campaignType[0]][
                campaignType[1]]['Coupon']['payload']

            if len(couponResponse) == 0 or len(couponPayload) == 0:
                coupons.createCoupons(payloadData,
                                      campaignId,
                                      campaignType,
                                      process,
                                      key=True)
            else:
                return couponResponse, couponPayload, campaignId