Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
pilarvargas-tecnativa committed Jan 24, 2024
1 parent cb2e50d commit 0e8d0ed
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions sale_loyalty_multi_gift/tests/test_sale_loyalty_multi_gift.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,60 @@ def test_04_test_sale_coupon_test_multi_gift(self):
self.assertEqual(2, discount_line_product_2.product_uom_qty)
self.assertEqual(3, discount_line_product_4.product_uom_qty)
self.assertFalse(discount_line_product_3)

def test_delete_01_loyalty_multi_gift_ids(self):
# Initially the promotion has 2 gifts
gift_options_qty = len(
self.loyalty_program_form.reward_ids[0].loyalty_multi_gift_ids
)
self.assertEqual(gift_options_qty, 2)
# By modifying the amount of gifts (+1) by typing in the field from reward_ids
# (loyalty.reward), the amount of gifts increases by 1, in total 3.
self.loyalty_program_form.reward_ids[0].write(
{
"loyalty_multi_gift_ids": [
(
0,
0,
{
"reward_product_ids": [(4, self.product_3.id)],
"reward_product_quantity": 1,
},
)
],
}
)
gift_options_qty = len(
self.loyalty_program_form.reward_ids[0].loyalty_multi_gift_ids
)
self.assertEqual(gift_options_qty, 3)
# This will fail. When modifying the amount of gifts from the promotion (as it
# is done in the form) if we increase that gift in 1 more, we should have in total
# 4 gifts, the previous 3 + 1, in this case 2 records are being created for the
# same gift and instead of having 4, there will be 5 (failure).
self.loyalty_program_form.write(
{
"reward_ids": [
(
1,
self.loyalty_program_form.reward_ids[0].id,
{
"loyalty_multi_gift_ids": [
(
0,
0,
{
"reward_product_ids": [(4, self.product_3.id)],
"reward_product_quantity": 1,
},
)
],
},
)
],
}
)
gift_options_qty = len(
self.loyalty_program_form.reward_ids[0].loyalty_multi_gift_ids
)
self.assertEqual(gift_options_qty, 4)

0 comments on commit 0e8d0ed

Please sign in to comment.