Ejemplo n.º 1
0
    def test_xml_element_builder_many_attributes_nested_element_content(self):
        element_str = str(XmlElementBuilder(
            "root",
            attributes={
                "attrb1": "value",
                "attrb2": "value"
            },
            content=[
                XmlElementBuilder(
                    "child",
                    content=[
                        XmlElementBuilder("grandchild")
                    ]
                )
            ]
        ))

        expected_str = """<root
    attrb1="value"
    attrb2="value">
    <child>
        <grandchild />
    </child>
</root>
"""
        self.assertEqual(expected_str, element_str)
Ejemplo n.º 2
0
    def test_xml_element_builder_no_attributes_element_content(self):

        element_str = str(XmlElementBuilder(
            "root",
            attributes=None,
            content=[
                XmlElementBuilder("child")
            ]
        ))

        expected_str = """<root>
    <child />
</root>
"""
        self.assertEqual(expected_str, element_str)
Ejemplo n.º 3
0
    def test_xml_element_builder_one_attributes_element_content(self):
        element_str = str(XmlElementBuilder(
            "root",
            attributes={
                "attrb": "value"
            },
            content=[
                XmlElementBuilder("child")
            ]
        ))

        expected_str = """<root attrb="value">
    <child />
</root>
"""
        self.assertEqual(expected_str, element_str)
Ejemplo n.º 4
0
    def test_xml_element_builder_no_attributes_str_content(self):

        element_str = str(XmlElementBuilder(
            "root",
            attributes=None,
            content="value"
        ))

        expected_str = """<root>value</root>
"""
        self.assertEqual(expected_str, element_str)
Ejemplo n.º 5
0
    def test_xml_element_builder_one_attributes_no_content(self):
        element_str = str(XmlElementBuilder(
            "root",
            attributes={
                "attrb": "value"
            },
            content=None
        ))

        expected_str = """<root attrb="value" />
"""
        self.assertEqual(expected_str, element_str)
Ejemplo n.º 6
0
    def test_xml_element_builder_many_attributes_str_content(self):
        element_str = str(XmlElementBuilder(
            "root",
            attributes={
                "attrb1": "value",
                "attrb2": "value"
            },
            content="value"
        ))

        expected_str = """<root
    attrb1="value"
    attrb2="value">
    value
</root>
"""
        self.assertEqual(expected_str, element_str)