[Erp5-report] r39267 yusei - /erp5/trunk/products/ERP5/tests/testRoundingTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Oct 18 05:19:45 CEST 2010


Author: yusei
Date: Mon Oct 18 05:19:44 2010
New Revision: 39267

URL: http://svn.erp5.org?rev=39267&view=rev
Log:
Add a test for RoundingModel.roundValue method.

Modified:
    erp5/trunk/products/ERP5/tests/testRoundingTool.py

Modified: erp5/trunk/products/ERP5/tests/testRoundingTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testRoundingTool.py?rev=39267&r1=39266&r2=39267&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testRoundingTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testRoundingTool.py [utf8] Mon Oct 18 05:19:44 2010
@@ -56,6 +56,30 @@ class TestRoundingTool(ERP5TypeTestCase)
     transaction.commit()
     self.tic()
 
+  def testRoundValueMethod(self):
+    """
+    Test rounding method
+    """
+    rounding_tool = self.portal.portal_roundings
+    rounding_model = rounding_tool.newContent(portal_type='Rounding Model')
+    rounding_model.edit(decimal_rounding_option='ROUND_HALF_UP')
+
+    rounding_model.edit(precision=0.01)
+    self.assertEqual(rounding_model.roundValue(12.344), 12.34)
+    self.assertEqual(rounding_model.roundValue(12.355), 12.36)
+    rounding_model.edit(precision=0.1)
+    self.assertEqual(rounding_model.roundValue(12.34), 12.3)
+    self.assertEqual(rounding_model.roundValue(12.35), 12.4)
+    rounding_model.edit(precision=1.0)
+    self.assertEqual(rounding_model.roundValue(1.1), 1)
+    self.assertEqual(rounding_model.roundValue(1.5), 2)
+    rounding_model.edit(precision=10.0)
+    self.assertEqual(rounding_model.roundValue(1.1), 0)
+    self.assertEqual(rounding_model.roundValue(5.0), 10)
+    rounding_model.edit(precision=100.0)
+    self.assertEqual(rounding_model.roundValue(132), 100)
+    self.assertEqual(rounding_model.roundValue(150), 200)
+
   def testBasicRounding(self):
     """
     Test basic features of rounding tool




More information about the Erp5-report mailing list