forked from OCA/edi-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edi_exchange_template_oca: add nswrapper test
- Loading branch information
1 parent
1772469
commit fd381f2
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import test_edi_backend_output | ||
from . import test_nswrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |