def test_reload_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.request.session['namespaces'])[0]

        self.request.session['curate_edit'] = True

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = etree.tostring(xml_tree)

        clean_parser = etree.XMLParser(remove_blank_text=True,
                                       remove_comments=True,
                                       remove_pis=True)
        etree.set_default_parser(parser=clean_parser)
        # load the XML tree from the text
        edit_data_tree = etree.XML(str(xml_data.encode('utf-8')))

        result_string = generate_element(self.request,
                                         xsd_element,
                                         xsd_tree,
                                         full_path='/root',
                                         edit_data_tree=edit_data_tree)

        expected_element = self.element_data_handler.get_json(xsd_files +
                                                              '.reload')

        self.assertDictEqual(result_string[1], expected_element)
    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.request.session['namespaces'])[0]

        result_string = generate_element(self.request, xsd_element, xsd_tree, full_path='')

        expected_element = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string[1], expected_element)
    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.request.session['namespaces'])[0]

        result_string = generate_element(self.request,
                                         xsd_element,
                                         xsd_tree,
                                         full_path='')

        expected_element = self.element_data_handler.get_json(xsd_files)
        self.assertDictEqual(result_string[1], expected_element)
    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.request.session['namespaces'])[0]

        self.request.session['curate_edit'] = True

        xml_tree = self.element_data_handler.get_xml(xsd_files)
        xml_data = etree.tostring(xml_tree)

        clean_parser = etree.XMLParser(remove_blank_text=True, remove_comments=True, remove_pis=True)
        etree.set_default_parser(parser=clean_parser)
        # load the XML tree from the text
        edit_data_tree = etree.XML(str(xml_data.encode('utf-8')))

        result_string = generate_element(self.request, xsd_element, xsd_tree, full_path='',
                                         edit_data_tree=edit_data_tree)

        expected_element = self.element_data_handler.get_json(xsd_files + '.reload')

        self.assertDictEqual(result_string[1], expected_element)