Пример #1
0
    def setUp(self):
        element_data = join(RESOURCES_PATH, 'parser', 'element')
        self.element_data_handler = DataHandler(element_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {'xs': SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()
Пример #2
0
    def setUp(self):
        restriction_data = join(RESOURCES_PATH, "parser", "restriction")
        self.restriction_data_handler = DataHandler(restriction_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()
Пример #3
0
    def setUp(self):
        choice_data = join(RESOURCES_PATH, "parser", "choice")
        self.choice_data_handler = DataHandler(choice_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()
        self.parser.editing = True
Пример #4
0
    def setUp(self):
        # Setup data handler
        complex_type_data = join(RESOURCES_PATH, "parser", "complex_type")
        self.complex_type_data_handler = DataHandler(complex_type_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()
Пример #5
0
    def setUp(self):
        # Init data path
        element_data = join(RESOURCES_PATH, 'parser', 'element')
        self.element_data_handler = DataHandler(element_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {'xs': SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser with editing enabled
        self.parser = XSDParser()
        self.parser.editing = True
Пример #6
0
    def setUp(self):
        # Init data path
        retriction_data = join(RESOURCES_PATH, "parser", "restriction")
        self.restriction_data_handler = DataHandler(retriction_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser with editing enabled
        self.parser = XSDParser()
        self.parser.editing = True
Пример #7
0
class ParserCreateComplexContentTestSuite(TestCase):
    """"""

    maxDiff = None

    def setUp(self):
        # Setup data handler
        complex_content_data = join(RESOURCES_PATH, "parser",
                                    "complex_content")
        self.complex_content_data_handler = DataHandler(complex_content_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()

    def test_create_extension_basic(self):
        xsd_files = join("extension", "basic")
        xsd_tree = self.complex_content_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:complexContent",
            namespaces=self.namespaces,
        )[0]

        result_string = self.parser.generate_complex_content(xsd_element,
                                                             xsd_tree,
                                                             full_path="/root")

        expected_dict = self.complex_content_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_create_restriction_basic(self):
        xsd_files = join("restriction", "basic")
        xsd_tree = self.complex_content_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:complexContent",
            namespaces=self.namespaces,
        )[0]

        # Generate result dict
        result_string = self.parser.generate_complex_content(xsd_element,
                                                             xsd_tree,
                                                             full_path="/root")

        # Load expected dictionary and compare with result
        expected_dict = self.complex_content_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string, expected_dict)
Пример #8
0
class ParserCreateRestrictionTestSuite(TestCase):
    """"""
    def setUp(self):
        restriction_data = join(RESOURCES_PATH, "parser", "restriction")
        self.restriction_data_handler = DataHandler(restriction_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()

    def _run_test(self, xsd_files):
        xsd_tree = self.restriction_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath("/xs:schema/xs:simpleType/xs:restriction",
                                     namespaces=self.namespaces)[0]

        result_dict = self.parser.generate_restriction(xsd_element,
                                                       xsd_tree,
                                                       full_path="/root")
        expected_dict = self.restriction_data_handler.get_json(xsd_files)

        return result_dict, expected_dict

    def test_enumeration(self):
        xsd_files = join("enumeration", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)
        self.assertDictEqual(result_dict, expected_dict)

    def test_simple_type(self):
        xsd_files = join("simple_type", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)
def get_parser():
    """Load configuration for the parser.

    Returns:

    """
    return XSDParser(min_tree=False,
                     ignore_modules=True,
                     collapse=True,
                     auto_key_keyref=False,
                     implicit_extension_base=False,
                     download_dependencies=True,
                     store_type=True)
Пример #10
0
def get_parser():
    """Load configuration for the parser.

    Returns:

    """

    return XSDParser(min_tree=PARSER_MIN_TREE,
                     ignore_modules=PARSER_IGNORE_MODULES,
                     collapse=PARSER_COLLAPSE,
                     auto_key_keyref=PARSER_AUTO_KEY_KEYREF,
                     implicit_extension_base=PARSER_IMPLICIT_EXTENSION_BASE,
                     download_dependencies=PARSER_DOWNLOAD_DEPENDENCIES)
Пример #11
0
def get_parser():
    """Returns parser

    Returns:

    """

    return XSDParser(min_tree=True,
                     ignore_modules=True,
                     collapse=True,
                     auto_key_keyref=False,
                     implicit_extension_base=False,
                     download_dependencies=PARSER_DOWNLOAD_DEPENDENCIES,
                     store_type=True)
Пример #12
0
class ParserReloadRestrictionTestSuite(TestCase):
    """"""
    def setUp(self):
        # Init data path
        retriction_data = join(RESOURCES_PATH, "parser", "restriction")
        self.restriction_data_handler = DataHandler(retriction_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser with editing enabled
        self.parser = XSDParser()
        self.parser.editing = True

    def _run_test(self, xsd_files):
        xsd_tree = self.restriction_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath("/xs:schema/xs:simpleType/xs:restriction",
                                     namespaces=self.namespaces)[0]

        xml_tree = self.restriction_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_restriction(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree,
            default_value=edit_data_tree.text,
        )

        # Load expected dictionary and compare with result
        expected_dict = self.restriction_data_handler.get_json(xsd_files +
                                                               ".reload")

        return result_dict, expected_dict

    def test_enumeration(self):
        xsd_files = join("enumeration", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(expected_dict, result_dict)

    def test_simple_type(self):
        xsd_files = join("simple_type", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(expected_dict, result_dict)
Пример #13
0
class ParserReloadElementTestSuite(TestCase):
    maxDiff = None

    def setUp(self):
        # Init data path
        element_data = join(RESOURCES_PATH, 'parser', 'element')
        self.element_data_handler = DataHandler(element_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {'xs': SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser with editing enabled
        self.parser = XSDParser()
        self.parser.editing = True

    def test_reload_simple_type_basic(self):
        xsd_files = join('simple_type', 'basic')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:element',
                                     namespaces=self.namespaces)[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = etree.tostring(xml_tree)
        edit_data_tree = etree.XML(str(xml_data.encode('utf-8')))

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path='',
            edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files+".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_reload_simple_type_basic_ns(self):
        xsd_files = join('simple_type', 'basic_ns')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:element',
                                     namespaces=self.namespaces)[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files.replace("_ns", ""))
        xml_data = etree.tostring(xml_tree)
        edit_data_tree = etree.XML(str(xml_data.encode('utf-8')))

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path='',
            edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files+".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_reload_simple_type_unbounded(self):
        xsd_files = join('simple_type', 'unbounded')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            '/xs:schema/xs:complexType/xs:sequence/xs:element',
            namespaces=self.namespaces
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = etree.tostring(xml_tree)
        edit_data_tree = etree.XML(str(xml_data.encode('utf-8')))

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path='/ex:root[1]',
            edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files+".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_reload_simple_type_unbounded_ns(self):
        xsd_files = join('simple_type', 'unbounded_ns')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            '/xs:schema/xs:complexType/xs:sequence/xs:element',
            namespaces=self.namespaces
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = etree.tostring(xml_tree)
        edit_data_tree = etree.XML(str(xml_data.encode('utf-8')))

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path='/root[1]',
            edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files+".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_reload_complex_type_basic(self):
        xsd_files = join('complex_type', 'basic')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:element',
                                     namespaces=self.namespaces)[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = etree.tostring(xml_tree)
        edit_data_tree = etree.XML(str(xml_data.encode('utf-8')))

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element,
            xsd_tree,
            full_path='',
            edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files+".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_complex_type_unbounded(self):
        xsd_files = join('complex_type', 'unbounded')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            '/xs:schema/xs:complexType/xs:sequence/xs:element',
            namespaces=self.namespaces
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = etree.tostring(xml_tree)
        edit_data_tree = etree.XML(str(xml_data.encode('utf-8')))

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element,
            xsd_tree,
            full_path='/root',
            edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files+".reload")
        self.assertDictEqual(expected_dict, result_dict)
Пример #14
0
class ParserReloadElementTestSuite(TestCase):
    def setUp(self):
        # Init data path
        element_data = join(RESOURCES_PATH, "parser", "element")
        self.element_data_handler = DataHandler(element_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser with editing enabled
        self.parser = XSDParser()
        self.parser.editing = True

    def test_reload_simple_type_basic(self):
        xsd_files = join("simple_type", "basic")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element", namespaces=self.namespaces
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path="", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files + ".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_reload_simple_type_basic_ns(self):
        xsd_files = join("simple_type", "basic_ns")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element", namespaces=self.namespaces
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files.replace("_ns", ""))
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path="", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files + ".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_reload_simple_type_unbounded(self):
        xsd_files = join("simple_type", "unbounded")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType/xs:sequence/xs:element",
            namespaces=self.namespaces,
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element,
            xsd_tree,
            full_path="/ex:root[1]",
            edit_data_tree=edit_data_tree,
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files + ".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_reload_simple_type_unbounded_ns(self):
        xsd_files = join("simple_type", "unbounded_ns")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType/xs:sequence/xs:element",
            namespaces=self.namespaces,
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path="/root[1]", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files + ".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_reload_complex_type_basic(self):
        xsd_files = join("complex_type", "basic")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element", namespaces=self.namespaces
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path="", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files + ".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_complex_type_unbounded(self):
        xsd_files = join("complex_type", "unbounded")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType/xs:sequence/xs:element",
            namespaces=self.namespaces,
        )[0]

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path="/root", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files + ".reload")
        self.assertDictEqual(expected_dict, result_dict)
Пример #15
0
class ParserGenerateElementTestSuite(TestCase):
    def setUp(self):
        element_data = join(RESOURCES_PATH, "parser", "element")
        self.element_data_handler = DataHandler(element_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()

    def test_create_simple_type_basic(self):
        xsd_files = join("simple_type", "basic")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element", namespaces=self.namespaces
        )[0]

        # Generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree, full_path="")

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_simple_type_basic_ns(self):
        xsd_files = join("simple_type", "basic_ns")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element", namespaces=self.namespaces
        )[0]

        # Generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree, full_path="")

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_simple_type_unbounded(self):
        xsd_files = join("simple_type", "unbounded")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType/xs:sequence/xs:element",
            namespaces=self.namespaces,
        )[0]

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path="/ex:root[1]"
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_simple_type_unbounded_ns(self):
        xsd_files = join("simple_type", "unbounded_ns")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType/xs:sequence/xs:element",
            namespaces=self.namespaces,
        )[0]

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path="/root[1]"
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_complex_type_basic(self):
        xsd_files = join("complex_type", "basic")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element", namespaces=self.namespaces
        )[0]

        # generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree, full_path="")

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_complex_type_unbounded(self):
        xsd_files = join("complex_type", "unbounded")
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType/xs:sequence/xs:element",
            namespaces=self.namespaces,
        )[0]

        # Generate result dict
        result_dict = self.parser.generate_element(
            xsd_element, xsd_tree, full_path="/root"
        )

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)
Пример #16
0
class ParserReloadChoiceTestSuite(TestCase):
    """"""
    def setUp(self):
        choice_data = join(RESOURCES_PATH, "parser", "choice")
        self.choice_data_handler = DataHandler(choice_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()
        self.parser.editing = True

    def test_reload_element_basic(self):
        xsd_files = join("element", "basic")
        xsd_tree = self.choice_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath("/xs:schema/xs:complexType/xs:choice",
                                     namespaces=self.namespaces)[0]

        xml_tree = self.choice_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        result_string = self.parser.generate_choice(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree)

        expected_element = self.choice_data_handler.get_json(xsd_files +
                                                             ".reload")

        self.assertDictEqual(expected_element, result_string)

    def test_reload_element_unbounded(self):
        xsd_files = join("element", "unbounded")
        xsd_tree = self.choice_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath("/xs:schema/xs:complexType/xs:choice",
                                     namespaces=self.namespaces)[0]

        xml_tree = self.choice_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        result_string = self.parser.generate_choice(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree)

        expected_element = self.choice_data_handler.get_json(xsd_files +
                                                             ".reload")

        self.assertDictEqual(expected_element, result_string)

    def test_reload_sequence_basic(self):
        xsd_files = join("sequence", "basic")
        xsd_tree = self.choice_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath("/xs:schema/xs:complexType/xs:choice",
                                     namespaces=self.namespaces)[0]

        xml_tree = self.choice_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        result_string = self.parser.generate_choice(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree)

        expected_element = self.choice_data_handler.get_json(xsd_files +
                                                             ".reload")

        self.assertDictEqual(expected_element, result_string)

    def test_reload_sequence_unbounded(self):
        xsd_files = join("sequence", "unbounded")
        xsd_tree = self.choice_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath("/xs:schema/xs:complexType/xs:choice",
                                     namespaces=self.namespaces)[0]

        xml_tree = self.choice_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        result_string = self.parser.generate_choice(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree)

        expected_element = self.choice_data_handler.get_json(xsd_files +
                                                             ".reload")

        self.assertDictEqual(expected_element, result_string)
Пример #17
0
class ParserReloadSequenceTestSuite(TestCase):
    """"""

    maxDiff = None

    def setUp(self):
        # Init data path
        sequence_data = join(RESOURCES_PATH, "parser", "sequence")
        self.sequence_data_handler = DataHandler(sequence_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser with editing enabled
        self.parser = XSDParser()
        self.parser.editing = True

    def _run_test(self, xsd_files):
        xsd_tree = self.sequence_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath("/xs:schema/xs:complexType/xs:sequence",
                                     namespaces=self.namespaces)[0]

        xml_tree = self.sequence_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_sequence(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree)

        # Load expected dictionary and compare with result
        expected_dict = self.sequence_data_handler.get_json(xsd_files +
                                                            ".reload")

        return result_dict, expected_dict

    def test_reload_element_basic(self):
        xsd_files = join("element", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_reload_element_unbounded(self):
        # fixme correct bug
        xsd_files = join("element", "unbounded")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_reload_choice_basic(self):
        xsd_files = join("choice", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_reload_choice_unbounded(self):
        xsd_files = join("choice", "unbounded")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_reload_sequence_basic(self):
        xsd_files = join("sequence", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_reload_sequence_unbounded(self):
        xsd_files = join("sequence", "unbounded")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_reload_multiple_basic(self):
        xsd_files = join("multiple", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_reload_multiple_unbounded(self):
        xsd_files = join("multiple", "unbounded")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)
Пример #18
0
class ParserCreateSequenceTestSuite(TestCase):
    """Test creation of elements under sequence"""
    def setUp(self):
        sequence_data = join(RESOURCES_PATH, "parser", "sequence")
        self.sequence_data_handler = DataHandler(sequence_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()

    def _run_test(self, xsd_files):
        xsd_xpath = "/xs:schema/xs:complexType/xs:sequence"

        xsd_tree = self.sequence_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(xsd_xpath, namespaces=self.namespaces)[0]

        result_dict = self.parser.generate_sequence(xsd_element,
                                                    xsd_tree,
                                                    full_path="/root")

        expected_dict = self.sequence_data_handler.get_json(xsd_files)

        return result_dict, expected_dict

    def test_create_element_basic(self):
        xsd_files = join("element", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_create_element_unbounded(self):
        xsd_files = join("element", "unbounded")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_create_choice_basic(self):
        xsd_files = join("choice", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_create_choice_unbounded(self):
        xsd_files = join("choice", "unbounded")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_create_sequence_basic(self):
        xsd_files = join("sequence", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_create_sequence_unbounded(self):
        xsd_files = join("sequence", "unbounded")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_create_multiple_basic(self):
        xsd_files = join("multiple", "basic")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)

    def test_create_multiple_unbounded(self):
        xsd_files = join("multiple", "unbounded")
        result_dict, expected_dict = self._run_test(xsd_files)

        self.assertDictEqual(result_dict, expected_dict)
Пример #19
0
class ParserCreateComplexTypeTestSuite(TestCase):
    """Element creation unit tests"""

    def setUp(self):
        # Setup data handler
        complex_type_data = join(RESOURCES_PATH, "parser", "complex_type")
        self.complex_type_data_handler = DataHandler(complex_type_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()

    def test_create_choice_basic(self):
        xsd_files = join("choice", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root"
        )

        expected_dict = self.complex_type_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_create_sequence_basic(self):
        xsd_files = join("sequence", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root"
        )

        expected_dict = self.complex_type_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_create_simple_content_basic(self):
        xsd_files = join("simple_content", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root"
        )

        expected_dict = self.complex_type_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_create_complex_content_basic(self):
        xsd_files = join("complex_content", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root"
        )

        expected_dict = self.complex_type_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_create_attribute_basic(self):
        xsd_files = join("attribute", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root"
        )

        expected_dict = self.complex_type_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_create_multiple_basic(self):
        xsd_files = join("multiple", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root"
        )

        expected_dict = self.complex_type_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string, expected_dict)
Пример #20
0
class ParserGenerateElementTestSuite(TestCase):
    maxDiff = None

    def setUp(self):
        element_data = join(RESOURCES_PATH, 'parser', 'element')
        self.element_data_handler = DataHandler(element_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {'xs': SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()

    def test_create_simple_type_basic(self):
        xsd_files = join('simple_type', 'basic')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:element',
                                     namespaces=self.namespaces)[0]

        # Generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree,
                                                   full_path='')

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_simple_type_basic_ns(self):
        xsd_files = join('simple_type', 'basic_ns')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:element',
                                     namespaces=self.namespaces)[0]

        # Generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree,
                                                   full_path='')

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_simple_type_unbounded(self):
        xsd_files = join('simple_type', 'unbounded')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            '/xs:schema/xs:complexType/xs:sequence/xs:element',
            namespaces=self.namespaces
        )[0]

        # Generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree,
                                                   full_path='/ex:root[1]')

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_simple_type_unbounded_ns(self):
        xsd_files = join('simple_type', 'unbounded_ns')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            '/xs:schema/xs:complexType/xs:sequence/xs:element',
            namespaces=self.namespaces
        )[0]

        # Generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree,
                                                   full_path='/root[1]')

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_complex_type_basic(self):
        xsd_files = join('complex_type', 'basic')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:element',
                                     namespaces=self.namespaces)[0]

        # generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree,
                                                   full_path='')

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)

    def test_create_complex_type_unbounded(self):
        xsd_files = join('complex_type', 'unbounded')
        xsd_tree = self.element_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            '/xs:schema/xs:complexType/xs:sequence/xs:element',
            namespaces=self.namespaces
        )[0]

        # Generate result dict
        result_dict = self.parser.generate_element(xsd_element, xsd_tree,
                                                   full_path='/root')

        # Load expected dictionary and compare with result
        expected_dict = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(expected_dict, result_dict)
