changeset ad089e5c7622 in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset;node=ad089e5c7622
description:
        Add test for payment term with repeating decimal and invalid ratio

        issue8966
        review265001002
diffstat:

 tests/test_account_invoice.py |  40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diffs (57 lines):

diff -r ff5a76bbdbc8 -r ad089e5c7622 tests/test_account_invoice.py
--- a/tests/test_account_invoice.py     Mon Jan 20 11:06:23 2020 +0100
+++ b/tests/test_account_invoice.py     Mon Jan 20 11:07:12 2020 +0100
@@ -10,6 +10,7 @@
 from trytond.tests.test_tryton import doctest_checker
 from trytond.pool import Pool
 
+from ..exceptions import PaymentTermValidationError
 from trytond.modules.currency.tests import create_currency
 
 
@@ -99,6 +100,45 @@
                 ])
 
     @with_transaction()
+    def test_payment_term_with_repeating_decimal(self):
+        "Test payment_term with repeating decimal"
+        pool = Pool()
+        PaymentTerm = pool.get('account.invoice.payment_term')
+
+        PaymentTerm.create([{
+                    'name': "Repeating Decimal",
+                    'lines': [
+                        ('create', [{
+                                    'type': 'percent',
+                                    'divisor': Decimal(3),
+                                    'ratio': Decimal('0.3333333333'),
+                                    }, {
+                                    'type': 'remainder',
+                                    }]),
+                        ],
+                    }])
+
+    @with_transaction()
+    def test_payment_term_with_invalid_ratio_divisor(self):
+        "Test payment_term with invalid ratio and divisor"
+        pool = Pool()
+        PaymentTerm = pool.get('account.invoice.payment_term')
+
+        with self.assertRaises(PaymentTermValidationError):
+            PaymentTerm.create([{
+                        'name': "Invalid ratio and divisor",
+                        'lines': [
+                            ('create', [{
+                                        'type': 'percent',
+                                        'divisor': Decimal(2),
+                                        'ratio': Decimal('0.4'),
+                                        }, {
+                                        'type': 'remainder',
+                                        }]),
+                            ],
+                        }])
+
+    @with_transaction()
     def test_payment_term_with_empty_value(self):
         'Test payment_term with empty'
         pool = Pool()

Reply via email to