Skip to content

Commit d2bd52e

Browse files
rlimaecodalonsod
andcommitted
[IMP] product_assortment: Add test for assortment update
Co-Authored-By: David Alonso <david.alonso@solvos.es>
1 parent d54357c commit d2bd52e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

product_assortment/tests/test_product_assortment.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ def test_product_assortment_view(self):
101101
res = self.assortment.show_products()
102102
self.assertEqual(res["domain"], [("id", "in", [included_product.id])])
103103

104+
def test_product_assortment_view_with_black_list(self):
105+
excluded_product = self.env.ref("product.product_product_7")
106+
self.assortment.write(
107+
{
108+
"blacklist_product_ids": [(4, excluded_product.id)],
109+
}
110+
)
111+
res = self.assortment.show_products()
112+
self.assertEqual(res["domain"], [("id", "not in", excluded_product.ids)])
113+
114+
def test_product_assortment_mixed_view(self):
115+
included_product = self.env.ref("product.product_product_7")
116+
excluded_product = self.env.ref("product.product_product_2")
117+
self.assortment.write(
118+
{
119+
"whitelist_product_ids": [(4, included_product.id)],
120+
"blacklist_product_ids": [(4, excluded_product.id)],
121+
}
122+
)
123+
res = self.assortment.show_products()
124+
self.assertEqual(res["domain"][1], ("id", "not in", excluded_product.ids))
125+
self.assertEqual(res["domain"][2], ("id", "in", included_product.ids))
126+
104127
def test_record_count(self):
105128
self.assertEqual(self.filter_no_assortment.record_count, 0)
106129

@@ -127,6 +150,18 @@ def test_assortment_with_partner_domain(self):
127150
)
128151
self.assertEqual(assortment.all_partner_ids, self.partner + self.partner2)
129152

153+
def test_assortment_update_with_multiple_partner(self):
154+
assortment = self.filter_obj.with_context(product_assortment=True).create(
155+
{
156+
"name": "Test Assortment multiple partner",
157+
"partner_domain": "[('name', '=', 'Test partner updated')]",
158+
"partner_ids": [(4, self.partner.id), (4, self.partner2.id)],
159+
}
160+
)
161+
self.partner.name = "Test partner updated"
162+
self.assertIn(assortment.id, self.partner.applied_assortment_ids.ids)
163+
self.assertEqual(assortment.all_partner_ids, self.partner + self.partner2)
164+
130165
def test_assortment_with_black_list_product_domain(self):
131166
excluded_product = self.env.ref("product.product_product_7")
132167
assortment = self.filter_obj.with_context(product_assortment=True).create(

0 commit comments

Comments
 (0)