예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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
예제 #6
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)