Beispiel #1
0
 def assertCreateCampaignDBCall(campaignId, payload):
     Logger.log('Asserting on DB for Campaign Id as :', campaignId,
                ' with payload :', payload)
     campaigns.assertCampaignBase(
         dbCallsCampaign.getCampaignBaseFromCampaignId(campaignId), payload)
     campaigns.assertTagResult(
         dbCallsCampaign.getCampaignTagsFromCampaignId(campaignId), payload)
     campaigns.assertObjectiveResult(
         dbCallsCampaign.getObjectiveMappingIdFromCampaignId(campaignId),
         payload)
Beispiel #2
0
 def test_createCoupon_Timeout(self, description, payloadData):
     response, payload, campaignId = coupons.createCoupons(
         payloadData=payloadData, timeout=0.0001)
     time.sleep(5)
     campaignsInfo = dbCallsCampaign.getCampaignBaseFromCampaignId(
         campaignId)
     Assertion.constructAssertion(
         int(campaignsInfo['voucher_series_id']) != -1,
         'Checking Even After Timeout Voucher Series is Created with VoucherSeriesId :{}'
         .format(campaignsInfo['voucher_series_id']))
Beispiel #3
0
    def assertCreateCouponDbCalls(response, payload, campaignId):
        voucherSeriesInfo = dbCallsCoupons.getVoucherSeriesInfoBasedOnId(
            response['json']['entity']['voucherSeriesId'])
        Assertion.constructAssertion(
            int(voucherSeriesInfo['campaign_id']) == int(campaignId),
            'Matching Campaign id in Voucher Series')
        Assertion.constructAssertion(
            voucherSeriesInfo['series_type'] == 'CAMPAIGN',
            'Matching Series Type in DB is set as Campaign')
        Assertion.constructAssertion(
            voucherSeriesInfo['description'] == payload['couponSeriesTag'],
            'Matching Coupon Name in DB :{} and passed in payalod :{}'.format(
                voucherSeriesInfo['description'], payload['couponSeriesTag']))
        Assertion.constructAssertion(
            voucherSeriesInfo['discount_on'] == payload['discountOn'],
            'Matching discountOn in Db :{} and in payalod :{}'.format(
                voucherSeriesInfo['discount_on'], payload['discountOn']))
        Assertion.constructAssertion(
            voucherSeriesInfo['discount_type'] == payload['discountType'],
            'Matching Discount Type in DB :{} and passed in Payload :{}'.
            format(voucherSeriesInfo['discount_type'],
                   payload['discountType']))
        Assertion.constructAssertion(
            voucherSeriesInfo['discount_value'] == payload['discountValue'],
            'Matching Discount Value in DB :{} and passed :{}'.format(
                voucherSeriesInfo['discount_value'], payload['discountValue']))
        if 'redeemableTillIds' in payload:
            Assertion.constructAssertion(
                voucherSeriesInfo['redeem_store_type'] == 'redeemable_stores',
                'MAtching redeem store type as redeemable_stores')

        if payload['couponLimit']['type'] == 'UNLIMITED':
            Assertion.constructAssertion(
                voucherSeriesInfo['max_create'] == -1,
                'Matching max_create value in Db as -1 as Coupon Limit is Unlimited'
            )
        else:
            Assertion.constructAssertion(
                voucherSeriesInfo['max_create'] == payload['couponLimit']
                ['limit'],
                'Matching max_create value in Db :{} and passed in payload as limit :{}'
                .format(voucherSeriesInfo['max_create'],
                        payload['couponLimit']['limit']))

        CampaignsInfo = dbCallsCampaign.getCampaignBaseFromCampaignId(
            campaignId)
        Assertion.constructAssertion(
            int(CampaignsInfo['voucher_series_id']) == int(
                response['json']['entity']['voucherSeriesId']),
            'Matching Voucher Series ID Set in Campaign is Correct')
        Assertion.constructAssertion(
            CampaignsInfo['end_date'].split(
                ' ')[0] == voucherSeriesInfo['valid_till_date'],
            'Matching Voucher Series ID Set in Campaign is Correct')
Beispiel #4
0
 def getTestPercentageOfCampaign(self):
     # self.testPercentage should come from ORG Config ,and this class should be independent of campaignID
     try:
         campaignBaseResult = dbCallsCampaign.getCampaignBaseFromCampaignId(
             self.campaignId)
         if campaignBaseResult['test_percentage'] is not None:
             self.testPercentage = int(
                 campaignBaseResult['test_percentage'])
         else:
             self.testPercentage = 90
     except:
         self.testPercentage = 90
