Esempio n. 1
0
 def test_getCampaignAll_loopOnLimit(self, description, startDate, endDate, startFrom, numberOfBreaksToCheck):
     getCampaignResponseToGetLengthOfCampaigns = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', '')])
     numberOfRecords = len(getCampaignResponseToGetLengthOfCampaigns.get('json').get('data'))
     List = []
     for numberOfLoops in range(numberOfRecords / numberOfBreaksToCheck):
         getCampaignResponse = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', startFrom + numberOfBreaksToCheck)])
         campaigns.assertGetCampaignWithPassedLimit(getCampaignResponseToGetLengthOfCampaigns.get('json').get('data'), getCampaignResponse.get('json').get('data'), startFrom, startFrom + numberOfBreaksToCheck)
         startFrom += numberOfBreaksToCheck
Esempio n. 2
0
 def test_getCampaignAll_DateRangeAndFormat_positiveScenrios(self, description, startDate, endDate, statusCode):
     getCampaignResponse = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate)])
     Assertion.constructAssertion(getCampaignResponse['statusCode'] == int(statusCode), 'Matching statusCode actual :{},expected :{}'.format(getCampaignResponse['statusCode'], statusCode))
     Assertion.constructAssertion(len(getCampaignResponse['json']['data']) >= 0, 'CampaignCreated betweenRange is :{} and campaignRecieved in getCall :{}'.format(0, len(getCampaignResponse['json']['data'])))
     for eachRecord in getCampaignResponse['json']['data']:
         if startDate != '':
             Assertion.constructAssertion(eachRecord['startDate'] >= startDate, 'Matching endDate of Response is within given range')
         if endDate != '':
             Assertion.constructAssertion(eachRecord['endDate'] <= endDate, 'Matching endDate of Response is within given range')
Esempio n. 3
0
 def test_getCampaignAll_Sanity(self, description, numberOfCamaigns, startDate, endDate, startFrom):
     getCampaignResponseCheck = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', numberOfCamaigns)])
     campaignsRequiredToCreate = numberOfCamaigns - len(getCampaignResponseCheck.get('json').get('data'))
         
     numberOfCampaignsGotCreated = 0
     if campaignsRequiredToCreate > 0:
         for number in range(campaignsRequiredToCreate):
             response, payload = campaigns.createCampaign({'name':'IRIS_' + str(int(time.time())), 'goalId':str(constant.irisGenericValues['goalId']), 'objectiveId': constant.irisGenericValues['objectiveId'], 'startDate':startDate, 'endDate':endDate})
             campaigns.assertCreateCampaign(response, 200)
             if response.get('statusCode') == 200:
                 numberOfCampaignsGotCreated = numberOfCampaignsGotCreated + 1
     
     Logger.log('Number of Campaigns required :{} and CampaignsAlready Present in Range :{} and created Camapign in this job :{}'.format(numberOfCamaigns, len(getCampaignResponseCheck.get('json').get('data')), numberOfCampaignsGotCreated))
     
     getCampaignResponse = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', numberOfCamaigns)])
     campaigns.assertGetCampaignAll(getCampaignResponse, numberOfCamaigns, 200)
     listOfCampaignsWithCampaignIdAndResponse = construct.constructGetCampaignAllToGetCampaignIdResponse(getCampaignResponse)
     for eachlistOfCampaignsWithCampaignIdAndResponse in listOfCampaignsWithCampaignIdAndResponse:
         campaigns.assertGetCampaignDBCall(eachlistOfCampaignsWithCampaignIdAndResponse[1], eachlistOfCampaignsWithCampaignIdAndResponse[0])
Esempio n. 4
0
 def test_getCampaignOfDifferentCampaignTypes(self, campaignType):
     response, payload = campaigns.createCampaign(
         campaignTypeParams=campaignType)
     campaigns.assertCreateCampaign(response, 200)
     getCampaignResponse = campaigns.getCampaignById(
         campaignId=response.get('json').get('entity').get('campaignId'))
     campaigns.assertGetCampaign(getCampaignResponse, 200)
     campaigns.assertGetCampaignDBCall(
         getCampaignResponse,
         response.get('json').get('entity').get('campaignId'))
