diff --git a/tests/test_currency.py b/tests/test_currency.py index 23abb5fa32..10cc6c88fc 100644 --- a/tests/test_currency.py +++ b/tests/test_currency.py @@ -86,6 +86,39 @@ class CurrencyTestCase(ModuleTestCase): 'date': today, }) + @with_transaction() + def test_round(self): + "Test simple round" + cu = create_currency('cu') + cu.rounding = Decimal('0.001') + cu.digits = 3 + cu.save() + + rounded = cu.round(Decimal('1.2345678')) + + self.assertEqual(rounded, Decimal('1.235')) + + @with_transaction() + def test_round_non_unity(self): + "Test round with non unity" + cu = create_currency('cu') + cu.rounding = Decimal('0.02') + cu.digits = 2 + cu.save() + + rounded = cu.round(Decimal('1.2345')) + + self.assertEqual(rounded, Decimal('1.24')) + + @with_transaction() + def test_round_big_number(self): + "Test rounding big number" + cu = create_currency('cu') + + rounded = cu.round(Decimal('1E50')) + + self.assertEqual(rounded, Decimal('1E50')) + @with_transaction() def test_compute_simple(self): 'Simple conversion'