Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinDupont committed Jan 17, 2024
1 parent ade8fd2 commit 6e10e74
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions mrp_food/tests/test_mrp_food_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit 6e10e74

Please sign in to comment.