Created
October 22, 2014 02:42
-
-
Save cerivera/fbe07a3deb28f6a474c5 to your computer and use it in GitHub Desktop.
test generating a real XML request
This file contains hidden or 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
def test_xml_basic_building(): | |
d = { | |
'EAI': '11111111', | |
'DBHost': 'BISTEST', | |
'ReferenceId': 'user12345', | |
'Request xmlns="http://www.example.com/WebDelivery" version="1.0"': { | |
'Products': { | |
'PremierProfile': { | |
'Subscriber': { | |
'OpInitials': 'CR', | |
'SubCode': '0123456' | |
}, | |
'OutputType': { | |
'XML': { | |
'Verbose': 'Y' | |
} | |
} | |
} | |
} | |
} | |
} | |
xml_out = dicttoxml.dicttoxml(d, attr_type=False, custom_root='NetRequest xmlns="http://www.example.com/NetRequest" xmlns:xsi="http://www.example.org/2001/XMLSchema" xsi:schemaLocation="http://www.example.com/NetRequest NetRequest.xsd"') | |
assert xml_out == _uglify_xml(""" | |
<?xml version="1.0" encoding="UTF-8" ?> | |
<NetRequest xmlns="http://www.example.com/NetRequest" xmlns:xsi="http://www.example.org/2001/XMLSchema" xsi:schemaLocation="http://www.example.com/NetRequest NetRequest.xsd"> | |
<EAI>11111111</EAI> | |
<DBHost>BISTEST</DBHost> | |
<ReferenceId>user12345</ReferenceId> | |
<Request xmlns="http://www.example.com/WebDelivery" version="1.0"> | |
<Products> | |
<PremierProfile> | |
<Subscriber> | |
<SubCode>0123456</SubCode> | |
<OpInitials>CR</OpInitials> | |
</Subscriber> | |
<OutputType> | |
<XML> | |
<Verbose>Y</Verbose> | |
</XML> | |
</OutputType> | |
</PremierProfile> | |
</Products> | |
</Request> | |
</NetRequest>""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment