summaryrefslogtreecommitdiff
path: root/tests/test_program_rules.py
diff options
context:
space:
mode:
authorRomain Derie <rde@odoo.com>2017-12-15 16:05:02 +0100
committerRomain Derie <rde@odoo.com>2018-02-23 18:37:20 +0100
commitc69778fe6f0c462f7cc1acfb54dea28604725b18 (patch)
tree4801955c7efb744e2d84c1b4dc528341354b87ae /tests/test_program_rules.py
parentef5d056403f11b48e42c1c2b63a2cb061e1c8ae9 (diff)
[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
Diffstat (limited to 'tests/test_program_rules.py')
-rw-r--r--tests/test_program_rules.py17
1 files changed, 14 insertions, 3 deletions
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