def test_serializing_cas_to_string(xmi, typesystem_xml): typesystem = load_typesystem(typesystem_xml) cas = load_cas_from_xmi(xmi, typesystem=typesystem) actual_xml = cas.to_xmi() assert_xml_equal(actual_xml, xmi)
def test_serializing_typesystem_to_file(tmpdir, typesystem_xml): typesystem = load_typesystem(typesystem_xml) path = str(tmpdir.join("typesystem.xml")) typesystem.to_xml(path) with open(path, "rb") as actual: assert_xml_equal(actual, typesystem_xml)
def test_serializing_cas_to_file(tmpdir, xmi, typesystem_xml): typesystem = load_typesystem(typesystem_xml) cas = load_cas_from_xmi(xmi, typesystem=typesystem) path = Path(str(tmpdir.join("cas.xml"))) cas.to_xmi(path) with path.open("r") as actual: assert_xml_equal(actual.read(), xmi)
def test_that_typesystem_with_redefined_documentation_annotation_works( typesystem_with_redefined_documentannotation_xml, ): typesystem = load_typesystem( typesystem_with_redefined_documentannotation_xml) actual_xml = typesystem.to_xml() assert_xml_equal(actual_xml, typesystem_with_redefined_documentannotation_xml)
def test_serializing_xmi_has_correct_namespaces(small_xmi, small_typesystem_xml): typesystem = load_typesystem(small_typesystem_xml) cas = load_cas_from_xmi(small_xmi, typesystem=typesystem) actual_xml = cas.to_xmi() assert_xml_equal(actual_xml, small_xmi) # Assert that the namespace is only once fully specified assert actual_xml.count('xmlns:cas="http:///uima/cas.ecore"') == 1 assert actual_xml.count("ns0") == 0
def test_serializing_typesystem_to_string(typesystem_xml): typesystem = load_typesystem(typesystem_xml) actual_xml = typesystem.to_xml() assert_xml_equal(actual_xml, typesystem_xml)