Beispiel #1
0
 def test_wechat_createMessage_Recurring(self, description, messageInfo):
     Logger.log(
         'Actual ListId:{} and CampaignId:{} and used for Recurring listId:{} and campaignId:{}'
         .format(
             self.listId, self.campaignId,
             constant.config['message_recurring']['WECHAT']['listId'],
             constant.config['message_recurring']['WECHAT']['campaignId']))
     actualListIdGettingUsedInAllCases = self.listId
     actualCampaignIdGettingUsedInAllCases = self.campaignId
     actualVoucherIdGettingUsedInAllCases = self.voucherId
     try:
         self.listId = constant.config['message_recurring']['WECHAT'][
             'listId']
         self.campaignId = constant.config['message_recurring']['WECHAT'][
             'campaignId']
         self.voucherId = constant.config['message_recurring']['WECHAT'][
             'voucherId']
         response, payload = campaignMessage.createMessage(
             self, messageInfo=messageInfo)
         campaignMessage.assertCreateMessage(response, 200)
         campaignMessage.assertCreateMessageDbCalls(
             response['json']['entity']['messageId'], self.campaignId,
             payload)
         campaignMessage.updateDefaultMessageJsonWithMessageInfoValues(
             messageInfo, payload, response['json']['entity']['messageId'])
     except AssertionError, reason:
         Assertion.constructAssertion(False, reason)
Beispiel #2
0
    def test_wechat_createMessage_Invalid_Payload(self, description,
                                                  invalidpayload, statusCode,
                                                  errorCode, errorMessage):
        try:
            payload = {
                'message': construct.constructWechatMessageBody('plain')
            }
            payload.update({
                'channel':
                'WECHAT',
                'accountDetails':
                construct.constructAccountDetails()
            })
            if 'data' == invalidpayload.keys()[0]:
                payload.pop(invalidpayload[invalidpayload.keys()[0]])
            else:
                payload[invalidpayload.keys()[0]].pop(
                    invalidpayload[invalidpayload.keys()[0]])

            response, payload = campaignMessage.createMessage(
                self, payloadData=payload)
            campaignMessage.assertCreateMessage(response, statusCode,
                                                errorCode, errorMessage)
        except AssertionError, reason:
            Assertion.constructAssertion(False, reason)
Beispiel #3
0
 def test_wechat_createMessage_Points(self, description, messageInfo):
     response, payload = campaignMessage.createMessage(
         self, messageInfo=messageInfo)
     campaignMessage.assertCreateMessage(response, 200)
     campaignMessage.assertCreateMessageDbCalls(
         response['json']['entity']['messageId'], self.campaignId, payload)
     campaignMessage.updateDefaultMessageJsonWithMessageInfoValues(
         messageInfo, payload, response['json']['entity']['messageId'])
Beispiel #4
0
 def test_wechat_createMessage_Invalid_IncentivesType(
         self, description, payload, incentives, statusCode, errorCode,
         errorMessage):
     try:
         payload.update(
             {'templateId': self.templateIdDict[incentives.lower()]})
         response, payload = campaignMessage.createMessage(
             self, payloadData=payload)
         campaignMessage.assertCreateMessage(response, statusCode,
                                             errorCode, errorMessage)
     except AssertionError, reason:
         Assertion.constructAssertion(False, reason)
Beispiel #5
0
 def test_wechat_createMessage_Immediate_Plain_InvalidAccountDetails(
         self, description, payload, accountDetailsPassed, statusCode,
         errorCode, errorMessage):
     try:
         payload.update({accountDetailsPassed})
         payload.update({'templateId': self.templateIdDict['plain']})
         response, payload = campaignMessage.createMessage(
             self, payloadData=payload)
         campaignMessage.assertCreateMessage(response, statusCode,
                                             errorCode, errorMessage)
     except AssertionError, reason:
         Assertion.constructAssertion(False, reason)
Beispiel #6
0
 def test_wechat_createMessage_Immediate_Plain_WithInvalidListId(
         self, description, payload, listIdPassed, statusCode, errorCode,
         errorMessage):
     actualListIdGettingUsedThroughOut = self.listId
     try:
         self.listId = listIdPassed
         payload.update({'templateId': self.templateIdDict['plain']})
         response, payload = campaignMessage.createMessage(
             self, payloadData=payload)
         campaignMessage.assertCreateMessage(response, statusCode,
                                             errorCode, errorMessage)
     except AssertionError, reason:
         Assertion.constructAssertion(False, reason)
Beispiel #7
0
 def authorizeCampaign(self, messageInfo, usePreCreatedMessages=False):
     if usePreCreatedMessages:
         Logger.log(
             'Message Object Found Update so Getting Message Details To Make Authorize Request'
         )
         messageObjectDetailsForMessageInfo = authorize.getMessageDetailsFromObject(
             messageInfo)
         Logger.log('Recieved Message Object :',
                    messageObjectDetailsForMessageInfo)
         if messageObjectDetailsForMessageInfo == {}:
             Logger.log(
                 'As Message Object is Empty Creating a New Message to Authorize'
             )
             return authorize.authorizeCampaign(self, messageInfo, False)
         authorizeResponse = authorize.makeAuthorizeRequest(
             messageObjectDetailsForMessageInfo['campaignId'],
             messageObjectDetailsForMessageInfo['messageId'])
         messageObjectDetailsForMessageInfo.update(
             {'authorizeResponse': authorizeResponse})
         Logger.log(
             'Authorized Succesfully and constructed MessageDefault Info Object as :',
             messageObjectDetailsForMessageInfo)
         return messageObjectDetailsForMessageInfo
     else:
         Logger.log('Creating a New Message And Authorizing')
         messageResponse, messagePayload = campaignMessage.createMessage(
             self, messageInfo=messageInfo)
         Logger.log('Message Created for Authorize with Id :{}'.format(
             messageResponse['json']['entity']['messageId']))
         campaignMessage.assertCreateMessage(messageResponse, 200)
         Logger.log('Making Authorize Post Request')
         authorizeResponse = authorize.makeAuthorizeRequest(
             str(self.campaignId),
             str(messageResponse['json']['entity']['messageId']))
         messageObjectDetailsForMessageInfo = {
             'campaignId': self.campaignId,
             'listId': self.listId,
             'groupVersionResult': self.groupVersionResult,
             'bucketId': self.bucketId,
             'voucherId': self.voucherId,
             'strategy': self.strategy,
             'messageInfo': messageInfo,
             'payload': messagePayload,
             'messageId':
             str(messageResponse['json']['entity']['messageId']),
             'authorizeResponse': authorizeResponse
         }
         Logger.log(
             'Authorized Succesfully and constructed MessageDefault Info Object as :',
             messageObjectDetailsForMessageInfo)
         return messageObjectDetailsForMessageInfo
Beispiel #8
0
 def test_wechat_createMessage_using_templateIds(self, description, payload,
                                                 incentives):
     payload.update({'templateId': self.templateIdDict[incentives.lower()]})
     if incentives.lower() == 'coupons':
         payload.update({
             'incentive':
             construct.constructIncentivesForCreateMessage(
                 [incentives, self.voucherId])
         })
     if incentives.lower() != 'plain' and incentives.lower() != 'coupons':
         payload.update({
             'incentive':
             construct.constructIncentivesForCreateMessage([incentives])
         })
     response, payload = campaignMessage.createMessage(self, payload)
     campaignMessage.assertCreateMessage(response, 200)
     campaignMessage.assertCreateMessageDbCalls(
         response['json']['entity']['messageId'], self.campaignId, payload)