-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] shipment_advice_planner_toursolver: add unit tests
- Loading branch information
Showing
5 changed files
with
76 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from . import common | ||
from . import test_shipment_advice_planner_toursolver | ||
from . import test_toursolver_delivery_window | ||
from . import test_picking_can_be_planned |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2023 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from odoo.tests.common import Form, TransactionCase | ||
|
||
|
||
class TestShipmentAdvicePlannerToursolverCommon(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.pickings = cls.env["stock.picking"].search([]) | ||
cls.context = { | ||
"active_ids": cls.pickings.ids, | ||
"active_model": "stock.picking", | ||
} | ||
cls.warehouse = cls.env.ref("stock.warehouse0") | ||
cls.resource_1 = cls.env.ref( | ||
"shipment_advice_planner_toursolver.toursolver_resource_r1_demo" | ||
) | ||
cls.resource_2 = cls.env.ref( | ||
"shipment_advice_planner_toursolver.toursolver_resource_r2_demo" | ||
) | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.wizard_form = Form( | ||
self.env["shipment.advice.planner"].with_context(**self.context) | ||
) | ||
self.wizard_form.warehouse_id = self.warehouse | ||
|
||
def _create_task(self): | ||
self.wizard_form.shipment_planning_method = "toursolver" | ||
wizard = self.wizard_form.save() | ||
wizard.delivery_resource_ids = self.resource_1 | self.resource_2 | ||
wizard.button_plan_shipments() | ||
return wizard.picking_to_plan_ids.toursolver_task_id |
25 changes: 25 additions & 0 deletions
25
shipment_advice_planner_toursolver/tests/test_picking_can_be_planned.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2023 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.addons.shipment_advice_planner.tests.test_picking_can_be_planned import ( | ||
TestPickingCanBePlanned as TestPickingCanBePlannedBase, | ||
) | ||
|
||
from .common import TestShipmentAdvicePlannerToursolverCommon | ||
|
||
|
||
class TestPickingCanBePlanned( | ||
TestPickingCanBePlannedBase, TestShipmentAdvicePlannerToursolverCommon | ||
): | ||
def test_01(self): | ||
picking = self.pickings.filtered(lambda p: p.state == "assigned")[0] | ||
self.assert_picking_can_be_planned_in_shipment_advice(picking) | ||
self._create_task() | ||
self.assertTrue(picking.toursolver_task_id) | ||
self.assert_can_not_be_planned_in_shipment_advice(picking) | ||
picking.toursolver_task_id.state = "done" | ||
self.assert_picking_can_be_planned_in_shipment_advice(picking) | ||
picking.toursolver_task_id.state = "cancelled" | ||
self.assert_picking_can_be_planned_in_shipment_advice(picking) | ||
picking.toursolver_task_id.state = "draft" | ||
self.assert_can_not_be_planned_in_shipment_advice(picking) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters