def test_reload_compliant_element(self): compliant_xml = self.occurs_data_handler.get_xml('compliant') occurences = lookup_occurs(self.sequence, self.document_schema, self.xml_xpath, compliant_xml) self.assertEqual(len(occurences), 3) occ0_expected_xml = self.occurs_data_handler.get_xml('item0') occ1_expected_xml = self.occurs_data_handler.get_xml('item1') occ2_expected_xml = self.occurs_data_handler.get_xml('item2') self.assertTrue(are_equals(occurences[0], occ0_expected_xml)) self.assertTrue(are_equals(occurences[1], occ1_expected_xml)) self.assertTrue(are_equals(occurences[2], occ2_expected_xml))
def test_reload_compliant_element(self): compliant_xml = self.occurs_data_handler.get_xml("compliant") occurences = lookup_occurs(self.sequence, self.document_schema, self.xml_xpath, compliant_xml) self.assertEqual(len(occurences), 3) occ0_expected_xml = self.occurs_data_handler.get_xml("item0") occ1_expected_xml = self.occurs_data_handler.get_xml("item1") occ2_expected_xml = self.occurs_data_handler.get_xml("item2") self.assertTrue(are_equals(occurences[0], occ0_expected_xml)) self.assertTrue(are_equals(occurences[1], occ1_expected_xml)) self.assertTrue(are_equals(occurences[2], occ2_expected_xml))
def execute_test(self, file_id): filename = '{}.xsd'.format(file_id) # load XSD xsd_file_path = join(self.resources_path, filename) xsd_file = open(xsd_file_path, 'r') xsd_file_content = xsd_file.read() # create template template = create_template(xsd_file_content, filename, filename) # load the form load_new_form(self.driver, self.base_url, file_id) time.sleep(TIMEOUT) # download XML self.driver.execute_script("downloadCurrentXML();") # wait a bit more to let time to save the file time.sleep(TIMEOUT * 5) # load expected result exp_result_path = join(self.resources_path, "{0}.xml".format(file_id)) exp_result_file = open(exp_result_path, 'r') exp_result_content = exp_result_file.read() # load result generated by the form result_path = join(self.results_path, "{0}.xml".format(file_id)) result_file = open(result_path, 'r') result_content = result_file.read() expected = etree.fromstring(exp_result_content) result = etree.fromstring(result_content) if not are_equals(expected, result): raise Exception('NOT EQUALS TO EXPECTED: {}'.format(file_id))
def reload(self, file_id, reload_id): file_name = '{0}-reload{1}.xml'.format(file_id, str(reload_id)) file_path = os.path.join(RESOURCES_PATH, file_name) if os.path.exists(file_path): # load the form upload_xml_form(self.driver, self.base_url, file_path) time.sleep(TIMEOUT) # download XML self.driver.execute_script("downloadCurrentXML();") # wait a bit more to let time to save the file time.sleep(TIMEOUT * 5) # load expected result exp_result_path = join(self.resources_path, file_name) exp_result_file = open(exp_result_path, 'r') exp_result_content = exp_result_file.read() # load result generated by the form result_path = join(self.results_path, "{}.xml".format(file_name)) result_file = open(result_path, 'r') result_content = result_file.read() expected = etree.fromstring(exp_result_content) result = etree.fromstring(result_content) if not are_equals(expected, result): raise Exception(file_name)
def test_imbricated_elements(self): document_schema = self.subnodes_data_handler.get_xsd("imbricated") complex_type_xpath = "/xs:schema/xs:complexType" complex_type = document_schema.xpath(complex_type_xpath, namespaces=self.namespace)[0] sequence_xpath = complex_type_xpath + "/xs:sequence" element_xpath = sequence_xpath + "/xs:element" element_a = document_schema.xpath(element_xpath, namespaces=self.namespace)[0] choice_element_xpath = sequence_xpath + "/xs:choice/xs:element" choice_elements = document_schema.xpath(choice_element_xpath, namespaces=self.namespace) element_b = choice_elements[0] element_c = choice_elements[1] xpath_result = get_nodes_xpath(complex_type, document_schema) expected_result = [ {"name": "a", "element": element_a}, {"name": "b", "element": element_b}, {"name": "c", "element": element_c}, ] self.assertEqual(len(xpath_result), len(expected_result)) for xpath in xpath_result: xpath_elem = xpath["element"] expected_elem_list = [expect["element"] for expect in expected_result if expect["name"] == xpath["name"]] expect_elem = expected_elem_list[0] if len(expected_elem_list) == 1 else None self.assertTrue(are_equals(xpath_elem, expect_elem))
def test_element_has_name(self): document_schema = self.subnodes_data_handler.get_xsd("name") # Retrieving the needed elements sequence_xpath = "/xs:schema/xs:complexType/xs:sequence" sequence = document_schema.xpath(sequence_xpath, namespaces=self.namespace)[0] element_xpath = sequence_xpath + "/xs:element" elements = document_schema.xpath(element_xpath, namespaces=self.namespace) element_a = elements[0] element_b = elements[1] # Building resulting and expected structures xpath_result = get_nodes_xpath(sequence, document_schema) expected_result = [{"name": "a", "element": element_a}, {"name": "b", "element": element_b}] # Testing equality self.assertEqual(len(xpath_result), len(expected_result)) for xpath in xpath_result: xpath_elem = xpath["element"] expected_elem_list = [expect["element"] for expect in expected_result if expect["name"] == xpath["name"]] expect_elem = expected_elem_list[0] if len(expected_elem_list) == 1 else None self.assertTrue(are_equals(xpath_elem, expect_elem))
def blank(self, file_id): # load the form load_new_form(self.driver, self.base_url, file_id) time.sleep(TIMEOUT) # download XML self.driver.execute_script("downloadCurrentXML();") # wait a bit more to let time to save the file time.sleep(TIMEOUT * 5) # load expected result exp_result_path = join(self.resources_path, "{0}.xml".format(file_id)) exp_result_file = open(exp_result_path, 'r') exp_result_content = exp_result_file.read() # load result generated by the form result_path = join(self.results_path, "{0}.xml".format(file_id)) result_file = open(result_path, 'r') result_content = result_file.read() expected = etree.fromstring(exp_result_content) result = etree.fromstring(result_content) if not are_equals(expected, result): raise Exception(str(file_id))
def test_button(self): result_string = self.renderer._render_collapse_button() result_html = etree.fromstring(result_string) expected_html = self.collapse_data_handler.get_html('collapse') self.assertTrue(are_equals(result_html, expected_html))
def test_element_ref_local(self): document_schema = self.subnodes_data_handler.get_xsd("ref_local") complex_type_xpath = "/xs:schema/xs:complexType" complex_type = document_schema.xpath(complex_type_xpath, namespaces=self.namespace)[0] element_a_xpath = complex_type_xpath + "/xs:sequence/xs:element" element_a = document_schema.xpath(element_a_xpath, namespaces=self.namespace)[0] element_r0_xpath = "/xs:schema/xs:element" element_r0 = document_schema.xpath(element_r0_xpath, namespaces=self.namespace)[0] xpath_result = get_nodes_xpath(complex_type, document_schema) expected_result = [ {"name": "a", "element": element_a}, {"name": "r0", "element": element_r0}, {"name": "r0", "element": element_r0}, # FIXME the 2nd element shouldn't be here (not needed) ] self.assertEqual(len(xpath_result), len(expected_result)) for xpath in xpath_result: xpath_elem = xpath["element"] expected_elem_list = [expect["element"] for expect in expected_result if expect["name"] == xpath["name"]] # FIXME Having 2 element with the same content is not useful (>= 1 should be replaced by == 1) expect_elem = expected_elem_list[0] if len(expected_elem_list) >= 1 else None self.assertTrue(are_equals(xpath_elem, expect_elem))
def test_input_value_none(self): input_element = create_mock_db_input(value=None) result_string = self.renderer._render_input(input_element) result_html = etree.fromstring(result_string) expected_html = self.input_data_handler.get_html('input_none') self.assertTrue(are_equals(result_html, expected_html))
def test_no_annotation_no_change(self): not_annotated_etree = self.annotation_data_handler.get_xsd("not_annot") not_annotated_element = not_annotated_etree.xpath(self.xsd_xpath, namespaces=self.namespaces)[0] remove_annotations(not_annotated_element) self.assertTrue(are_equals(not_annotated_element, self.expected_xsd))
def test_input_title_str(self): input_element = create_mock_db_input(title='string') result_string = self.renderer._render_input(input_element) result_html = etree.fromstring(result_string) expected_html = self.input_data_handler.get_html('title') self.assertTrue(are_equals(result_html, expected_html))
def test_no_annotation_no_change(self): not_annotated_etree = self.annotation_data_handler.get_xsd('not_annot') not_annotated_element = not_annotated_etree.xpath(self.xsd_xpath, namespaces=self.namespaces)[0] remove_annotations(not_annotated_element) self.assertTrue(are_equals(not_annotated_element, self.expected_xsd))
def execute_test(self, file_id): filename_inc = '{}_inc.xsd'.format(file_id) # load XSD xsd_file_path_inc = join(self.resources_path, filename_inc) xsd_file_inc = open(xsd_file_path_inc, 'r') xsd_file_content_inc = xsd_file_inc.read() # create template template_inc = create_template(xsd_file_content_inc, filename_inc, filename_inc) template_version = TemplateVersion.objects().get( pk=template_inc.templateVersion) # remove the dependency template template_version.deletedVersions.append(str(template_inc.id)) template_version.isDeleted = True template_version.save() filename = '{}.xsd'.format(file_id) # load XSD xsd_file_path = join(self.resources_path, filename) xsd_file = open(xsd_file_path, 'r') xsd_file_content = xsd_file.read() # create template xsd_tree = etree.fromstring(xsd_file_content) update_dependencies(xsd_tree, {filename_inc: str(template_inc.id)}) xsd_file_content = etree.tostring(xsd_tree) template = create_template(xsd_file_content, filename, filename, [str(template_inc.id)]) # load the form load_new_form(self.driver, self.base_url, file_id) time.sleep(TIMEOUT) # download XML self.driver.execute_script("downloadCurrentXML();") # wait a bit more to let time to save the file time.sleep(TIMEOUT * 5) # load expected result exp_result_path = join(self.resources_path, "{0}.xml".format(file_id)) exp_result_file = open(exp_result_path, 'r') exp_result_content = exp_result_file.read() # load result generated by the form result_path = join(self.results_path, "{0}.xml".format(file_id)) result_file = open(result_path, 'r') result_content = result_file.read() expected = etree.fromstring(exp_result_content) result = etree.fromstring(result_content) if not are_equals(expected, result): raise Exception('NOT EQUALS TO EXPECTED: {}'.format(file_id))
def test_annotation_is_removed(self): annotated_etree = self.annotation_data_handler.get_xsd('annot') # annotated_etree = etree.ElementTree(annotated_schema) annotated_element = annotated_etree.xpath(self.xsd_xpath, namespaces=self.namespaces)[0] remove_annotations(annotated_element) self.assertTrue(are_equals(annotated_element, self.expected_xsd))
def test_input_value_str(self): input_element = create_mock_db_input(value="string") result_string = self.renderer._render_input(input_element) result_html = etree.fromstring(result_string) expected_html = self.input_data_handler.get_html( 'val_str_pl_empty_tt_empty') self.assertTrue(are_equals(result_html, expected_html))
def test_annotation_is_removed(self): annotated_etree = self.annotation_data_handler.get_xsd("annot") # annotated_etree = etree.ElementTree(annotated_schema) annotated_element = annotated_etree.xpath(self.xsd_xpath, namespaces=self.namespaces)[0] remove_annotations(annotated_element) self.assertTrue(are_equals(annotated_element, self.expected_xsd))
def test_input_title_str(self): input_element = create_mock_db_input( title='string' ) result_string = self.renderer._render_input(input_element) result_html = etree.fromstring(result_string) expected_html = self.input_data_handler.get_html('title') self.assertTrue(are_equals(result_html, expected_html))
def test_message_str(self): form_error_message = 'Sample error message' result_string = self.renderer._render_form_error(form_error_message) self.assertEqual(result_string, self.renderer._render_form_error(unicode(form_error_message))) result_html = etree.fromstring(result_string) expected_html = self.form_error_data_handler.get_html('form_error') self.assertTrue(are_equals(result_html, expected_html))
def test_input_placeholder_str(self): input_element = create_mock_db_input(placeholder='string') result_string = self.renderer._render_input(input_element) result_html = etree.fromstring(result_string) # expected_html = self.input_data_handler.get_html('placeholder') expected_html = self.input_data_handler.get_html( 'val_empty_pl_str_tt_empty') self.assertTrue(are_equals(result_html, expected_html))
def test_input_value_none(self): input_element = create_mock_db_input( value=None ) result_string = self.renderer._render_input(input_element) result_html = etree.fromstring(result_string) expected_html = self.input_data_handler.get_html('input_none') self.assertTrue(are_equals(result_html, expected_html))
def execute_test(self, file_id): filename_inc = '{}_inc.xsd'.format(file_id) # load XSD xsd_file_path_inc = join(self.resources_path, filename_inc) xsd_file_inc = open(xsd_file_path_inc, 'r') xsd_file_content_inc = xsd_file_inc.read() # create template template_inc = create_template(xsd_file_content_inc, filename_inc, filename_inc) template_version = TemplateVersion.objects().get(pk=template_inc.templateVersion) # remove the dependency template template_version.deletedVersions.append(str(template_inc.id)) template_version.isDeleted = True template_version.save() filename = '{}.xsd'.format(file_id) # load XSD xsd_file_path = join(self.resources_path, filename) xsd_file = open(xsd_file_path, 'r') xsd_file_content = xsd_file.read() # create template xsd_tree = etree.fromstring(xsd_file_content) update_dependencies(xsd_tree, {filename_inc: str(template_inc.id)}) xsd_file_content = etree.tostring(xsd_tree) template = create_template(xsd_file_content, filename, filename, [str(template_inc.id)]) # load the form load_new_form(self.driver, self.base_url, file_id) time.sleep(TIMEOUT) # download XML self.driver.execute_script("downloadCurrentXML();") # wait a bit more to let time to save the file time.sleep(TIMEOUT * 5) # load expected result exp_result_path = join(self.resources_path, "{0}.xml".format(file_id)) exp_result_file = open(exp_result_path, 'r') exp_result_content = exp_result_file.read() # load result generated by the form result_path = join(self.results_path, "{0}.xml".format(file_id)) result_file = open(result_path, 'r') result_content = result_file.read() expected = etree.fromstring(exp_result_content) result = etree.fromstring(result_content) if not are_equals(expected, result): raise Exception('NOT EQUALS TO EXPECTED: {}'.format(file_id))
def test_id_none_options_empty_list(self): options = [] result_string = self.renderer._render_select(None, self.select_class, options) self.assertEqual(result_string, self.renderer._render_select(None, self.select_class, options)) # print result_string result_html = etree.fromstring(result_string) expected_html = self.select_data_handler.get_html('id_none_options_empty') self.assertTrue(are_equals(result_html, expected_html))
def test_elem_id_none_chosen_false(self): element_id = 'string' chosen = True result_string = render_ul(self.content, element_id, chosen) self.assertEqual(result_string, render_ul(unicode(self.content), element_id, chosen)) # print result_string result_html = etree.fromstring(result_string) expected_html = self.ul_data_handler.get_html2('elem_str_ch_true') self.assertTrue(are_equals(result_html, expected_html))
def test_choice_basic(self): file_path = join('choice', 'basic') xsd_data = self.xsd_handler.get_xsd(file_path) session = self.client.session session['xmlDocTree'] = etree.tostring(xsd_data) session.save() result = retrieve_rendered_form(self.client) expected_result = self.html_handler.get_html(file_path) self.assertTrue(are_equals(result[1], expected_result))
def test_add_del_true(self): is_add_present = True is_del_present = True # form_string = render_buttons(is_add_present, is_del_present, self.default_tag_id) form_string = self.renderer._render_buttons(is_add_present, is_del_present) # form_wrapped = '<span>' + form + '</span>' form = etree.fromstring('<span>' + form_string + '</span>') expected_form = self._expected_form(is_add_present, is_del_present) # expected_form_wrapped = '<span>' + self.addButtonPresent + self.delButtonPresent + '</span>' self.assertTrue(are_equals(form, expected_form))
def test_imbricated_elements(self): document_schema = self.subnodes_data_handler.get_xsd('imbricated') complex_type_xpath = '/xs:schema/xs:complexType' complex_type = document_schema.xpath(complex_type_xpath, namespaces=self.namespace)[0] sequence_xpath = complex_type_xpath + '/xs:sequence' element_xpath = sequence_xpath + '/xs:element' element_a = document_schema.xpath(element_xpath, namespaces=self.namespace)[0] choice_element_xpath = sequence_xpath + '/xs:choice/xs:element' choice_elements = document_schema.xpath(choice_element_xpath, namespaces=self.namespace) element_b = choice_elements[0] element_c = choice_elements[1] xpath_result = get_nodes_xpath(complex_type, document_schema) expected_result = [ { 'name': 'a', 'element': element_a }, { 'name': 'b', 'element': element_b }, { 'name': 'c', 'element': element_c }, ] self.assertEqual(len(xpath_result), len(expected_result)) for xpath in xpath_result: xpath_elem = xpath['element'] expected_elem_list = [ expect['element'] for expect in expected_result if expect['name'] == xpath['name'] ] expect_elem = expected_elem_list[0] if len( expected_elem_list) == 1 else None self.assertTrue(are_equals(xpath_elem, expect_elem))
def test_add_true_del_false(self): is_add_present = True is_del_present = False # form_string = self.renderer._render_buttons(is_add_present, is_del_present, self.default_tag_id) form_string = self.renderer._render_buttons(is_add_present, is_del_present) form = etree.fromstring('<span>' + form_string + '</span>') expected_form = self._expected_form(is_add_present, is_del_present) # expected_form_wrapped = '<span>' + self.addButtonPresent + self.delButtonHidden + '</span>' self.assertTrue( are_equals(form, expected_form) # self._xmlStringAreEquals(form_wrapped, expected_form_wrapped) )
def test_add_del_true(self): is_add_present = True is_del_present = True # form_string = render_buttons(is_add_present, is_del_present, self.default_tag_id) form_string = self.renderer._render_buttons(is_add_present, is_del_present) # form_wrapped = '<span>' + form + '</span>' form = etree.fromstring('<span>' + form_string + '</span>') expected_form = self._expected_form(is_add_present, is_del_present) # expected_form_wrapped = '<span>' + self.addButtonPresent + self.delButtonPresent + '</span>' self.assertTrue( are_equals(form, expected_form) )
def test_id_str_options_list(self): options = [('opt1', 'opt1', False), ('opt2', 'opt2', False), ('opt3', 'opt3', True)] result_string = self.renderer._render_select(self.select_id, self.select_class, options) self.assertEqual( result_string, self.renderer._render_select(unicode(self.select_id), self.select_class, options)) result_html = etree.fromstring(result_string) expected_html = self.select_data_handler.get_html( 'id_str_options_list') self.assertTrue(are_equals(result_html, expected_html))
def test_element_ref_local(self): document_schema = self.subnodes_data_handler.get_xsd('ref_local') complex_type_xpath = '/xs:schema/xs:complexType' complex_type = document_schema.xpath(complex_type_xpath, namespaces=self.namespace)[0] element_a_xpath = complex_type_xpath + '/xs:sequence/xs:element' element_a = document_schema.xpath(element_a_xpath, namespaces=self.namespace)[0] element_r0_xpath = '/xs:schema/xs:element' element_r0 = document_schema.xpath(element_r0_xpath, namespaces=self.namespace)[0] xpath_result = get_nodes_xpath(complex_type, document_schema) expected_result = [ { 'name': 'a', 'element': element_a }, { 'name': 'r0', 'element': element_r0 }, { # FIXME the 2nd element shouldn't be here (not needed) 'name': 'r0', 'element': element_r0 } ] self.assertEqual(len(xpath_result), len(expected_result)) for xpath in xpath_result: xpath_elem = xpath['element'] expected_elem_list = [ expect['element'] for expect in expected_result if expect['name'] == xpath['name'] ] # FIXME Having 2 element with the same content is not useful (>= 1 should be replaced by == 1) expect_elem = expected_elem_list[0] if len( expected_elem_list) >= 1 else None self.assertTrue(are_equals(xpath_elem, expect_elem))
def test_id_str_options_list(self): options = [ ('opt1', 'opt1', False), ('opt2', 'opt2', False), ('opt3', 'opt3', True) ] result_string = self.renderer._render_select(self.select_id, self.select_class, options) self.assertEqual( result_string, self.renderer._render_select(unicode(self.select_id), self.select_class, options) ) result_html = etree.fromstring(result_string) expected_html = self.select_data_handler.get_html('id_str_options_list') self.assertTrue(are_equals(result_html, expected_html))
def test_imbricated_elements(self): document_schema = self.subnodes_data_handler.get_xsd('imbricated') complex_type_xpath = '/xs:schema/xs:complexType' complex_type = document_schema.xpath(complex_type_xpath, namespaces=self.namespace)[0] sequence_xpath = complex_type_xpath + '/xs:sequence' element_xpath = sequence_xpath + '/xs:element' element_a = document_schema.xpath(element_xpath, namespaces=self.namespace)[0] choice_element_xpath = sequence_xpath + '/xs:choice/xs:element' choice_elements = document_schema.xpath(choice_element_xpath, namespaces=self.namespace) element_b = choice_elements[0] element_c = choice_elements[1] xpath_result = get_nodes_xpath(complex_type, document_schema) expected_result = [ { 'name': 'a', 'element': element_a }, { 'name': 'b', 'element': element_b }, { 'name': 'c', 'element': element_c }, ] self.assertEqual(len(xpath_result), len(expected_result)) for xpath in xpath_result: xpath_elem = xpath['element'] expected_elem_list = [expect['element'] for expect in expected_result if expect['name'] == xpath['name']] expect_elem = expected_elem_list[0] if len(expected_elem_list) == 1 else None self.assertTrue(are_equals(xpath_elem, expect_elem))
def test_element_ref_local(self): document_schema = self.subnodes_data_handler.get_xsd('ref_local') complex_type_xpath = '/xs:schema/xs:complexType' complex_type = document_schema.xpath(complex_type_xpath, namespaces=self.namespace)[0] element_a_xpath = complex_type_xpath + '/xs:sequence/xs:element' element_a = document_schema.xpath(element_a_xpath, namespaces=self.namespace)[0] element_r0_xpath = '/xs:schema/xs:element' element_r0 = document_schema.xpath(element_r0_xpath, namespaces=self.namespace)[0] xpath_result = get_nodes_xpath(complex_type, document_schema) expected_result = [ { 'name': 'a', 'element': element_a }, { 'name': 'r0', 'element': element_r0 }, { # FIXME the 2nd element shouldn't be here (not needed) 'name': 'r0', 'element': element_r0 } ] self.assertEqual(len(xpath_result), len(expected_result)) for xpath in xpath_result: xpath_elem = xpath['element'] expected_elem_list = [expect['element'] for expect in expected_result if expect['name'] == xpath['name']] # FIXME Having 2 element with the same content is not useful (>= 1 should be replaced by == 1) expect_elem = expected_elem_list[0] if len(expected_elem_list) >= 1 else None self.assertTrue(are_equals(xpath_elem, expect_elem))
def test_element_has_name(self): document_schema = self.subnodes_data_handler.get_xsd('name') # Retrieving the needed elements sequence_xpath = '/xs:schema/xs:complexType/xs:sequence' sequence = document_schema.xpath(sequence_xpath, namespaces=self.namespace)[0] element_xpath = sequence_xpath + '/xs:element' elements = document_schema.xpath(element_xpath, namespaces=self.namespace) element_a = elements[0] element_b = elements[1] # Building resulting and expected structures xpath_result = get_nodes_xpath(sequence, document_schema) expected_result = [{ 'name': 'a', 'element': element_a }, { 'name': 'b', 'element': element_b }] # Testing equality self.assertEqual(len(xpath_result), len(expected_result)) for xpath in xpath_result: xpath_elem = xpath['element'] expected_elem_list = [ expect['element'] for expect in expected_result if expect['name'] == xpath['name'] ] expect_elem = expected_elem_list[0] if len( expected_elem_list) == 1 else None self.assertTrue(are_equals(xpath_elem, expect_elem))
def test_reload_noncompliant_element(self): noncompliant_xml = self.occurs_data_handler.get_xml("noncompliant") occurences = lookup_occurs(self.sequence, self.document_schema, self.xml_xpath, noncompliant_xml) self.assertEqual(len(occurences), 6) occ0_expected_xml = self.occurs_data_handler.get_xml("item0") occ1_expected_xml = self.occurs_data_handler.get_xml("item1") occ2_expected_xml = self.occurs_data_handler.get_xml("item2") occ3_expected_xml = self.occurs_data_handler.get_xml("item3") occ4_expected_xml = self.occurs_data_handler.get_xml("item4") occ5_expected_xml = self.occurs_data_handler.get_xml("item5") self.assertTrue(are_equals(occurences[0], occ0_expected_xml)) self.assertTrue(are_equals(occurences[1], occ1_expected_xml)) self.assertTrue(are_equals(occurences[2], occ2_expected_xml)) self.assertTrue(are_equals(occurences[3], occ3_expected_xml)) self.assertTrue(are_equals(occurences[4], occ4_expected_xml)) self.assertTrue(are_equals(occurences[5], occ5_expected_xml))
def test_reload_noncompliant_element(self): noncompliant_xml = self.occurs_data_handler.get_xml('noncompliant') occurences = lookup_occurs(self.sequence, self.document_schema, self.xml_xpath, noncompliant_xml) self.assertEqual(len(occurences), 6) occ0_expected_xml = self.occurs_data_handler.get_xml('item0') occ1_expected_xml = self.occurs_data_handler.get_xml('item1') occ2_expected_xml = self.occurs_data_handler.get_xml('item2') occ3_expected_xml = self.occurs_data_handler.get_xml('item3') occ4_expected_xml = self.occurs_data_handler.get_xml('item4') occ5_expected_xml = self.occurs_data_handler.get_xml('item5') self.assertTrue(are_equals(occurences[0], occ0_expected_xml)) self.assertTrue(are_equals(occurences[1], occ1_expected_xml)) self.assertTrue(are_equals(occurences[2], occ2_expected_xml)) self.assertTrue(are_equals(occurences[3], occ3_expected_xml)) self.assertTrue(are_equals(occurences[4], occ4_expected_xml)) self.assertTrue(are_equals(occurences[5], occ5_expected_xml))