Esempio n. 1
0
    def test_create_element_unbounded(self):
        xsd_files = join('element', 'unbounded')
        xsd_tree = self.sequence_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:complexType/xs:sequence',
                                     namespaces=self.request.session['namespaces'])[0]

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

        expected_element = self.sequence_data_handler.get_json(xsd_files)

        self.assertDictEqual(result_string[1], expected_element)
Esempio n. 2
0
    def test_create_element_basic(self):
        xsd_files = join('element', 'basic')
        xsd_xpath = '/xs:schema/xs:complexType/xs:sequence'

        # self.parser_test_datastructures(xsd_files, self.sequence_data_handler, xsd_xpath,
        #                                 self.request.session['namespaces'],
        #                                 generate_sequence, self.request)

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

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

        expected_element = self.sequence_data_handler.get_json(xsd_files)

        self.assertDictEqual(result_string[1], expected_element)
Esempio n. 3
0
    def test_reload_multiple_unbounded(self):
        xsd_files = join('multiple', 'unbounded')
        xsd_tree = self.sequence_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:complexType/xs:sequence',
                                     namespaces=self.request.session['namespaces'])[0]

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

        xml_tree = self.sequence_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_sequence(self.request, xsd_element, xsd_tree, full_path='/root',
                                          edit_data_tree=edit_data_tree)

        expected_element = self.sequence_data_handler.get_json(xsd_files + '.reload')
        self.assertDictEqual(result_string[1], expected_element)