def test_uses_offers_in_order_of_descending_priority(self): self.applicator.get_site_offers = Mock( return_value=[models.ConditionalOffer( name="offer1", condition=self.condition, benefit=self.benefit, priority=1)]) self.applicator.get_user_offers = Mock( return_value=[models.ConditionalOffer( name="offer2", condition=self.condition, benefit=self.benefit, priority=-1)]) offers = self.applicator.get_offers(self.basket) priorities = [offer.priority for offer in offers] self.assertEqual(sorted(priorities, reverse=True), priorities)
def setUp(self): range = models.Range.objects.create( name="All products", includes_all_products=True) condition = models.CountCondition.objects.create( range=range, type=models.Condition.COUNT, value=3) benefit = models.PercentageDiscountBenefit.objects.create( range=range, type=models.Benefit.PERCENTAGE, value=20, max_affected_items=1) self.offer = models.ConditionalOffer( name="Test", offer_type=models.ConditionalOffer.SITE, condition=condition, benefit=benefit)
def setUp(self): self.condition_product = factories.ProductFactory() condition_range = factories.RangeFactory() condition_range.add_product(self.condition_product) self.condition = models.CountCondition.objects.create( range=condition_range, type=models.Condition.COUNT, value=2) self.benefit_product = factories.ProductFactory() benefit_range = factories.RangeFactory() benefit_range.add_product(self.benefit_product) self.benefit = models.AbsoluteDiscountBenefit.objects.create( range=benefit_range, type=models.Benefit.FIXED, value=D('3.00')) self.offer = models.ConditionalOffer(id=1, condition=self.condition, benefit=self.benefit) self.basket = factories.create_basket(empty=True) self.applicator = Applicator()
def setUp(self): self.offer = models.ConditionalOffer(max_global_applications=4)
def test_active_on_null_start_and_end_datetime(self): # null datetimes - offer is always available offer = models.ConditionalOffer(start_datetime=None, end_datetime=None) test = datetime.date(2017, 3, 10) self.assertTrue(offer.is_available(test_date=test))
def test_active_on_null_start_datetime(self): # null start_datetime means offer is active from the beginning of time offer = models.ConditionalOffer(start_datetime=None, end_datetime=self.end) test = datetime.date(2000, 3, 10) self.assertTrue(offer.is_available(test_date=test))
def test_active_on_null_end_datetime(self): # null end_datetime means offer should never expire offer = models.ConditionalOffer(start_datetime=self.start, end_datetime=None) test = datetime.date(2017, 3, 10) self.assertTrue(offer.is_available(test_date=test))
def setUp(self): self.start = datetime.date(2011, 1, 1) self.end = datetime.date(2011, 2, 1) self.offer = models.ConditionalOffer(start_datetime=self.start, end_datetime=self.end)
def setUp(self): self.offer = models.ConditionalOffer(max_user_applications=1) self.user = UserFactory()
def setUp(self): self.offer = models.ConditionalOffer( status=models.ConditionalOffer.SUSPENDED)
def setUp(self): self.offer = models.ConditionalOffer( max_discount=D('100.00'), total_discount=D('0.00'))
def setUp(self): self.applications = results.OfferApplications() self.offer = models.ConditionalOffer()
def setUp(self): offer = models.ConditionalOffer() self.applications = OfferApplications() for i in range(4): self.applications.add(offer, models.BasketDiscount(D('5.00')))