Esempio n. 5
0
 def test_getCampaignAll_updateUpcomingCampaign_outOfGivenRange(self, description, numberOfCamaigns, startDate, endDate, startFrom):
     getCampaignResponseCheck = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', numberOfCamaigns)])
     campaignsRequiredToCreate = numberOfCamaigns - len(getCampaignResponseCheck.get('json').get('data'))
 
     numberOfCampaignsGotCreated = 0
     if campaignsRequiredToCreate > 0:
         for number in range(campaignsRequiredToCreate):
             response, payload = campaigns.createCampaign({'name':'IRIS_' + str(int(time.time())), 'goalId':str(constant.irisGenericValues['goalId']), 'objectiveId': constant.irisGenericValues['objectiveId'], 'startDate':startDate, 'endDate':endDate})
             campaigns.assertCreateCampaign(response, 200)
             if response.get('statusCode') == 200:
                 numberOfCampaignsGotCreated = numberOfCampaignsGotCreated + 1
     
     Logger.log('Number of Campaigns required :{} and CampaignsAlready Present in Range :{} and created Camapign in this job :{}'.format(numberOfCamaigns, len(getCampaignResponseCheck.get('json').get('data')), numberOfCampaignsGotCreated))
     
     getCampaignResponse = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', numberOfCamaigns)])
     campaigns.assertGetCampaignAll(getCampaignResponse, numberOfCamaigns, 200)
     listOfCampaignsWithCampaignIdAndResponse = construct.constructGetCampaignAllToGetCampaignIdResponse(getCampaignResponse)
     campaignIdToUpdate = listOfCampaignsWithCampaignIdAndResponse[0][0]
     Logger.log('Updating Campaign with id :', campaignIdToUpdate)
     campaigns.updateCampaign({'startDate':int(time.time() * 1000 + 24 * 60 * 60 * 1000 * 469), 'endDate':int(time.time() * 1000 + 24 * 60 * 60 * 1000 * 470)}, campaignId=campaignIdToUpdate)
     getCampaignResponseAfterUpdatingSingleCampaignInThatRange = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate), ('startFrom', startFrom), ('numberOfRecords', numberOfCamaigns)])
     for each in getCampaignResponseAfterUpdatingSingleCampaignInThatRange.get('json').get('data'):
         if int(each.get('id')) == int(campaignIdToUpdate):
             Assertion.constructAssertion(False, 'Updated Campaign Found in Get All Call')
Esempio n. 6
0
 def test_getCampaign_PassingWorngOrg(self):
     response, payload = campaigns.createCampaign({
         'name':
         'IRIS_' + str(int(time.time())),
         'goalId':
         str(dbCallsCampaign.getValidGoalId()),
         'objectiveId':
         dbCallsCampaign.getValidObjectiveId()
     })
     campaigns.assertCreateCampaign(response, 200)
     previousOrgId = construct.updateOrgId(0)
     try:
         getCampaignResponse = campaigns.getCampaignById(
             campaignId=response.get('json').get('entity').get(
                 'campaignId'))
         campaigns.assertGetCampaign(
             getCampaignResponse, 400, 1007,
             'Campaign Id Exception : No Campaign Exists For This Campaign Id'
         )
     except AssertionError, exp:
         Logger.log('Assertion Failed as :', exp)
Esempio n. 7
0
 def test_getCampaign_updateCampaign(self, description, payloadToUpload,
                                     campaignType):
     updateResponse, createResponse, updatePayload, createPayload = campaigns.updateCampaign(
         payloadToUpload, campaignType=campaignType)
     Logger.log(
         'updateResponse :{} , createResponse :{} , updatePayload :{} ,createPayload :{}'
         .format(updateResponse, createResponse, updatePayload,
                 createPayload))
     campaigns.assertUpdateCampaign(updateResponse, createResponse, 200)
     if updateResponse.get('statusCode') == 200:
         createPayload.update(updatePayload)
         getCampaignResponse = campaigns.getCampaignById(
             campaignId=updateResponse.get('json').get('entity').get(
                 'campaignId'))
         campaigns.assertGetCampaign(getCampaignResponse, 200)
         campaigns.assertGetCampaignDBCall(
             getCampaignResponse,
             updateResponse.get('json').get('entity').get('campaignId'))
     else:
         Logger.log(
             'Status Code for updateCampaign is not 200 so no call to Get Campaign for this case'
         )
Esempio n. 8
0
 def test_getCampaignAll_DateRangeAndFormat_NegativeScenarios(self, description, startDate, endDate, statusCode, errorCode, errorMessage):
     getCampaignResponse = campaigns.getCampaignById(queryParam=[('startDate', startDate), ('endDate', endDate)])
     campaigns.assertGetCampaignAll(getCampaignResponse, 0, statusCode, errorCode, errorMessage)
Esempio n. 9
0
 def test_getCampaign_NegativeCases(self, description, campaignId,
                                    statusCode, errorCode, errorMessage):
     getCampaignResponse = campaigns.getCampaignById(campaignId=campaignId)
     campaigns.assertGetCampaign(getCampaignResponse, statusCode, errorCode,
                                 errorMessage)