def test_multiple(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.request.session['namespaces'])[0] 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'))) # default_value = edit_data_tree.xpath('/root[1]', namespaces=self.request.session['namespaces']) result_string = generate_extension(self.request, xsd_element, xsd_tree, full_path='/root[1]', default_value=edit_data_tree, 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_choice(self): xsd_files = join('choice', '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.session['namespaces'])[0] result_string = generate_extension(self.request, xsd_element, xsd_tree, full_path='') expected_dict = self.extension_data_handler.get_json(xsd_files) self.assertDictEqual(result_string[1], expected_dict)
def test_choice(self): xsd_files = join('choice', '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.session['namespaces'])[0] result_string = generate_extension(self.request, xsd_element, xsd_tree, full_path='') expected_dict = self.extension_data_handler.get_json(xsd_files) self.assertDictEqual(result_string[1], expected_dict)
def test_attribute(self): xsd_files = join('attribute', 'basic') 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.session['namespaces'])[0] self.session['keys'] = {} self.session['keyrefs'] = {} self.session.save() self.request.session = self.session result_string = generate_extension(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_attribute(self): xsd_files = join('attribute', 'basic') 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.session['namespaces'])[0] self.session['keys'] = {} self.session['keyrefs'] = {} self.session.save() self.request.session = self.session result_string = generate_extension(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_sequence(self): xsd_files = join('sequence', '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.session['namespaces'])[0] xml_tree = self.extension_data_handler.get_xml(xsd_files) xml_data = etree.tostring(xml_tree) xml_value = '' 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_extension(self.request, xsd_element, xsd_tree, full_path='/root[1]', default_value=xml_value, 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)