Olivier Dony (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-float-rounding-odo into 
lp:openobject-addons.

Requested reviews:
  Vo Minh Thu (OpenERP) (vmt-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-float-rounding-odo/+merge/86557

This is the corresponding addons branch for the server branch implementing the 
new style of float rounding 
lp:~openerp-dev/openobject-server/trunk-float-rounding-odo

This branch contains a spot fix for one YAML test that is failing after the 
introduction of the new rounding, because it compares floats using '=='. I 
changed it to use the new float_compare() method.

Other cases of float comparisons have not been updated as they are not 
failing... but should presumably be changed in the future to do something 
similar.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-float-rounding-odo/+merge/86557
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-float-rounding-odo.
=== modified file 'mrp/test/order_process.yml'
--- mrp/test/order_process.yml	2011-12-12 12:25:01 +0000
+++ mrp/test/order_process.yml	2011-12-21 12:42:33 +0000
@@ -54,6 +54,9 @@
   Now I check workcenter lines.
 -
   !python {model: mrp.production}: |
+    from tools import float_compare
+    def assert_equals(value1, value2, msg, float_compare=float_compare):
+        assert float_compare(value1, value2, precision_digits=2) == 0, msg
     order = self.browse(cr, uid, ref("mrp_production_shelf100cm"), context=context)
     assert len(order.workcenter_lines), "Workcenter lines are not generated proper."
     for line in order.workcenter_lines:
@@ -63,25 +66,20 @@
         d, m = divmod(factor, wc.capacity_per_cycle)
         cycle = (d + (m and 1.0 or 0.0))
         if line.name == "Short time assembly - Assembly Section":
-            assert line.sequence, "Sequence is not correspond: %s" % (line.name)
-            assert line.cycle == (4*cycle), "Cycle is not correspond: %s" % (line.name)
-            assert line.hour == (2*cycle*4 + hours), "Hours is not correspond: %s"% (line.name)
+            assert_equals(line.cycle, (4*cycle), "Computed cycles mismatch: %s" % (line.name))
+            assert_equals(line.hour, (2*cycle*4 + hours), "Computed hours mismatch: %s"% (line.name))
         elif line.name == "Short time assembly - Rear Panel SHE100":
-            assert line.sequence, "Sequence is not correspond: %s" % (line.name)
-            assert line.cycle == (1*cycle), "Cycle is not correspond: %s" % (line.name)
-            assert line.hour == (2*cycle + hours), "Hours is not correspond: %s"% (line.name)
+            assert_equals(line.cycle, (1*cycle), "Computed cycles mismatch: %s" % (line.name))
+            assert_equals(line.hour, (2*cycle + hours), "Computed hours mismatch: %s"% (line.name))
         elif line.name == "long time assembly - Shelf of 100cm":
-            assert line.sequence, "Sequence is not correspond: %s" % (line.name)
-            assert line.cycle == (2*cycle), "Cycle is not correspond: %s" % (line.name)
-            assert line.hour == (5*cycle + hours), "Hours is not correspond: %s"% (line.name)
+            assert_equals(line.cycle, (2*cycle), "Computed cycles mismatch: %s" % (line.name))
+            assert_equals(line.hour, (5*cycle + hours), "Computed hours mismatch: %s"% (line.name))
         elif line.name == "Testing - Shelf of 100cm":
-            assert line.sequence, "Sequence is not correspond: %s" % (line.name)
-            assert line.cycle == (1*cycle), "Cycle is not correspond: %s" % (line.name)
-            assert line.hour == (1*cycle + hours), "Hours is not correspond: %s"% (line.name)
+            assert_equals(line.cycle, (1*cycle), "Computed cycles mismatch: %s" % (line.name))
+            assert_equals(line.hour, (1*cycle + hours), "Computed hours mismatch: %s"% (line.name))
         elif line.name == "Packing - Shelf of 100cm":
-            assert line.sequence, "Sequence is not correspond: %s" % (line.name)
-            assert line.cycle == (1*cycle), "Cycle is not correspond: %s" % (line.name)
-            assert line.hour == (0.5*cycle + hours), "Hours is not correspond: %s"% (line.name)
+            assert_equals(line.cycle, (1*cycle), "Computed cycles mismatch: %s" % (line.name))
+            assert_equals(line.hour, (0.5*cycle + hours), "Computed hours mismatch: %s"% (line.name))
         else:
             raise AssertionError('unknown workcenter line: %s' % line)
 -

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to