summaryrefslogtreecommitdiff
path: root/test/jsonld/test_api.py
blob: 5beab1fd95efe28b1ef512222f8ac0ead880d755 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: UTF-8 -*-
from rdflib import Graph, Literal, URIRef


def test_parse():
    test_json = """
    {
        "@context": {
            "dc": "http://purl.org/dc/terms/",
            "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
            "rdfs": "http://www.w3.org/2000/01/rdf-schema#"
        },
        "@id": "http://example.org/about",
        "dc:title": {
            "@language": "en",
            "@value": "Someone's Homepage"
        }
    }
    """
    g = Graph().parse(data=test_json, format="json-ld")
    assert list(g) == [
        (
            URIRef("http://example.org/about"),
            URIRef("http://purl.org/dc/terms/title"),
            Literal("Someone's Homepage", lang="en"),
        )
    ]