def test_transformation_single_body_multi_target(datafiles):
    path = str(datafiles)
    test_data = os.path.join(path, "single_anno_single_body_multi_target.json")
    with open(test_data, "r") as f:
        j = json.load(f)
    chars = (
        '<a href="https://omeka.example.org/topic/virtual:person/matter">' +
        "https://omeka.example.org/topic/virtual:person/matter</a>")
    i = (
        "https://elucidate.example.org/annotation/w3c/fd8c7a22abcde179e30850b5d1f7c439/"
        + "8cbec70c-e859-4624-b1e3-1bbec5bcca85")
    result = {
        "motivation": "oa:tagging",
        "on":
        "http://waylon.example.org/work/AVT/canvas/274#xywh=659,1646,174,62",
        "@id": i,
        "@type": "oa:Annotation",
        "resource": {
            "chars": chars,
            "format": "application/html"
        },
    }
    assert (elucidate.transform_annotation(
        item=j, flatten_at_ids=True,
        transform_function=elucidate.mirador_oa) == result)
def test_transformation_single_body_simple_target():
    i = (
        "https://elucidate.example.org/annotation/w3c/fd8c7a22abcde179e30850b5d1f7c439/"
        + "8cbec70c-e859-4624-b1e3-1bbec5bcca85")
    j = {
        "id": i,
        "type": "Annotation",
        "creator": "https://montague.example.org/",
        "generator": "https://montague.example.org/",
        "body": {
            "type": "SpecificResource",
            "format": "application/html",
            "creator": "https://montague.example.org/",
            "generator": "https://montague.example.org//nlp/",
            "purpose": "tagging",
            "source": "https://omeka.example.org/topic/virtual:person/matter",
        },
        "target":
        "http://waylon.example.org/work/AVT/canvas/274#xywh=659,1646,174,62",
        "motivation": "tagging",
    }
    chars = (
        '<a href="https://omeka.example.org/topic/virtual:person/matter">' +
        "https://omeka.example.org/topic/virtual:person/matter</a>")
    result = {
        "motivation": "oa:tagging",
        "on":
        "http://waylon.example.org/work/AVT/canvas/274#xywh=659,1646,174,62",
        "@id": i,
        "@type": "oa:Annotation",
        "resource": {
            "chars": chars,
            "format": "application/html"
        },
    }
    assert (elucidate.transform_annotation(
        item=j, flatten_at_ids=True,
        transform_function=elucidate.mirador_oa) == result)
def test_transformation_no_transform(datafiles):
    path = str(datafiles)
    test_data = os.path.join(path, "single_anno.json")
    with open(test_data, "r") as f:
        j = json.load(f)
    assert elucidate.transform_annotation(item=j) == j