|
@@ -2,7 +2,10 @@ from decimal import Decimal as D
|
2
|
2
|
|
3
|
3
|
from django.test import TestCase
|
4
|
4
|
|
|
5
|
+from oscar.apps.offer.applicator import Applicator
|
|
6
|
+from oscar.apps.offer.models import Benefit
|
5
|
7
|
from oscar.apps.shipping.models import OrderAndItemCharges, WeightBased
|
|
8
|
+from oscar.apps.shipping.repository import Repository
|
6
|
9
|
from oscar.core.compat import get_user_model
|
7
|
10
|
from oscar.test import factories
|
8
|
11
|
|
|
@@ -198,3 +201,24 @@ class WeightBasedMethodTests(TestCase):
|
198
|
201
|
charge = self.standard.calculate(basket)
|
199
|
202
|
|
200
|
203
|
self.assertEqual(D('1.00') + D('2.00'), charge.excl_tax)
|
|
204
|
+
|
|
205
|
+ def test_zero_charge_discount(self):
|
|
206
|
+ # Since Repository.apply_shipping_offer() returns the original
|
|
207
|
+ # shipping method object on a free shipping charge, it's discount()
|
|
208
|
+ # method should be callable and also indicate it won't add discounts.
|
|
209
|
+ basket = factories.create_basket()
|
|
210
|
+ self.assertEqual(D('0.00'), self.standard.discount(basket))
|
|
211
|
+
|
|
212
|
+ def test_zero_charge_with_shipping_discount(self):
|
|
213
|
+ offer = factories.create_offer(
|
|
214
|
+ benefit=Benefit.objects.create(
|
|
215
|
+ type=Benefit.SHIPPING_FIXED_PRICE, value=1),
|
|
216
|
+ )
|
|
217
|
+ basket = factories.create_basket()
|
|
218
|
+ Applicator().apply_offers(basket, [offer])
|
|
219
|
+
|
|
220
|
+ # Similar to test_zero_charge_discount(),
|
|
221
|
+ # but now test how the repository deals with it.
|
|
222
|
+ method = Repository().apply_shipping_offer(
|
|
223
|
+ basket, self.standard, offer)
|
|
224
|
+ self.assertEqual(D('0.00'), method.discount(basket))
|