From c69778fe6f0c462f7cc1acfb54dea28604725b18 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 15 Dec 2017 16:05:02 +0100 Subject: [IMP] sale_coupon, website_sale_coupon: add tests Commit a42c27f99e0061b7c4f recently fixed some bugs on sale_coupon. This commit add some tests to be sure theses bugs are fixed and won't appear again. This closes #1744 --- tests/test_program_rules.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tests/test_program_rules.py') diff --git a/tests/test_program_rules.py b/tests/test_program_rules.py index 17018dd49fd..181b5adb07e 100644 --- a/tests/test_program_rules.py +++ b/tests/test_program_rules.py @@ -55,7 +55,7 @@ class TestProgramRules(TestSaleCouponCommon): # Test case: Based on the minimum purchased self.immediate_promotion_program.write({ - 'rule_minimum_amount': 1000.0, + 'rule_minimum_amount': 1006, 'rule_minimum_amount_tax_inclusion': 'tax_excluded' }) @@ -81,7 +81,7 @@ class TestProgramRules(TestSaleCouponCommon): order.write({'order_line': [ (0, False, { 'product_id': self.product_A.id, - 'name': '1 Product A', + 'name': '10 Product A', 'product_uom': self.uom_unit.id, 'product_uom_qty': 10.0, }), @@ -93,7 +93,18 @@ class TestProgramRules(TestSaleCouponCommon): }) ]}) order.recompute_coupon_lines() - self.assertEqual(len(order.order_line.ids), 3, "The promo offert should have been applied as the purchased amount is enough") + # 10*100 + 5 = 1005 + self.assertEqual(len(order.order_line.ids), 2, "The promo offert should not be applied as the purchased amount is not enough") + + self.immediate_promotion_program.rule_minimum_amount = 1005 + order.recompute_coupon_lines() + self.assertEqual(len(order.order_line.ids), 3, "The promo offert should be applied as the purchased amount is now enough") + + # 10*(100*1.15) + (5*1.15) = 10*115 + 5.75 = 1155.75 + self.immediate_promotion_program.rule_minimum_amount = 1006 + self.immediate_promotion_program.rule_minimum_amount_tax_inclusion = 'tax_included' + order.recompute_coupon_lines() + self.assertEqual(len(order.order_line.ids), 3, "The promo offert should be applied as the initial amount required is now tax included") def test_program_rules_validity_dates_and_uses(self): # Test case: Based on the validity dates and the number of allowed uses -- cgit v1.2.3