From 40a5904d9b2734b2c667119cfdb396059d16a8cf Mon Sep 17 00:00:00 2001 From: eLBati Date: Tue, 28 Nov 2023 18:22:22 +0100 Subject: [PATCH] Use assertAlmostEqual for fields which could be result of computation Rif https://github.com/OCA/l10n-italy/pull/3681#discussion_r1403980080 --- .../tests/test_import_fatturapa_xml.py | 18 +++++++++--------- l10n_it_ricevute_bancarie/tests/test_riba.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py index 2c6da7820602..def000107567 100644 --- a/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py +++ b/l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py @@ -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) @@ -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)) @@ -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) @@ -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) @@ -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) @@ -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): diff --git a/l10n_it_ricevute_bancarie/tests/test_riba.py b/l10n_it_ricevute_bancarie/tests/test_riba.py index a69031a471c4..edbef4c769b0 100644 --- a/l10n_it_ricevute_bancarie/tests/test_riba.py +++ b/l10n_it_ricevute_bancarie/tests/test_riba.py @@ -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