def test_get_queryset(self): """ Should return only Conditional Offers with Site offer type. """ # Conditional Offer should contain a condition with enterprise customer uuid set in order to be returned partner_conditional_offer = factories.EnterpriseOfferFactory( partner=self.partner) # Conditional Offer with null Partner or non-matching Partner should not be returned null_partner_offer = factories.EnterpriseOfferFactory() different_partner_offer = factories.EnterpriseOfferFactory( partner=factories.SiteConfigurationFactory().partner) enterprise_offers = [ partner_conditional_offer, factories.EnterpriseOfferFactory( offer_type=ConditionalOffer.VOUCHER), factories.ConditionalOfferFactory( offer_type=ConditionalOffer.SITE), null_partner_offer, different_partner_offer ] for offer in enterprise_offers: self.mock_specific_enterprise_customer_api( offer.condition.enterprise_customer_uuid) response = self.client.get(self.path) self.assertEqual(list(response.context['object_list']), [partner_conditional_offer])
def test_get_queryset(self): """ Should return only Conditional Offers with Site offer type. """ # Conditional Offer should contain a condition with program uuid set in order to be returned site_conditional_offer = factories.ProgramOfferFactory( partner=self.partner) # Conditional Offer with null Partner or non-matching Partner should not be returned null_partner_offer = factories.ProgramOfferFactory() different_partner_offer = factories.ProgramOfferFactory( partner=factories.SiteConfigurationFactory().partner) program_offers = [ site_conditional_offer, factories.ProgramOfferFactory(offer_type=ConditionalOffer.VOUCHER), factories.ConditionalOfferFactory( offer_type=ConditionalOffer.SITE), null_partner_offer, different_partner_offer ] for offer in program_offers: self.mock_program_detail_endpoint( offer.condition.program_uuid, self.site_configuration.discovery_api_url) response = self.client.get(self.path) self.assertEqual(list(response.context['object_list']), [site_conditional_offer])