summaryrefslogtreecommitdiff
path: root/test/test_parsers/test_trix_parse.py
blob: 89b74465776eb8b2ff263fe0eef4b906ed642493 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import os
from test.data import TEST_DATA_DIR

from rdflib.graph import ConjunctiveGraph


class TestTrixParse:
    def setup_method(self):
        pass

    def teardown_method(self):
        pass

    def testAperture(self):
        g = ConjunctiveGraph()

        trix_path = os.path.relpath(
            os.path.join(TEST_DATA_DIR, "suites", "trix/trix-aperture.trix"), os.curdir
        )
        g.parse(trix_path, format="trix")
        c = list(g.contexts())

        # print list(g.contexts())
        t = sum(map(len, g.contexts()))

        assert t == 24
        assert len(c) == 4

        # print "Parsed %d triples"%t

    def testSpec(self):
        g = ConjunctiveGraph()

        trix_path = os.path.relpath(
            os.path.join(TEST_DATA_DIR, "suites", "trix/trix-nokia-example.trix"),
            os.curdir,
        )
        g.parse(trix_path, format="trix")

        # print "Parsed %d triples"%len(g)

    def testNG4j(self):
        g = ConjunctiveGraph()

        trix_path = os.path.relpath(
            os.path.join(TEST_DATA_DIR, "suites", "trix/trix-ng4j-test-01.trix"),
            os.curdir,
        )
        g.parse(trix_path, format="trix")

        # print "Parsed %d triples"%len(g)