From 6e10e7459a7509db6a44fcb7c979852ae7da018a Mon Sep 17 00:00:00 2001 From: Quentin Dupont Date: Wed, 17 Jan 2024 11:27:07 +0100 Subject: [PATCH] add test --- mrp_food/tests/test_mrp_food_bom.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/mrp_food/tests/test_mrp_food_bom.py b/mrp_food/tests/test_mrp_food_bom.py index 5b9ac2e3..0adfeefe 100644 --- a/mrp_food/tests/test_mrp_food_bom.py +++ b/mrp_food/tests/test_mrp_food_bom.py @@ -10,11 +10,14 @@ class TestMrpFoodBom(TransactionCase): def setUp(self): super(TestMrpFoodBom, self).setUp() self.bom_tomato_tart = self.env.ref("mrp_food.demo_bom_tomato_tart") - self.bom_not_seasonal = self.env.ref("mrp_food.demo_bom_lines_not_seasonal") + self.bom_lines_not_seasonal = self.env.ref( + "mrp_food.demo_bom_lines_not_seasonal" + ) self.bom_tomato_tart_tomatoes = self.env.ref( "mrp_food.demo_bom_tomato_tart_line_tomatoes" ) self.seasonality_all = self.env.ref("mrp_food.demo_seasonality_all_season") + self.seasonality_line_all = self.env.ref("mrp_food.demo_seasonality_all_line") self.peach = self.env.ref("mrp_food.demo_product_peach_no_season") def test_01_bom_price_subtotal_line(self): @@ -59,10 +62,22 @@ def test_04_bom_seasonality(self): ) def test_05_bom_lines_seasonalities(self): - self.assertEqual(self.bom_not_seasonal.products_not_in_season, "Chickpea.") - self.bom_not_seasonal.write( + self.assertEqual( + self.bom_lines_not_seasonal.products_not_in_season, "Chickpea." + ) + self.bom_lines_not_seasonal.write( {"bom_line_ids": [(0, 0, {"product_id": self.peach.id, "product_qty": 1})]} ) self.assertEqual( - self.bom_not_seasonal.products_not_in_season, "Chickpea, Peach." + self.bom_lines_not_seasonal.products_not_in_season, "Chickpea, Peach." ) + + def test_06_check_update_seasonality(self): + self.assertEqual(self.bom_lines_not_seasonal.is_bom_seasonal, True) + self.env["mrp.bom"].cron_seasonality_bom_check_state() + # Check without any changes + self.assertEqual(self.bom_lines_not_seasonal.is_bom_seasonal, True) + # "All season" became not seasonal + self.seasonality_line_all.write({"date_end": "2000-01-02"}) + self.env["mrp.bom"].cron_seasonality_bom_check_state() + self.assertEqual(self.bom_lines_not_seasonal.is_bom_seasonal, False)