Пример #21
0
class ParserCreateExtensionTestSuite(TestCase):
    """"""
    def setUp(self):
        extension_data = join(RESOURCES_PATH, "parser", "extension")
        self.extension_data_handler = DataHandler(extension_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()

    def test_generate_extension_with_multiple_children_returns_expected_json_dict(
            self):
        xsd_files = join("multiple", "basic")
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:complexContent/xs:extension",
            namespaces=self.namespaces,
        )[0]

        result_dict = self.parser.generate_extension(xsd_element,
                                                     xsd_tree,
                                                     full_path="/root")
        expected_dict = self.extension_data_handler.get_json(xsd_files)

        self.assertDictEqual(expected_dict, result_dict)

    def test_generate_extension_with_single_child_attribute_returns_expected_json_dict(
        self, ):
        xsd_files = join("attribute", "single")
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:simpleContent/xs:extension",
            namespaces=self.namespaces,
        )[0]

        result_dict = self.parser.generate_extension(xsd_element,
                                                     xsd_tree,
                                                     full_path="/root")
        expected_dict = self.extension_data_handler.get_json(xsd_files)

        self.assertDictEqual(expected_dict, result_dict)

    def test_generate_extension_with_single_child_choice_returns_expected_json_dict(
        self, ):
        xsd_files = join("choice", "single")
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:complexContent/xs:extension",
            namespaces=self.namespaces,
        )[0]

        result_dict = self.parser.generate_extension(xsd_element,
                                                     xsd_tree,
                                                     full_path="/root")
        expected_dict = self.extension_data_handler.get_json(xsd_files)

        self.assertDictEqual(expected_dict, result_dict)

    def test_generate_extension_with_single_child_sequence_returns_expected_json_dict(
        self, ):
        xsd_files = join("sequence", "single")
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:complexContent/xs:extension",
            namespaces=self.namespaces,
        )[0]

        result_dict = self.parser.generate_extension(xsd_element,
                                                     xsd_tree,
                                                     full_path="/root")
        expected_dict = self.extension_data_handler.get_json(xsd_files)

        self.assertDictEqual(expected_dict, result_dict)
