|
|
@@ -4,8 +4,8 @@ from django.utils import unittest
|
|
4
|
4
|
from django.test.client import Client
|
|
5
|
5
|
from django.contrib.auth.models import User
|
|
6
|
6
|
|
|
7
|
|
-from oscar.apps.shipping.methods import FreeShipping, FixedPriceShipping, WeightBasedChargesMethod
|
|
8
|
|
-from oscar.apps.shipping.models import OrderAndItemLevelChargeMethod, WeightBand
|
|
|
7
|
+from oscar.apps.shipping.methods import Free, FixedPrice, WeightBased
|
|
|
8
|
+from oscar.apps.shipping.models import OrderAndItemCharges, WeightBand
|
|
9
|
9
|
from oscar.apps.shipping.repository import Repository
|
|
10
|
10
|
from oscar.apps.shipping import Scales
|
|
11
|
11
|
from oscar.apps.basket.models import Basket
|
|
|
@@ -13,10 +13,10 @@ from oscar.test.helpers import create_product
|
|
13
|
13
|
from oscar.test.decorators import dataProvider
|
|
14
|
14
|
|
|
15
|
15
|
|
|
16
|
|
-class FreeShippingTest(unittest.TestCase):
|
|
|
16
|
+class FreeTest(unittest.TestCase):
|
|
17
|
17
|
|
|
18
|
18
|
def setUp(self):
|
|
19
|
|
- self.method = FreeShipping()
|
|
|
19
|
+ self.method = Free()
|
|
20
|
20
|
|
|
21
|
21
|
def test_shipping_is_free_for_empty_basket(self):
|
|
22
|
22
|
basket = Basket()
|
|
|
@@ -32,17 +32,17 @@ class FreeShippingTest(unittest.TestCase):
|
|
32
|
32
|
self.assertEquals(D('0.00'), self.method.basket_charge_excl_tax())
|
|
33
|
33
|
|
|
34
|
34
|
|
|
35
|
|
-class FixedPriceShippingTest(unittest.TestCase):
|
|
|
35
|
+class FixedPriceTest(unittest.TestCase):
|
|
36
|
36
|
|
|
37
|
37
|
def test_fixed_price_shipping_charges_for_empty_basket(self):
|
|
38
|
|
- method = FixedPriceShipping(D('10.00'), D('10.00'))
|
|
|
38
|
+ method = FixedPrice(D('10.00'), D('10.00'))
|
|
39
|
39
|
basket = Basket()
|
|
40
|
40
|
method.set_basket(basket)
|
|
41
|
41
|
self.assertEquals(D('10.00'), method.basket_charge_incl_tax())
|
|
42
|
42
|
self.assertEquals(D('10.00'), method.basket_charge_excl_tax())
|
|
43
|
43
|
|
|
44
|
44
|
def test_fixed_price_shipping_assumes_no_tax(self):
|
|
45
|
|
- method = FixedPriceShipping(D('10.00'))
|
|
|
45
|
+ method = FixedPrice(D('10.00'))
|
|
46
|
46
|
basket = Basket()
|
|
47
|
47
|
method.set_basket(basket)
|
|
48
|
48
|
self.assertEquals(D('10.00'), method.basket_charge_excl_tax())
|
|
|
@@ -54,16 +54,16 @@ class FixedPriceShippingTest(unittest.TestCase):
|
|
54
|
54
|
|
|
55
|
55
|
@dataProvider(shipping_values)
|
|
56
|
56
|
def test_different_values(self, value):
|
|
57
|
|
- method = FixedPriceShipping(D(value))
|
|
|
57
|
+ method = FixedPrice(D(value))
|
|
58
|
58
|
basket = Basket()
|
|
59
|
59
|
method.set_basket(basket)
|
|
60
|
60
|
self.assertEquals(D(value), method.basket_charge_excl_tax())
|
|
61
|
61
|
|
|
62
|
62
|
|
|
63
|
|
-class OrderAndItemLevelChargeMethodTests(unittest.TestCase):
|
|
|
63
|
+class OrderAndItemChargesTests(unittest.TestCase):
|
|
64
|
64
|
|
|
65
|
65
|
def setUp(self):
|
|
66
|
|
- self.method = OrderAndItemLevelChargeMethod(price_per_order=D('5.00'), price_per_item=D('1.00'))
|
|
|
66
|
+ self.method = OrderAndItemCharges(price_per_order=D('5.00'), price_per_item=D('1.00'))
|
|
67
|
67
|
self.basket = Basket.objects.create()
|
|
68
|
68
|
self.method.set_basket(self.basket)
|
|
69
|
69
|
|
|
|
@@ -81,10 +81,10 @@ class OrderAndItemLevelChargeMethodTests(unittest.TestCase):
|
|
81
|
81
|
self.assertEquals(D('5.00') + 7*D('1.00'), self.method.basket_charge_incl_tax())
|
|
82
|
82
|
|
|
83
|
83
|
|
|
84
|
|
-class ZeroFreeShippingThresholdTest(unittest.TestCase):
|
|
|
84
|
+class ZeroFreeThresholdTest(unittest.TestCase):
|
|
85
|
85
|
|
|
86
|
86
|
def setUp(self):
|
|
87
|
|
- self.method = OrderAndItemLevelChargeMethod(price_per_order=D('10.00'), free_shipping_threshold=D('0.00'))
|
|
|
87
|
+ self.method = OrderAndItemCharges(price_per_order=D('10.00'), free_shipping_threshold=D('0.00'))
|
|
88
|
88
|
self.basket = Basket.objects.create()
|
|
89
|
89
|
self.method.set_basket(self.basket)
|
|
90
|
90
|
|
|
|
@@ -97,10 +97,10 @@ class ZeroFreeShippingThresholdTest(unittest.TestCase):
|
|
97
|
97
|
self.assertEquals(D('0.00'), self.method.basket_charge_incl_tax())
|
|
98
|
98
|
|
|
99
|
99
|
|
|
100
|
|
-class NonZeroFreeShippingThresholdTest(unittest.TestCase):
|
|
|
100
|
+class NonZeroFreeThresholdTest(unittest.TestCase):
|
|
101
|
101
|
|
|
102
|
102
|
def setUp(self):
|
|
103
|
|
- self.method = OrderAndItemLevelChargeMethod(price_per_order=D('10.00'), free_shipping_threshold=D('20.00'))
|
|
|
103
|
+ self.method = OrderAndItemCharges(price_per_order=D('10.00'), free_shipping_threshold=D('20.00'))
|
|
104
|
104
|
self.basket = Basket.objects.create()
|
|
105
|
105
|
self.method.set_basket(self.basket)
|
|
106
|
106
|
|
|
|
@@ -123,7 +123,7 @@ class NonZeroFreeShippingThresholdTest(unittest.TestCase):
|
|
123
|
123
|
class WeightBasedShippingTests(unittest.TestCase):
|
|
124
|
124
|
|
|
125
|
125
|
def test_no_bands_leads_to_zero_charges(self):
|
|
126
|
|
- method = WeightBasedChargesMethod('dummy')
|
|
|
126
|
+ method = WeightBased('dummy')
|
|
127
|
127
|
basket = Basket.objects.create()
|
|
128
|
128
|
method.set_basket(basket)
|
|
129
|
129
|
|
|
|
@@ -133,7 +133,7 @@ class WeightBasedShippingTests(unittest.TestCase):
|
|
133
|
133
|
def test_lower_band_basket(self):
|
|
134
|
134
|
WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
135
|
135
|
WeightBand.objects.create(method_code='standard', upper_limit=3, charge=D('12.00'))
|
|
136
|
|
- method = WeightBasedChargesMethod('standard')
|
|
|
136
|
+ method = WeightBased('standard')
|
|
137
|
137
|
|
|
138
|
138
|
basket = Basket.objects.create()
|
|
139
|
139
|
basket.add_product(create_product(attributes={'weight': 0.5}))
|
|
|
@@ -144,7 +144,7 @@ class WeightBasedShippingTests(unittest.TestCase):
|
|
144
|
144
|
def test_inner_band_basket(self):
|
|
145
|
145
|
WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
146
|
146
|
WeightBand.objects.create(method_code='standard', upper_limit=3, charge=D('12.00'))
|
|
147
|
|
- method = WeightBasedChargesMethod('standard')
|
|
|
147
|
+ method = WeightBased('standard')
|
|
148
|
148
|
|
|
149
|
149
|
basket = Basket.objects.create()
|
|
150
|
150
|
basket.add_product(create_product(attributes={'weight': 0.5}))
|
|
|
@@ -156,7 +156,7 @@ class WeightBasedShippingTests(unittest.TestCase):
|
|
156
|
156
|
def test_outer_band_basket(self):
|
|
157
|
157
|
WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
158
|
158
|
WeightBand.objects.create(method_code='standard', upper_limit=3, charge=D('12.00'))
|
|
159
|
|
- method = WeightBasedChargesMethod('standard', upper_charge=D('30.00'))
|
|
|
159
|
+ method = WeightBased('standard', upper_charge=D('30.00'))
|
|
160
|
160
|
|
|
161
|
161
|
basket = Basket.objects.create()
|
|
162
|
162
|
basket.add_product(create_product(attributes={'weight': 10.5}))
|
|
|
@@ -260,5 +260,5 @@ class RepositoryTests(unittest.TestCase):
|
|
260
|
260
|
user, basket = User(), Basket()
|
|
261
|
261
|
methods = self.repo.get_shipping_methods(user, basket)
|
|
262
|
262
|
self.assertEqual(1, len(methods))
|
|
263
|
|
- self.assertTrue(isinstance(methods[0], FreeShipping))
|
|
|
263
|
+ self.assertTrue(isinstance(methods[0], Free))
|
|
264
|
264
|
|