From 4ab379ec75c561d6cd3819d99473db8586172112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A0n=20Todorovich?= Date: Tue, 25 Oct 2022 16:38:00 -0300 Subject: [PATCH] [IMP] mrp_bom_attribute_match: assert exception messages --- .../tests/test_mrp_bom_attribute_match.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py b/mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py index 2a88899d9..e6b5b5083 100644 --- a/mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py +++ b/mrp_bom_attribute_match/tests/test_mrp_bom_attribute_match.py @@ -23,7 +23,12 @@ class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase): line_form.component_template_id = self.product_plastic line_form.product_qty = 1 sword_cyan = self.sword_attrs.product_template_value_ids[0] - with self.assertRaises(ValidationError): + with self.assertRaisesRegex( + ValidationError, + r"You cannot use an attribute value for attribute\(s\) .* in the " + r"field “Apply on Variants” as it's the same attribute used in the " + r"field “Match on Attribute” related to the component .*", + ): line_form.bom_product_template_attribute_value_ids.add(sword_cyan) def test_bom_2(self): @@ -42,7 +47,12 @@ class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase): "value_ids": [(4, orchid_attribute_value_id.id)], } ) - with self.assertRaises(UserError): + with self.assertRaisesRegex( + UserError, + r"This product template is used as a component in the BOMs for .* and " + r"attribute\(s\) .* is not present in all such product\(s\), and this " + r"would break the BOM behavior\.", + ): vals = { "attribute_id": smell_attribute.id, "product_tmpl_id": self.product_plastic.id, @@ -52,7 +62,11 @@ class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase): mrp_bom_form = Form(self.env["mrp.bom"]) mrp_bom_form.product_tmpl_id = self.product_sword with mrp_bom_form.bom_line_ids.new() as line_form: - with self.assertRaises(ValidationError): + with self.assertRaisesRegex( + UserError, + r"Some attributes of the dynamic component are not included into " + r"production product attributes\.", + ): line_form.component_template_id = self.product_plastic plastic_smells_like_orchid.unlink() @@ -91,8 +105,10 @@ class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase): # Component skipped mo_form.bom_id = self.bom_id mo_form.product_qty = 1 - with self.assertRaises(ValidationError): - # Some attributes of the dynamic component are not included into ... + with self.assertRaisesRegex( + ValidationError, + r"Some attributes of the dynamic component are not included into .+", + ): self.mo_sword = mo_form.save() def test_manufacturing_order_4(self): @@ -154,5 +170,5 @@ class TestMrpAttachmentMgmt(TestMrpAttachmentMgmtBase): "product_qty": 1.0, } ) - with self.assertRaises(UserError): + with self.assertRaisesRegex(UserError, r"Recursion error! .+"): test_bom_3.explode(self.product_9, 1)