Пример #22
0
class ParserReloadExtensionTestSuite(TestCase):
    """"""
    def setUp(self):
        # Init data path
        extension_data = join(RESOURCES_PATH, "parser", "extension")
        self.extension_data_handler = DataHandler(extension_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser with editing enabled
        self.parser = XSDParser()
        self.parser.editing = True

    def test_generate_extension_with_multiple_children_returns_expected_json_dict(
            self):
        xsd_files = join("multiple", "basic")
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:complexContent/xs:extension",
            namespaces=self.namespaces,
        )[0]

        xml_tree = self.extension_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_extension(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree,
            default_value=edit_data_tree,
        )

        # Load expected dictionary and compare with result
        expected_dict = self.extension_data_handler.get_json(xsd_files +
                                                             ".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_generate_extension_with_single_child_attribute_returns_expected_json_dict(
        self, ):
        xsd_files = join("attribute", "single")
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:simpleContent/xs:extension",
            namespaces=self.namespaces,
        )[0]

        xml_tree = self.extension_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_extension(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree,
            default_value="entry0",
        )

        # Load expected dictionary and compare with result
        expected_dict = self.extension_data_handler.get_json(xsd_files +
                                                             ".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_generate_extension_with_single_child_choice_returns_expected_json_dict(
        self, ):
        xsd_files = join("choice", "single")
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:complexContent/xs:extension",
            namespaces=self.namespaces,
        )[0]

        xml_tree = self.extension_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_extension(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree)

        # Load expected dictionary and compare with result
        expected_dict = self.extension_data_handler.get_json(xsd_files +
                                                             ".reload")
        self.assertDictEqual(expected_dict, result_dict)

    def test_generate_extension_with_single_child_sequence_returns_expected_json_dict(
        self, ):
        xsd_files = join("sequence", "single")
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:element/xs:complexType/xs:complexContent/xs:extension",
            namespaces=self.namespaces,
        )[0]

        xml_tree = self.extension_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_dict = self.parser.generate_extension(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree)

        # Load expected dictionary and compare with result
        expected_dict = self.extension_data_handler.get_json(xsd_files +
                                                             ".reload")
        self.assertDictEqual(expected_dict, result_dict)
