예제 #1
0
    def test_grouped_voucher_discounts(self):
        voucher = VoucherFactory()
        offer1 = ConditionalOfferFactory(name='offer1')
        offer1.set_voucher(voucher)
        result1 = models.BasketDiscount(D('2.00'))

        offer2 = ConditionalOfferFactory(name='offer2')
        offer2.set_voucher(voucher)
        result2 = models.BasketDiscount(D('1.00'))

        self.applications.add(offer1, result1)
        self.applications.add(offer2, result2)

        assert len(self.applications) == 2

        discounts = self.applications.grouped_voucher_discounts
        discounts = [x for x in discounts]
        assert len(discounts) == 1
        assert discounts[0]['voucher'] == voucher
        assert discounts[0]['discount'] == D('3.00')
예제 #2
0
 def setUp(self):
     offer = models.ConditionalOffer()
     self.applications = OfferApplications()
     for i in range(4):
         self.applications.add(offer, models.BasketDiscount(D('5.00')))
예제 #3
0
 def test_can_filter_offer_discounts(self):
     result = models.BasketDiscount(D('2.00'))
     self.applications.add(self.offer, result)
     self.assertEqual(1, len(self.applications.offer_discounts))