Skip to content

Commit

Permalink
Use assertAlmostEqual for fields which could be result of computation
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati authored and odooNextev committed Jan 8, 2024
1 parent 9985016 commit 40a5904
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_00_xml_import(self):
welfare_found = False
for line in invoice.invoice_line_ids:
if line.product_id.id == self.service.id:
self.assertEqual(line.price_unit, 3)
self.assertAlmostEqual(line.price_unit, 3)
welfare_found = True
self.assertTrue(welfare_found)
self.assertTrue(len(invoice.e_invoice_line_ids) == 1)
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_04_xml_import(self):
self.assertEqual(invoice.invoice_line_ids[1].tax_ids[0].name, "22% e-bill")
self.assertEqual(invoice.invoice_line_ids[0].tax_ids[0].amount, 22)
self.assertEqual(invoice.invoice_line_ids[1].tax_ids[0].amount, 22)
self.assertEqual(invoice.invoice_line_ids[1].price_unit, 2)
self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 2)
self.assertTrue(len(invoice.e_invoice_line_ids) == 2)
for e_line in invoice.e_invoice_line_ids:
self.assertTrue(e_line.line_number in (1, 2))
Expand Down Expand Up @@ -648,10 +648,10 @@ def test_32_xml_import(self):
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.move_type, "in_refund")
self.assertEqual(invoice.amount_total, 18.3)
self.assertEqual(invoice.invoice_line_ids[0].price_unit, 2.0)
self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 2.0)
self.assertEqual(invoice.invoice_line_ids[0].quantity, 10.0)
self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 20.0)
self.assertEqual(invoice.invoice_line_ids[1].price_unit, -1.0)
self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, -1.0)
self.assertEqual(invoice.invoice_line_ids[1].quantity, 5.0)
self.assertEqual(invoice.invoice_line_ids[1].price_subtotal, -5.0)

Expand All @@ -662,7 +662,7 @@ def test_33_xml_import(self):
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.move_type, "in_refund")
self.assertEqual(round(invoice.amount_total, 2), 24.4)
self.assertEqual(invoice.invoice_line_ids[0].price_unit, 2.0)
self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 2.0)
self.assertEqual(invoice.invoice_line_ids[0].quantity, 10.0)
self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 20.0)
self.assertEqual(invoice.e_invoice_amount_untaxed, -20.0)
Expand Down Expand Up @@ -815,10 +815,10 @@ def test_46_xml_many_zeros(self):
invoice_id = res.get("domain")[0][2][0]
invoice = self.invoice_model.browse(invoice_id)
self.assertEqual(invoice.amount_total, 18.07)
self.assertEqual(invoice.invoice_line_ids[0].price_unit, 18.07)
self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 18.07)
self.assertEqual(invoice.invoice_line_ids[0].quantity, 1.0)
self.assertEqual(invoice.invoice_line_ids[0].price_subtotal, 18.07)
self.assertEqual(invoice.invoice_line_ids[1].price_unit, 16.60)
self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 16.60)
self.assertEqual(invoice.invoice_line_ids[1].quantity, 1.0)
self.assertEqual(invoice.invoice_line_ids[1].price_subtotal, 0.0)

Expand Down Expand Up @@ -1072,9 +1072,9 @@ def test_xml_import_summary_tax_rate(self):
self.assertEqual(invoice.amount_total, 204.16)
self.assertEqual(len(invoice.invoice_line_ids), 2)

self.assertEqual(invoice.invoice_line_ids[0].price_unit, 164.46)
self.assertAlmostEqual(invoice.invoice_line_ids[0].price_unit, 164.46)
self.assertEqual(invoice.invoice_line_ids[0].quantity, 1.0)
self.assertEqual(invoice.invoice_line_ids[1].price_unit, 3.52)
self.assertAlmostEqual(invoice.invoice_line_ids[1].price_unit, 3.52)
self.assertEqual(invoice.invoice_line_ids[1].quantity, 1.0)

def test_e_invoice_field_compute(self):
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_ricevute_bancarie/tests/test_riba.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_add_due_cost(self):
self.invoice.invoice_line_ids[2].product_id.id, self.service_due_cost.id
)
# ---- Test Cost line is equal to 10.00
self.assertEqual(
self.assertAlmostEqual(
(
self.invoice.invoice_line_ids[1].price_unit
+ self.invoice.invoice_line_ids[2].price_unit
Expand Down

0 comments on commit 40a5904

Please sign in to comment.