Пример #23
0
class ParserReloadComplexTypeTestSuite(TestCase):
    """Element reload unit tests"""

    def setUp(self):
        complex_type_data = join(RESOURCES_PATH, "parser", "complex_type")
        self.complex_type_data_handler = DataHandler(complex_type_data)

        # Set default namespace
        self.namespace = LXML_SCHEMA_NAMESPACE
        self.namespaces = {"xs": SCHEMA_NAMESPACE}

        # Get an instance of the XSDParser
        self.parser = XSDParser()
        self.parser.editing = True

    def test_reload_choice_basic(self):
        xsd_files = join("choice", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        xml_tree = self.complex_type_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.complex_type_data_handler.get_json("%s.reload" % xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_reload_sequence_basic(self):
        xsd_files = join("sequence", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        xml_tree = self.complex_type_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.complex_type_data_handler.get_json("%s.reload" % xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_reload_simple_content_basic(self):
        xsd_files = join("simple_content", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        xml_tree = self.complex_type_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        xml_value = xml_tree.xpath("/root", namespaces=self.namespaces)[0].text

        # Generate result dict
        result_string = self.parser.generate_complex_type(
            xsd_element,
            xsd_tree,
            full_path="/root",
            edit_data_tree=edit_data_tree,
            default_value=xml_value,
        )

        # Load expected dictionary and compare with result
        expected_dict = self.complex_type_data_handler.get_json("%s.reload" % xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_reload_complex_content_basic(self):
        xsd_files = join("complex_content", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        xml_tree = self.complex_type_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.complex_type_data_handler.get_json("%s.reload" % xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_reload_attribute_basic(self):
        xsd_files = join("attribute", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        xml_tree = self.complex_type_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.complex_type_data_handler.get_json("%s.reload" % xsd_files)
        self.assertDictEqual(result_string, expected_dict)

    def test_reload_multiple_basic(self):
        xsd_files = join("multiple", "basic")
        xsd_tree = self.complex_type_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            "/xs:schema/xs:complexType", namespaces=self.namespaces
        )[0]

        xml_tree = self.complex_type_data_handler.get_xml(xsd_files)
        xml_data = XSDTree.tostring(xml_tree)
        edit_data_tree = XSDTree.transform_to_xml(xml_data)

        # Generate result dict
        result_string = self.parser.generate_complex_type(
            xsd_element, xsd_tree, full_path="/root", edit_data_tree=edit_data_tree
        )

        # Load expected dictionary and compare with result
        expected_dict = self.complex_type_data_handler.get_json("%s.reload" % xsd_files)
        self.assertDictEqual(result_string, expected_dict)