feat: a Jadlog quote counts one box per 60 m of film
All checks were successful
Build and deploy / Validate source (push) Successful in 1m20s
Build and deploy / Integration suite on a real stack (push) Successful in 3m11s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m19s
All checks were successful
Build and deploy / Validate source (push) Successful in 1m20s
Build and deploy / Integration suite on a real stack (push) Successful in 3m11s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m19s
The client corrected the box to 63 x 15.5 x 15.5 cm and said one box holds about 60 m. JADLOG_METROS_POR_CAIXA quotes a longer order as several boxes, each with its packaging weight and volume. UV ships in the same box. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -124,10 +124,27 @@ class JadlogFreightTest(unittest.TestCase):
|
||||
freight.quote('jadlog', '01310100', '60', 1490)
|
||||
self.assertEqual(seen[1], 4.8)
|
||||
|
||||
def test_a_long_order_ships_in_more_boxes(self):
|
||||
seen = []
|
||||
|
||||
def handler(request):
|
||||
seen.append(json.loads(request.content)['frete'][0]['peso'])
|
||||
return httpx.Response(200, json={'frete': [{'vltotal': 30, 'prazo': 3}]})
|
||||
|
||||
freight = self.freight(handler, JADLOG_PESO_BASE_KG='0.3', JADLOG_PESO_POR_METRO_KG='0.075',
|
||||
JADLOG_CAIXA_CM='63x15,5x15,5', JADLOG_CUBAGEM_KG_M3='300',
|
||||
JADLOG_METROS_POR_CAIXA='60')
|
||||
# 63 x 15.5 x 15.5 cm is 0.01513575 m³: 4.541 kg cubed for one box.
|
||||
self.assertEqual((freight.boxes('60'), freight.boxes('60.01'), freight.boxes('121')), (1, 2, 3))
|
||||
quote = freight.quote('jadlog', '01310100', '61', 1490)
|
||||
# Two boxes: 0.6 kg of packaging plus 4.575 kg of film, against 9.081 kg cubed.
|
||||
self.assertEqual((quote['boxes'], quote['real_kg'], seen[0]), (2, '5.175', 9.081))
|
||||
|
||||
def test_a_box_needs_its_factor(self):
|
||||
for env in ({'JADLOG_CAIXA_CM': '56x14x14'}, {'JADLOG_CUBAGEM_KG_M3': '300'},
|
||||
{'JADLOG_CAIXA_CM': '56x14', 'JADLOG_CUBAGEM_KG_M3': '300'},
|
||||
{'JADLOG_CAIXA_CM': '56x14x14', 'JADLOG_CUBAGEM_KG_M3': '0'}):
|
||||
{'JADLOG_CAIXA_CM': '56x14x14', 'JADLOG_CUBAGEM_KG_M3': '0'},
|
||||
{'JADLOG_METROS_POR_CAIXA': '0'}):
|
||||
with self.subTest(env=env), self.assertRaises(RuntimeError):
|
||||
self.freight(lambda request: httpx.Response(200), **env)
|
||||
# Neither: the real weight only, as before the box was known.
|
||||
|
||||
Reference in New Issue
Block a user