forked from OCA/edi-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_nswrapper.py
58 lines (49 loc) · 1.86 KB
/
test_nswrapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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 TransactionCase
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(TransactionCase):
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))