diff --git a/stock_warehouse_calendar_orderpoint/tests/__init__.py b/stock_warehouse_calendar_orderpoint/tests/__init__.py index 178eb5918016..06a61a356944 100644 --- a/stock_warehouse_calendar_orderpoint/tests/__init__.py +++ b/stock_warehouse_calendar_orderpoint/tests/__init__.py @@ -1 +1,2 @@ -from . import test_calendar_orderpoint +from . import test_orderpoint_json_lead_days_popover +from . import test_orderpoint_lead_days_date diff --git a/stock_warehouse_calendar_orderpoint/tests/common.py b/stock_warehouse_calendar_orderpoint/tests/common.py index d1979f26e539..04730b92fd84 100644 --- a/stock_warehouse_calendar_orderpoint/tests/common.py +++ b/stock_warehouse_calendar_orderpoint/tests/common.py @@ -63,9 +63,9 @@ def setUpClass(cls): "product_uom": cls.env.ref("uom.product_uom_unit"), } ) - # We want only 1 reordering rule of type "pull" to avoid inconsistent behaviors + # To avoid strange behaviors: + # - set the first rule to be of type "pull" + # - set all rules' delays to 0 (the "pull" rule's delay is updated in tests) cls.reordering_rule = cls.orderpoint.rule_ids[0] cls.reordering_rule.action = "pull" - other_rules = cls.orderpoint.rule_ids - cls.reordering_rule - if other_rules: - other_rules.unlink() + cls.orderpoint.rule_ids.write({"delay": 0}) diff --git a/stock_warehouse_calendar_orderpoint/tests/test_orderpoint_json_lead_days_popover.py b/stock_warehouse_calendar_orderpoint/tests/test_orderpoint_json_lead_days_popover.py new file mode 100644 index 000000000000..bc6c5469a5a3 --- /dev/null +++ b/stock_warehouse_calendar_orderpoint/tests/test_orderpoint_json_lead_days_popover.py @@ -0,0 +1,27 @@ +# Copyright 2022 Camptocamp SA +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl) + +from json import loads + +from freezegun import freeze_time + +from .common import CommonCalendarOrderpoint + + +class TestOrderpointJsonPopover(CommonCalendarOrderpoint): + """Tests orderpoint's Json popover info""" + + @freeze_time("2024-04-01 10:00") + def test_00_json_popover_info(self): + self.wh.orderpoint_calendar_id = self.reordering_calendar + self.wh.calendar_id = self.working_hours_calendar + self.reordering_rule.delay = 5 + self.env["stock.warehouse.orderpoint"].invalidate_cache( + ["json_lead_days_popover"] + ) + info = loads(self.orderpoint.json_lead_days_popover) + self.assertIn("lead_days_description", info) + self.assertIn( + "Reordering Date04/03/2024", + info["lead_days_description"], + ) diff --git a/stock_warehouse_calendar_orderpoint/tests/test_calendar_orderpoint.py b/stock_warehouse_calendar_orderpoint/tests/test_orderpoint_lead_days_date.py similarity index 99% rename from stock_warehouse_calendar_orderpoint/tests/test_calendar_orderpoint.py rename to stock_warehouse_calendar_orderpoint/tests/test_orderpoint_lead_days_date.py index c5bbf44b5a24..cf2b77b5ee46 100644 --- a/stock_warehouse_calendar_orderpoint/tests/test_calendar_orderpoint.py +++ b/stock_warehouse_calendar_orderpoint/tests/test_orderpoint_lead_days_date.py @@ -6,7 +6,7 @@ from .common import CommonCalendarOrderpoint -class TestCalendarOrderpoint(CommonCalendarOrderpoint): +class TestOrderpointLeadDaysDate(CommonCalendarOrderpoint): """Tests orderpoints' forecast date computations The OP calendar defines reordering slots as Wed 8-12 + 13-17, Sat 13-17.