From a81fe79bb6e8215725905b35c7c7f53437dc8613 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 18 Aug 2020 17:16:45 +0200 Subject: [PATCH] [IMP] account_banking_sepa_direct_debit: Ease inheritance in tests - Unfold SDD test in 2 classes: the base with initialization + the other with tests - Internal variable for parametrizing the chart template to load --- .../__manifest__.py | 2 +- .../tests/test_sdd.py | 52 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/account_banking_sepa_direct_debit/__manifest__.py b/account_banking_sepa_direct_debit/__manifest__.py index 4dec981a3..4ea64c687 100644 --- a/account_banking_sepa_direct_debit/__manifest__.py +++ b/account_banking_sepa_direct_debit/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Account Banking SEPA Direct Debit", "summary": "Create SEPA files for Direct Debit", - "version": "13.0.1.0.0", + "version": "13.0.1.0.1", "license": "AGPL-3", "author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/bank-payment", diff --git a/account_banking_sepa_direct_debit/tests/test_sdd.py b/account_banking_sepa_direct_debit/tests/test_sdd.py index 97de426d0..8d33bf3e7 100644 --- a/account_banking_sepa_direct_debit/tests/test_sdd.py +++ b/account_banking_sepa_direct_debit/tests/test_sdd.py @@ -1,5 +1,5 @@ # Copyright 2016 Akretion (Alexis de Lattre ) -# Copyright 2018 Tecnativa - Pedro M. Baeza +# Copyright 2018-2020 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import base64 @@ -11,9 +11,11 @@ from odoo.tests import common from odoo.tools import float_compare -class TestSDD(common.HttpCase): +class TestSDDBase(common.HttpCase): + _chart_template_xml_id = "l10n_generic_coa.configurable_chart_template" + def setUp(self): - super(TestSDD, self).setUp() + super().setUp() self.company = self.env["res.company"] self.account_model = self.env["account.account"] self.journal_model = self.env["account.journal"] @@ -42,11 +44,7 @@ class TestSDD(common.HttpCase): ) self.partner_agrolait.company_id = self.main_company.id self.partner_c2c.company_id = self.main_company.id - - self.env.ref( - "l10n_generic_coa.configurable_chart_template" - ).try_loading_for_current_company() - + self.env.ref(self._chart_template_xml_id).try_loading_for_current_company() self.account_revenue = self.account_model.search( [ ( @@ -125,22 +123,6 @@ class TestSDD(common.HttpCase): # Trigger the recompute of account type on res.partner.bank self.partner_bank_model.search([])._compute_acc_type() - def test_pain_001_02(self): - self.payment_mode.payment_method_id.pain_version = "pain.008.001.02" - self.check_sdd() - - def test_pain_003_02(self): - self.payment_mode.payment_method_id.pain_version = "pain.008.003.02" - self.check_sdd() - - def test_pain_001_03(self): - self.payment_mode.payment_method_id.pain_version = "pain.008.001.03" - self.check_sdd() - - def test_pain_001_04(self): - self.payment_mode.payment_method_id.pain_version = "pain.008.001.04" - self.check_sdd() - def check_sdd(self): self.mandate2.recurrent_sequence_type = "first" invoice1 = self.create_invoice(self.partner_agrolait.id, self.mandate2, 42.0) @@ -228,7 +210,7 @@ class TestSDD(common.HttpCase): self.assertEqual(self.mandate2.recurrent_sequence_type, "recurring") return - def create_invoice(self, partner_id, mandate, price_unit, type="out_invoice"): + def create_invoice(self, partner_id, mandate, price_unit, inv_type="out_invoice"): invoice_vals = [ ( 0, @@ -246,7 +228,7 @@ class TestSDD(common.HttpCase): "partner_id": partner_id, "reference_type": "none", "currency_id": self.env.ref("base.EUR").id, - "type": type, + "type": inv_type, "date": fields.Date.today(), "payment_mode_id": self.payment_mode.id, "mandate_id": mandate.id, @@ -255,3 +237,21 @@ class TestSDD(common.HttpCase): ) invoice.post() return invoice + + +class TestSDD(TestSDDBase): + def test_pain_001_02(self): + self.payment_mode.payment_method_id.pain_version = "pain.008.001.02" + self.check_sdd() + + def test_pain_003_02(self): + self.payment_mode.payment_method_id.pain_version = "pain.008.003.02" + self.check_sdd() + + def test_pain_001_03(self): + self.payment_mode.payment_method_id.pain_version = "pain.008.001.03" + self.check_sdd() + + def test_pain_001_04(self): + self.payment_mode.payment_method_id.pain_version = "pain.008.001.04" + self.check_sdd()