|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
Suds SAX Document unit tests.
|
|
|
|
|
|
Implemented using the 'pytest' testing framework.
|
|
|
|
|
|
"""
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
import testutils
|
|
|
testutils.run_using_pytest(globals())
|
|
|
|
|
|
import suds
|
|
|
from suds.sax.document import Document
|
|
|
import suds.sax.parser
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
class TestStringRepresentation:
|
|
|
|
|
|
@staticmethod
|
|
|
def create_test_document():
|
|
|
input_data = suds.byte_str("""\
|
|
|
<xsd:element name="ZuZu">
|
|
|
<xsd:simpleType>
|
|
|
<xsd:restriction base="xsd:string">
|
|
|
<xsd:enumeration value="alfa"/>
|
|
|
<xsd:enumeration value="beta"/>
|
|
|
<xsd:enumeration value="gamma"/>
|
|
|
</xsd:restriction>
|
|
|
</xsd:simpleType>
|
|
|
</xsd:element>""")
|
|
|
document = suds.sax.parser.Parser().parse(suds.BytesIO(input_data))
|
|
|
assert document.__class__ is Document
|
|
|
return document
|
|
|
|
|
|
def test_convert_to_unicode(self):
|
|
|
document = self.create_test_document()
|
|
|
expected = document.str()
|
|
|
assert str(document) == expected
|
|
|
|
|
|
def test_plain_method(self):
|
|
|
document = self.create_test_document()
|
|
|
expected = Document.DECL + document.root().plain()
|
|
|
result = document.plain()
|
|
|
assert result == expected
|
|
|
|
|
|
def test_str_method(self):
|
|
|
document = self.create_test_document()
|
|
|
expected = Document.DECL + "\n" + document.root().str()
|
|
|
result = document.str()
|
|
|
assert result == expected
|
|
|
|
|
|
def test_xml_declaration(self):
|
|
|
assert Document.DECL == '<?xml version="1.0" encoding="UTF-8"?>'
|
|
|
|