def test_zero_charge_with_shipping_discount(self):
        offer = factories.create_offer(benefit=Benefit.objects.create(
            type=Benefit.SHIPPING_FIXED_PRICE, value=1), )
        basket = factories.create_basket()
        Applicator().apply_offers(basket, [offer])

        # Similar to test_zero_charge_discount(),
        # but now test how the repository deals with it.
        method = Repository().apply_shipping_offer(basket, self.standard,
                                                   offer)
        self.assertEqual(D('0.00'), method.discount(basket))
    def test_zero_charge_with_shipping_discount(self):
        offer = factories.create_offer(
            benefit=Benefit.objects.create(
                type=Benefit.SHIPPING_FIXED_PRICE, value=1),
        )
        basket = factories.create_basket()
        Applicator().apply_offers(basket, [offer])

        # Similar to test_zero_charge_discount(),
        # but now test how the repository deals with it.
        method = Repository().apply_shipping_offer(
            basket, self.standard, offer)
        self.assertEqual(D('0.00'), method.discount(basket))
Example #3
0
class RepositoryTests(TestCase):
    def setUp(self):
        self.repo = Repository()

    def test_default_method_is_free(self):
        user, basket = User(), Basket()
        methods = self.repo.get_shipping_methods(user, basket)
        self.assertEqual(1, len(methods))
        self.assertTrue(isinstance(methods[0], Free))
Example #4
0
class RepositoryTests(TestCase):
    def setUp(self):
        self.repo = Repository()

    def test_default_method_is_free(self):
        user, basket = User(), Basket()
        methods = self.repo.get_shipping_methods(user, basket)
        self.assertEqual(1, len(methods))
        self.assertTrue(isinstance(methods[0], Free))
Example #5
0
    def test_shipping_offer_is_applied(self):
        add_product(self.basket, D('12.00'))
        offer = self.apply_20percent_shipping_offer()

        shipping = FixedPrice(D('5.00'), D('5.00'))
        shipping = Repository().apply_shipping_offer(self.basket, shipping,
                                                     offer)

        place_order(self.creator,
                    basket=self.basket,
                    order_number='1234',
                    shipping_method=shipping)
        order = Order.objects.get(number='1234')

        self.assertEqual(1, len(order.shipping_discounts))
        self.assertEqual(D('4.00'), order.shipping_incl_tax)
        self.assertEqual(D('16.00'), order.total_incl_tax)
Example #6
0
    def test_has_discount_recorded_correctly_when_order_is_placed(self):
        add_product(self.basket, D('12.00'), 1)
        utils.Applicator().apply(self.basket)
        self.assertEqual(1, len(self.basket.offer_applications))

        shipping_method = WeightBased.objects.first()
        shipping_method = Repository().apply_shipping_offer(
            self.basket, shipping_method, self.offer)
        order = factories.create_order(basket=self.basket,
                                       shipping_method=shipping_method)

        discounts = order.discounts.all()
        self.assertEqual(1, len(discounts))

        discount = discounts[0]
        self.assertTrue(discount.is_shipping_discount)
        self.assertEqual(D('9.00'), discount.amount)
Example #7
0
    def test_zero_shipping_discount_is_not_created(self):
        add_product(self.basket, D('12.00'))
        offer = self.apply_20percent_shipping_offer()

        shipping = Free()
        shipping = Repository().apply_shipping_offer(self.basket, shipping,
                                                     offer)

        place_order(self.creator,
                    basket=self.basket,
                    order_number='1234',
                    shipping_method=shipping)
        order = Order.objects.get(number='1234')

        # No shipping discount
        self.assertEqual(0, len(order.shipping_discounts))
        self.assertEqual(D('0.00'), order.shipping_incl_tax)
        self.assertEqual(D('12.00'), order.total_incl_tax)
Example #8
0
 def setUp(self):
     self.repo = Repository()
Example #9
0
 def setUp(self):
     self.repo = Repository()