Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

Commit 90fe1c6

Browse files
committed
[FIX]fix test case for onchange_attribute
1 parent d3497ac commit 90fe1c6

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

product_configurator/tests/test_product_config.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,36 @@ def test_18_onchange_attribute(self):
552552
self.attribute_vals_2.id])],
553553
'domain_id': self.productConfigDomainId.id
554554
})
555-
# with self.assertRaises(ValidationError):
556-
# config_line.onchange_attribute()
557-
558-
# self.assertFalse(
559-
# config_line.value_ids,
560-
# 'Error: If value_ids True\
561-
# Method: onchange_attribute()'
562-
# )
555+
556+
line_vals = {
557+
'product_tmpl_id': self.product_tmpl_id.id,
558+
'attribute_line_id': self.attributeLine1.id,
559+
'value_ids': [(6, 0, [
560+
self.attribute_vals_1.id,
561+
self.attribute_vals_2.id])],
562+
'domain_id': self.productConfigDomainId.id
563+
}
564+
order_line_obj = self.env['product.config.line']
565+
specs = order_line_obj._onchange_spec()
566+
updates = order_line_obj.onchange(
567+
line_vals, ['attribute_line_id'], specs
568+
)
569+
values = updates.get('value', {})
570+
for name, val in values.items():
571+
if isinstance(val, tuple):
572+
values[name] = val[0]
573+
574+
self.assertFalse(
575+
values.get('domain_id'),
576+
'Error: If value_ids True\
577+
Method: onchange_attribute()'
578+
)
579+
self.assertEqual(
580+
values.get('value_ids')[0],
581+
(5,),
582+
'Error: If value_ids True\
583+
Method: onchange_attribute()'
584+
)
563585

564586
def test_19_eval(self):
565587
self.attr_color.custom_type = 'binary'

0 commit comments

Comments
 (0)