From 8fcec94b5462661e6a8137c0f5e7a9757d073a93 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Mon, 18 Nov 2024 17:52:13 +0100 Subject: [PATCH] edi_xml: improve base test class --- edi_xml_oca/tests/common.py | 14 ++++++++++++++ edi_xml_oca/tests/test_xml.py | 15 ++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/edi_xml_oca/tests/common.py b/edi_xml_oca/tests/common.py index 0f562e746b..d579e80304 100644 --- a/edi_xml_oca/tests/common.py +++ b/edi_xml_oca/tests/common.py @@ -6,6 +6,8 @@ import xmlunittest +from odoo.addons.component.tests.common import SavepointComponentCase + class XMLTestCaseMixin(xmlunittest.XmlTestMixin): def _dev_write_example_file(self, test_file, filename, content): @@ -22,3 +24,15 @@ def read_test_file(self, filename): path = os.path.join(os.path.dirname(__file__), "examples", filename) with open(path, "r") as thefile: return thefile.read() + + +class XMLComponentTestCase(SavepointComponentCase, XMLTestCaseMixin): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.backend = cls.env.ref("edi_oca.demo_edi_backend") + cls.handler = cls.backend._find_component( + cls.backend._name, + ["edi.xml"], + work_ctx={"schema_path": "edi_xml_oca:tests/fixtures/Test.xsd"}, + ) diff --git a/edi_xml_oca/tests/test_xml.py b/edi_xml_oca/tests/test_xml.py index 8e454e7190..75617d5b28 100644 --- a/edi_xml_oca/tests/test_xml.py +++ b/edi_xml_oca/tests/test_xml.py @@ -2,9 +2,8 @@ # @author: Simone Orsi # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -from odoo.addons.component.tests.common import SavepointComponentCase -from .common import XMLTestCaseMixin +from .common import XMLComponentTestCase TEST_XML = """