예제 #1
0
    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)
예제 #2
0
 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)
예제 #3
0
    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()
예제 #4
0
 def setUp(self):
     self.offer = models.ConditionalOffer(max_global_applications=4)
예제 #5
0
 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))
예제 #6
0
 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))
예제 #7
0
 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))
예제 #8
0
 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)
예제 #9
0
 def setUp(self):
     self.offer = models.ConditionalOffer(max_user_applications=1)
     self.user = UserFactory()
예제 #10
0
 def setUp(self):
     self.offer = models.ConditionalOffer(
         status=models.ConditionalOffer.SUSPENDED)
예제 #11
0
 def setUp(self):
     self.offer = models.ConditionalOffer(
         max_discount=D('100.00'),
         total_discount=D('0.00'))
예제 #12
0
 def setUp(self):
     self.applications = results.OfferApplications()
     self.offer = models.ConditionalOffer()
예제 #13
0
 def setUp(self):
     offer = models.ConditionalOffer()
     self.applications = OfferApplications()
     for i in range(4):
         self.applications.add(offer, models.BasketDiscount(D('5.00')))