Beispiel #5
0
 def assertUpdateCampaignDBCall(payload, campaignId):
     Logger.log(
         'DB Assertion for UpdateCampaign with payload :{}'.format(payload))
     campaignBaseResult = dbCallsCampaign.getCampaignBaseFromCampaignId(
         campaignId)
     Logger.log('campaignBaseResult :{}'.format(campaignBaseResult))
     campaigns.assertCampaignBase(campaignBaseResult, payload)
     if 'tags' in payload:
         campaigns.assertTagResult(
             dbCallsCampaign.getCampaignTagsFromCampaignId(campaignId),
             payload)
     campaigns.assertObjectiveResult(
         dbCallsCampaign.getObjectiveMappingIdFromCampaignId(campaignId),
         payload)
Beispiel #6
0
 def assertGetCampaignDBCall(response, campaignId):
     Assertion.constructAssertion(
         response['json']['entity']['id'] == campaignId,
         'Matching Id of Response : {} and passed campaignId : {} are same'.
         format(response['json']['entity']['id'], campaignId))
     campaignBaseResult = dbCallsCampaign.getCampaignBaseFromCampaignId(
         campaignId)
     campaigns.assertCampaignBase(campaignBaseResult,
                                  response['json']['entity'])
     campaigns.assertTestControlRatiobasedOnTestType(
         campaignBaseResult['test_control'],
         campaignBaseResult.get('test_percentage'))
     if 'tags' in response['json']['entity']:
         campaigns.assertTagResult(
             dbCallsCampaign.getCampaignTagsFromCampaignId(campaignId),
             response['json']['entity'])
     campaigns.assertObjectiveResult(
         dbCallsCampaign.getObjectiveMappingIdFromCampaignId(campaignId),
         response['json']['entity'])
Beispiel #7
0
    def assertTestControlUsers(response, payload, campaignId, userType):
        data = ''
        listOfUserData = payload['data']
        for eachuser in listOfUserData:
            data = data + "'" + eachuser.split(',')[2] + "',"

        campaignBaseResult = dbCallsCampaign.getCampaignBaseFromCampaignId(
            campaignId)

        if campaignBaseResult['test_control'].lower() == 'skip':
            Logger.log(
                'Asserting Test Control Based on secretA with data :{} of which Test users are :{} and control users are :{} for test Control Type :{}'
                .format(data, len(data[:len(data) - 1].split(',')), 0, 'SKIP'))
            Assertion.constructAssertion(
                response['json']['entity']['test'] == len(data[:len(data) -
                                                               1].split(',')),
                'Matching Test user in SKIP type is equal to size of user Data'
            )
            Assertion.constructAssertion(
                response['json']['entity']['control'] == 0,
                'Matching Control User in case of Skip should always be 0')
        elif campaignBaseResult['test_control'].lower() == 'custom':
            data = data[:len(data) - 1]
            numberOfTestUsers = int(
                round(
                    len(data.split(',')) *
                    int(campaignBaseResult['test_percentage']) * 0.01))
            numberOfControlUsers = len(data.split(',')) - numberOfTestUsers
            Logger.log(
                'Based on Calculation as Per Test percentage, number of test Users :{} and control: {}'
                .format(numberOfTestUsers, numberOfControlUsers))
            Assertion.constructAssertion(
                response['json']['entity']['test'] == numberOfTestUsers,
                'Matching Test user based on Calculation for CUSTOM Type actual :{} and expected :{}'
                .format(response['json']['entity']['test'], numberOfTestUsers))
            Assertion.constructAssertion(
                response['json']['entity']['control'] == numberOfControlUsers,
                'Matching Control user based on Calculation for CUSTOM Type actual :{} and expected :{}'
                .format(response['json']['entity']['control'],
                        numberOfControlUsers))
        elif campaignBaseResult['test_control'].lower() == 'org':
            result = dbCallsList.getTestControlBasedOnSecreta(
                userType, data[:len(data) - 1], 'iris')
            Logger.log(
                'Asserting Test Control Based on secretA with data :{} of which Test users are :{} and control users are :{} for test Control Type :{}'
                .format(data, result['test'], result['control'], 'ORG'))
            Assertion.constructAssertion(
                response['json']['entity']['test'] == len(result['test']),
                'Matching Test Users as per SecretA Value, actual :{} and expected  :{}'
                .format(response['json']['entity']['test'],
                        len(result['test'])))
            Assertion.constructAssertion(
                response['json']['entity']['control'] == len(
                    result['control']),
                'Matching Control Users as per SecretA Value, actual :{} and expected :{}'
                .format(response['json']['entity']['control'],
                        len(result['control'])))
        else:
            Logger.log('Not Able to Assert as TestType is :{}'.format(
                campaignBaseResult['test_control']))

        return campaignBaseResult['test_control']