File: test_api.py

package info (click to toggle)
rdflib 7.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 77,580 kB
  • sloc: python: 58,671; sh: 153; makefile: 88; ruby: 74; xml: 45
file content (26 lines) | stat: -rw-r--r-- 719 bytes parent folder | download
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
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"),
        )
    ]