|
|
@@ -136,24 +136,48 @@ class WeightBandTests(unittest.TestCase):
|
|
136
|
136
|
WeightBand.objects.all().delete()
|
|
137
|
137
|
|
|
138
|
138
|
def test_get_band_for_lower_weight(self):
|
|
139
|
|
- band = WeightBand.objects.create(upper_limit=1, charge=D('4.00'))
|
|
140
|
|
- fetched_band = WeightBand.get_band_for_weight(0.5)
|
|
|
139
|
+ band = WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
|
140
|
+ fetched_band = WeightBand.get_band_for_weight('standard', 0.5)
|
|
141
|
141
|
self.assertEqual(band.id, fetched_band.id)
|
|
142
|
142
|
|
|
143
|
143
|
def test_get_band_for_higher_weight(self):
|
|
144
|
|
- band = WeightBand.objects.create(upper_limit=1, charge=D('4.00'))
|
|
145
|
|
- fetched_band = WeightBand.get_band_for_weight(1.5)
|
|
|
144
|
+ band = WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
|
145
|
+ fetched_band = WeightBand.get_band_for_weight('standard', 1.5)
|
|
146
|
146
|
self.assertIsNone(fetched_band)
|
|
147
|
147
|
|
|
148
|
148
|
def test_get_band_for_matching_weight(self):
|
|
149
|
|
- band = WeightBand.objects.create(upper_limit=1, charge=D('4.00'))
|
|
150
|
|
- fetched_band = WeightBand.get_band_for_weight(1)
|
|
|
149
|
+ band = WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
|
150
|
+ fetched_band = WeightBand.get_band_for_weight('standard', 1)
|
|
151
|
151
|
self.assertEqual(band.id, fetched_band.id)
|
|
152
|
152
|
|
|
153
|
|
- def test_get_band_for_series_of_bands(self):
|
|
|
153
|
+ def test_weight_to_is_upper_bound(self):
|
|
|
154
|
+ band = WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
|
155
|
+ self.assertEqual(1, band.weight_to)
|
|
|
156
|
+
|
|
|
157
|
+ def test_weight_from_for_single_band(self):
|
|
|
158
|
+ band = WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
|
159
|
+ self.assertEqual(0, band.weight_from)
|
|
|
160
|
+
|
|
|
161
|
+ def test_weight_from_for_multiple_bands(self):
|
|
154
|
162
|
WeightBand.objects.create(upper_limit=1, charge=D('4.00'))
|
|
155
|
|
- WeightBand.objects.create(upper_limit=2, charge=D('8.00'))
|
|
156
|
|
- WeightBand.objects.create(upper_limit=3, charge=D('12.00'))
|
|
157
|
|
- self.assertEqual(D('4.00'), WeightBand.get_band_for_weight(0.5).charge)
|
|
158
|
|
- self.assertEqual(D('8.00'), WeightBand.get_band_for_weight(1.5).charge)
|
|
159
|
|
- self.assertEqual(D('12.00'), WeightBand.get_band_for_weight(2.5).charge)
|
|
|
163
|
+ band = WeightBand.objects.create(method_code='standard', upper_limit=2, charge=D('8.00'))
|
|
|
164
|
+ self.assertEqual(1, band.weight_from)
|
|
|
165
|
+
|
|
|
166
|
+ def test_weight_from_for_multiple_bands(self):
|
|
|
167
|
+ WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
|
168
|
+ band = WeightBand.objects.create(method_code='express', upper_limit=2, charge=D('8.00'))
|
|
|
169
|
+ self.assertEqual(0, band.weight_from)
|
|
|
170
|
+
|
|
|
171
|
+ def test_get_band_for_series_of_bands(self):
|
|
|
172
|
+ WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
|
173
|
+ WeightBand.objects.create(method_code='standard', upper_limit=2, charge=D('8.00'))
|
|
|
174
|
+ WeightBand.objects.create(method_code='standard', upper_limit=3, charge=D('12.00'))
|
|
|
175
|
+ self.assertEqual(D('4.00'), WeightBand.get_band_for_weight('standard', 0.5).charge)
|
|
|
176
|
+ self.assertEqual(D('8.00'), WeightBand.get_band_for_weight('standard', 1.5).charge)
|
|
|
177
|
+ self.assertEqual(D('12.00'), WeightBand.get_band_for_weight('standard', 2.5).charge)
|
|
|
178
|
+
|
|
|
179
|
+ def test_get_band_for_series_of_bands_from_different_methods(self):
|
|
|
180
|
+ WeightBand.objects.create(method_code='standard', upper_limit=1, charge=D('4.00'))
|
|
|
181
|
+ WeightBand.objects.create(method_code='express', upper_limit=2, charge=D('8.00'))
|
|
|
182
|
+ WeightBand.objects.create(method_code='standard', upper_limit=3, charge=D('12.00'))
|
|
|
183
|
+ self.assertEqual(D('12.00'), WeightBand.get_band_for_weight('standard', 2.5).charge)
|