Skip to content

Commit

Permalink
[TEST] delivery_carrier_pricelist,delivery_multi_destination: fix tes…
Browse files Browse the repository at this point in the history
…ts related to delivery_auto_refresh
  • Loading branch information
ilyasProgrammer committed Apr 4, 2022
1 parent 0382b0c commit da545e5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
13 changes: 7 additions & 6 deletions delivery_carrier_pricelist/tests/test_delivery_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,21 @@ def test_wizard_invoice_policy(self):
def test_wizard_send_shipping(self):
self.create_price_list()
self.create_wizard()
price = self.pricelist_item.fixed_price
self.carrier_pricelist.invoice_policy = "pricelist"
delivery_wizard = self.delivery_wizard
delivery_wizard.carrier_id = self.carrier_pricelist
rec = delivery_wizard.save()
rec.button_confirm()
so = self.sale_normal_delivery_charges
so.action_confirm()
self.assertEqual(so.carrier_id, delivery_wizard.carrier_id)
link = delivery_wizard.carrier_id.get_tracking_link(so.picking_ids)
self.assertFalse(link)
result = delivery_wizard.carrier_id.send_shipping(so.picking_ids)
expecting = [{"exact_price": price, "tracking_number": False}]
self.assertEqual(result, expecting)
delivery_auto_refresh = self.env["ir.module.module"].search(
[("name", "=", "delivery_auto_refresh"), ("state", "=", "installed")]
)
if delivery_auto_refresh:
self.assertTrue(result[0]["exact_price"] > 0)
else:
self.assertEqual(result, [{"exact_price": 0.0, "tracking_number": False}])

def test_fields_view_get(self):
carrier = self.carrier_pricelist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ def test_delivery_multi_destination(self):
choose_delivery_carrier = delivery_wizard.save()
choose_delivery_carrier.button_confirm()
sale_order_line = order.order_line.filtered("is_delivery")
self.assertAlmostEqual(sale_order_line.price_unit, 50, 2)
delivery_auto_refresh = self.env["ir.module.module"].search(
[("name", "=", "delivery_auto_refresh"), ("state", "=", "installed")]
)
if delivery_auto_refresh:
self.assertEqual(sale_order_line.price_unit, 10.0)
else:
self.assertAlmostEqual(sale_order_line.price_unit, 50, 2)
self.assertTrue(sale_order_line.is_delivery)
order.partner_shipping_id = self.partner_3.id
delivery_wizard = Form(
Expand All @@ -172,7 +178,10 @@ def test_delivery_multi_destination(self):
choose_delivery_carrier = delivery_wizard.save()
choose_delivery_carrier.button_confirm()
sale_order_line = order.order_line.filtered("is_delivery")
self.assertAlmostEqual(sale_order_line.price_unit, 150, 2)
if delivery_auto_refresh:
self.assertEqual(sale_order_line.price_unit, 10.0)
else:
self.assertAlmostEqual(sale_order_line.price_unit, 150, 2)

def test_search(self):
carriers = self.env["delivery.carrier"].search([])
Expand Down Expand Up @@ -200,7 +209,16 @@ def test_picking_validation(self):
self.sale_order.partner_shipping_id = self.partner_2.id
self.sale_order.action_confirm()
picking = self.sale_order.picking_ids
self.assertEqual(picking.carrier_id, self.carrier_multi)
delivery_auto_refresh = self.env["ir.module.module"].search(
[("name", "=", "delivery_auto_refresh"), ("state", "=", "installed")]
)
if delivery_auto_refresh:
self.assertTrue(len(picking.carrier_id) == 1)
else:
self.assertEqual(picking.carrier_id, self.carrier_multi)
picking.move_lines.quantity_done = 1
picking._action_done()
self.assertAlmostEqual(picking.carrier_price, 50)
if delivery_auto_refresh:
self.assertEqual(picking.carrier_price, 10.0)
else:
self.assertAlmostEqual(picking.carrier_price, 50)

0 comments on commit da545e5

Please sign in to comment.