Skip to content

Commit

Permalink
[FIX] product_cost_usd: use float_compare in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
suniagajose authored and nhomar committed Oct 20, 2017
1 parent 090cfaf commit dddff71
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions product_cost_usd/tests/test_standard_price_usd.py
Expand Up @@ -4,7 +4,7 @@

from odoo.tests.common import TransactionCase
from odoo.exceptions import ValidationError
from odoo.tools import float_round
from odoo.tools import float_round, float_compare
from odoo import fields


Expand Down Expand Up @@ -45,7 +45,9 @@ def test_01(self):
expected_price = float_round(
product.standard_price_usd * 1.15,
precision_rounding=self.usd.rounding)
self.assertEqual(product.price, expected_price)
self.assertEqual(
float_compare(product.price, expected_price, precision_digits=2),
0, "Product price should be %s" % product.price)

def test_02(self):
""" Test a MXN pricelist based on cost in usd. """
Expand All @@ -55,7 +57,9 @@ def test_02(self):
expected_price = float_round(
(product.standard_price_usd * 1.15) * mxn_rate,
precision_rounding=self.mxn.rounding)
self.assertEqual(product.price, expected_price)
self.assertEqual(
float_compare(product.price, expected_price, precision_digits=2),
0, "Product price should be %s" % product.price)

def test_03(self):
""" Test constraint check_cost_and_price. """
Expand Down Expand Up @@ -100,8 +104,9 @@ def test_sale_margin(self):
margin = float_round(
expected_price - expected_cost,
precision_rounding=self.mxn.rounding)
msg = "Sale order margin should be %s" % margin
self.assertEqual(sale_order.margin, margin, msg)
self.assertEqual(
float_compare(sale_order.margin, margin, precision_digits=2),
0, "Sale order margin should be %s" % margin)

def test_sale_margin_normal(self):
""" Test the sale margin module using a pricelist without cost in
Expand Down

0 comments on commit dddff71

Please sign in to comment.