def test_LUCI_GCC_001(self, description,ownerValues): configRequest = LuciObject.getCouponConfigRequest({'ownedBy' : ownerValues[0]}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) Assertion.constructAssertion(couponConfigList != None, 'Retrieved couponConfig from GetCouponConfig by OwnedBy') configRequest = LuciObject.getCouponConfigRequest({'ownerId': ownerValues[1]}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) Assertion.constructAssertion(couponConfigList != None, 'Retrieved couponConfig from GetCouponConfig by OwnedId')
def test_LUCI_GCC_005(self, description,ownerValues): configRequest = LuciObject.getCouponConfigRequest({'ownedBy' : ownerValues[0], 'includeExpired' : True, 'limit' : 5}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) Assertion.constructAssertion(len(couponConfigList) == 5, 'GetCouponConfig Limit {} and couponconfig got {}'.format(5, len(couponConfigList))) Assertion.constructAssertion(couponConfigList != None, 'Retrieved couponConfig from GetCouponConfig by OwnedBy') configRequest = LuciObject.getCouponConfigRequest({'ownerId': ownerValues[1]}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) Assertion.constructAssertion(couponConfigList != None, 'Retrieved couponConfig from GetCouponConfig by OwnedId')
def getCouponConfigAndAssertion(self, couponSeriesId, no_issued=0, no_redeemed=0, updateConfigRequest={}): tmpDict = {'couponSeriesId': couponSeriesId} tmpDict.update(updateConfigRequest) configRequest = LuciObject.getCouponConfigRequest(tmpDict) couponConfigList = self.connObj.getCouponConfiguration(configRequest) couponConfig = couponConfigList[0].__dict__ if not couponConfig['isExternalIssual']: Assertion.constructAssertion( couponConfig['num_issued'] == no_issued, 'No. of Coupons issued, Actual : {} and Expected : {}'.format( couponConfig['num_issued'], no_issued)) else: Assertion.constructAssertion( couponConfig['num_issued'] != 0, 'No. of Coupons issued, Actual : {} and Expected : {}'.format( couponConfig['num_issued'], no_issued)) Assertion.constructAssertion( couponConfig['num_redeemed'] == no_redeemed, 'No. of Coupons redeemed, Actual : {} and Expected: {}'.format( couponConfig['num_redeemed'], no_redeemed)) Assertion.constructAssertion( 'owned_by' in couponConfig, 'Getting Details Owned by in CouponConfig') Assertion.constructAssertion( 'owner_id' in couponConfig, 'Getting Details Owner id in CouponConfig') Assertion.constructAssertion( 'ownerValidity' in couponConfig, 'Getting Details owner Validity in CouponConfig') return couponConfig
def test_LUCI_GCC_003(self, description): couponSeriesAsc = [self.couponSeriesId1, self.couponSeriesId2, self.couponSeriesId3, self.couponSeriesId4, self.couponSeriesId5] configRequest = LuciObject.getCouponConfigRequest({'orderBy' : self.constructObj.couponConfigOrderBy['CREATED_DATE'], 'sort' : self.constructObj.sort['ASC'], 'limit' : 5}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) Assertion.constructAssertion(len(couponConfigList) == 5, 'GetCouponConfig Limit {} and couponconfig got {}'.format(5, len(couponConfigList))) for couponConfig in couponConfigList: couponConfig = couponConfig.__dict__ Logger.log('Coupon Config Ids : ' , couponConfig['id'] ) Assertion.constructAssertion(couponConfig['id'] not in couponSeriesAsc, 'GetCouponConfig CouponSeriesId sort by desc order by Created Date Actual :{} and Excepted : {}'.format(couponConfig['id'],couponSeriesAsc))
def test_LUCI_GCC_009_sanity(self, description, requestFilter): configRequest = LuciObject.getCouponConfigRequest(requestFilter) couponConfigList = self.connObj.getCouponConfiguration(configRequest) getAllResponseList = self.connObj.getAllCouponConfigurations(LuciObject.getAllCouponConfigRequest(requestFilter)) Assertion.constructAssertion(len(couponConfigList) == len(getAllResponseList), 'GetCouponConfig & GetAllConfig List size {} and {} is matched'.format(len(couponConfigList),len(getAllResponseList))) for getConfigCouponSeries,getAllConfigCouponSeries in zip(couponConfigList,getAllResponseList): getConfigCouponSeries = getConfigCouponSeries.__dict__ getAllConfigCouponSeries = getAllConfigCouponSeries.__dict__ Assertion.constructAssertion(getConfigCouponSeries['id'] == getAllConfigCouponSeries['id'] , 'GetCouponConfig & GetAllConfig CouponSeriesId is Matched {} and {}'.format(getConfigCouponSeries['id'],getAllConfigCouponSeries['id']))
def test_LUCI_GCC_008(self, description): randomValueCamp = randValues.randomInteger(digits=6) couponConfig, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions(self, {'client_handling_type': 'DISC_CODE_PIN', 'created': Utils.getTime(seconds=0, milliSeconds=True), 'valid_till_date': Utils.getTime(days=1, milliSeconds=True), 'campaign_id' : randomValueCamp}) configRequest = LuciObject.getCouponConfigRequest({'ownerId' : randomValueCamp, 'sort' : 1, 'includeUnclaimed' : True, 'limit' : 5 }) couponConfigList = self.connObj.getCouponConfiguration(configRequest) for couponRes in couponConfigList: couponRes = couponRes.__dict__ if couponRes['id'] == couponSeriesId: Assertion.constructAssertion(couponRes['owned_by'] == self.constructObj.ownedBy['OUTBOUND'], 'OwnedBy value is Matched Actual: {} and Expected: {}'.format(couponRes['owned_by'] , self.constructObj.ownedBy['OUTBOUND'])) Assertion.constructAssertion(couponRes['owner_id'] == randomValueCamp, 'OwnerId is Matched Actual: {} and Expected: {}'.format(couponRes['owner_id'], randomValueCamp)) break Assertion.constructAssertion(len(couponConfigList) == 5, 'GetCouponConfig Limit {} and couponconfig got {}'.format(5, len(couponConfigList))) Assertion.constructAssertion(couponConfigList != None, 'Retrieved couponConfig from GetCouponConfig by OwnedBy')
def couponConfigChange(self, condition): Logger.log('Setting Voucher Resent Config to :{} for voucherId :{}'.format(condition, self.voucherId)) constant.config['campaignId'] = self.campaignId port = constant.config['luciPort'].next() connObj = LuciThrift(port) constructObj = LuciObject() configRequest = LuciObject.getCouponConfigRequest({'couponSeriesId': self.voucherId}) couponConfigList = connObj.getCouponConfiguration(configRequest) couponConfig = couponConfigList[0].__dict__ couponConfig.update(condition) couponConfigObject = LuciObject.couponConfiguration(couponConfig) saveCouponConfigObject = LuciObject.saveCouponConfigRequest(couponConfigObject) connObj.saveCouponConfiguration(saveCouponConfigObject)
def test_LUCI_BCSKU_002_sanity(self, description): couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self) prodInfo = LuciObject.productInfo( {'productIds': [9926522, 9926523, 15972]}) couponConfigObj.update({'productInfo': [prodInfo]}) couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigObj, {'includeProductInfo': True}) prodInfo = LuciObject.productInfo({ 'productType': 0, 'productIds': [1243] }) couponConfigObj.update({'productInfo': [prodInfo]}) couponConfigObj, couponSeriesId = LuciHelper.saveCouponConfigAndAssertions( self, couponConfigObj, {'includeProductInfo': True}) LuciHelper.queuePumpWait(self, couponSeriesId) Assertion.constructAssertion( LuciDBHelper.getCouponsCreated_Count(couponSeriesId) != 0, 'Coupon Code Pumped to Queue') configRequest = LuciObject.getCouponConfigRequest( {'couponSeriesId': couponSeriesId}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) productInfo = couponConfigList[0].__dict__ productInfo = productInfo['productInfo'] productIds = [] productIds2 = [] voucherProductDataValuesList = LuciDBHelper.getVoucherProductDataValues( couponSeriesId) for k in productInfo: k = k.__dict__ Assertion.constructAssertion( (k['productType'] == self.constructObj.productType['BRAND']) or (k['productType'] == self.constructObj.productType['CATEGORY']), 'PRODUCT TYPE IS MISMATCH') productIds += k['productIds'] for k in voucherProductDataValuesList: productIds2.append(k['product_id']) Assertion.constructAssertion( len(voucherProductDataValuesList) == len(productIds), 'PRODUCT IDs COUNT IS MISMATCH') Assertion.constructAssertion( set(productIds) == set(productIds2), 'PRODUCT IDs ARE MISMATCH IN DB AND THRIFT RESPONSE')
def test_LUCI_GCC_004(self, description): self.couponConfig4.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self,self.couponConfig4) time.sleep(2) self.couponConfig1.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self, self.couponConfig1) time.sleep(2) self.couponConfig3.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self, self.couponConfig3) time.sleep(2) self.couponConfig5.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self, self.couponConfig5) time.sleep(2) self.couponConfig2.update({'description' : 'Luci desc updated'}) LuciHelper.saveCouponConfigAndAssertions(self, self.couponConfig2) couponSeriesDesc = [self.couponSeriesId2, self.couponSeriesId5, self.couponSeriesId3, self.couponSeriesId1, self.couponSeriesId4] configRequest = LuciObject.getCouponConfigRequest({'orderBy' : self.constructObj.couponConfigOrderBy['LAST_MODIFIED_DATE'], 'sort' : self.constructObj.sort['DESC'], 'limit' : 5}) couponConfigList = self.connObj.getCouponConfiguration(configRequest) Assertion.constructAssertion(len(couponConfigList) == 5, 'GetCouponConfig Limit {} and couponconfig got {}'.format(5, len(couponConfigList))) for couponConfig,couponSeriesId in zip(couponConfigList,couponSeriesDesc): couponConfig = couponConfig.__dict__ Logger.log('Coupon Config Ids : ' , couponConfig['id'] ) Assertion.constructAssertion(couponConfig['id'] == couponSeriesId , 'GetCouponConfig CouponSeriesId sort by desc order by Created Date Actual :{} and Excepted : {}'.format(couponConfig['id'],couponSeriesId))
def test_LUCI_GCC_006(self, description,getCouponRequest): configRequest = LuciObject.getCouponConfigRequest(getCouponRequest) couponConfigList = self.connObj.getCouponConfiguration(configRequest) Logger.log('Log Details : ', len(couponConfigList)) Assertion.constructAssertion(len(couponConfigList) == 5, 'GetCouponConfig Limit {} and couponconfig got {}'.format(5, len(couponConfigList))) Assertion.constructAssertion(couponConfigList != None, 'Retrieved couponConfig from GetCouponConfig by OwnedBy')