Skip to content

Commit

Permalink
edi_exchange_template_oca: add nswrapper test
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk authored and john-herholz-dt committed Jun 28, 2024
1 parent 1772469 commit fd381f2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions edi_exchange_template_oca/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import test_edi_backend_output
from . import test_nswrapper
58 changes: 58 additions & 0 deletions edi_exchange_template_oca/tests/test_nswrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2022 Camptocamp SA
# @author Simone Orsi <[email protected]>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo.tests.common import SavepointCase
from odoo.tools import pycompat

from ..utils import xml_purge_nswrapper

ORDER_RESP_WRAPPER_TMPL = """
<OrderResponse
xmlns="urn:oasis:names:specification:ubl:schema:xsd:OrderResponse-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
>
<cbc:UBLVersionID>2.2</cbc:UBLVersionID>
{}
</OrderResponse>
"""

XML1 = """
<nswrapper xmlns:foo="http://www.unece.org/cefact/Foo">
<foo:LovelyNamespacedElement />
</nswrapper>
"""

XML2 = """
<nswrapper
xmlns="urn:oasis:names:specification:ubl:schema:xsd:OrderResponse-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
>
<cac:Party>
<cbc:EndpointID>7302347231111</cbc:EndpointID>
<cac:PartyIdentification>
<cbc:ID>7300070011115</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name>Moderna Produkter AB</cbc:Name>
</cac:PartyName>
</cac:Party>
</nswrapper>
"""


class TestNSWrapper(SavepointCase):
maxDiff = None

def test_purge1(self):
res = xml_purge_nswrapper(XML1)
self.assertNotIn("nswrapper", pycompat.to_text(res))

def test_purge2(self):
res = xml_purge_nswrapper(XML2)
self.assertNotIn("nswrapper", pycompat.to_text(res))

def test_purge3(self):
res = xml_purge_nswrapper(ORDER_RESP_WRAPPER_TMPL.format(XML2))
self.assertNotIn("nswrapper", pycompat.to_text(res))

0 comments on commit fd381f2

Please sign in to comment.