Beispiel #1
0
    def test_reload_extension(self):
        xsd_files = join('extension', 'basic')
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            '/xs:schema/xs:element/xs:complexType/xs:complexContent',
            namespaces=self.request.session['namespaces'])[0]

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

        xml_tree = self.extension_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_complex_content(self.request,
                                                 xsd_element,
                                                 xsd_tree,
                                                 full_path='/root',
                                                 edit_data_tree=edit_data_tree)
        # print result_string
        # result_string = '<div>' + result_string + '</div>'

        expected_dict = self.extension_data_handler.get_json(xsd_files +
                                                             '.reload')

        self.assertDictEqual(result_string[1], expected_dict)
    def test_create_extension(self):
        xsd_files = join('extension', 'basic')
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:element/xs:complexType/xs:complexContent',
                                     namespaces=self.request.session['namespaces'])[0]

        result_string = generate_complex_content(self.request, xsd_element, xsd_tree, full_path='')
        # print result_string

        expected_dict = self.extension_data_handler.get_json(xsd_files)

        self.assertDictEqual(result_string[1], expected_dict)
Beispiel #3
0
    def test_create_extension(self):
        xsd_files = join('extension', 'basic')
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath(
            '/xs:schema/xs:element/xs:complexType/xs:complexContent',
            namespaces=self.request.session['namespaces'])[0]

        result_string = generate_complex_content(self.request,
                                                 xsd_element,
                                                 xsd_tree,
                                                 full_path='')
        # print result_string

        expected_dict = self.extension_data_handler.get_json(xsd_files)

        self.assertDictEqual(result_string[1], expected_dict)
    def test_reload_extension(self):
        xsd_files = join('extension', 'basic')
        xsd_tree = self.extension_data_handler.get_xsd(xsd_files)
        xsd_element = xsd_tree.xpath('/xs:schema/xs:element/xs:complexType/xs:complexContent',
                                     namespaces=self.request.session['namespaces'])[0]

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

        xml_tree = self.extension_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_complex_content(self.request, xsd_element, xsd_tree, full_path='/root',
                                                 edit_data_tree=edit_data_tree)
        # print result_string
        # result_string = '<div>' + result_string + '</div>'

        expected_dict = self.extension_data_handler.get_json(xsd_files + '.reload')

        self.assertDictEqual(result_string[1], expected_dict)