summaryrefslogtreecommitdiff
path: root/test/test_extras/test_infixowl/test_annotatableterms.py
blob: 1e6382673c65f470eaf7abedf09f48ab703525bd (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import pytest

from rdflib import Graph, Literal, Namespace, URIRef
from rdflib.extras.infixowl import AnnotatableTerms, Individual

EXNS = Namespace("http://example.org/vocab/")
PZNS = Namespace(
    "http://www.co-ode.org/ontologies/pizza/2005/10/18/classified/pizza.owl#"
)


@pytest.fixture(scope="function")
def graph():
    g = Graph()
    g.bind("ex", EXNS)
    Individual.factoryGraph = g

    yield g

    del g


def test_annotatableterms_comment_gettersetter(graph):

    u = URIRef(EXNS.foo)

    at = AnnotatableTerms(u, graph, EXNS.foo, True)
    comment1 = Literal("A comment")
    comment2 = Literal("Another comment")

    at.comment = comment1

    assert list(at.comment) == [comment1]

    at.comment = [comment1, comment2]

    assert list(at.comment) == [comment1, comment2]


def test_annotatableterms_seealso_gettersetter(graph):

    u = URIRef(EXNS.foo)

    at = AnnotatableTerms(u, graph, EXNS.foo, True)

    at.seeAlso = None

    seealso1 = EXNS.tarek
    seealso2 = EXNS.pizza

    at.seeAlso = [seealso1, seealso2]

    assert list(at.seeAlso) == [seealso1, seealso2]


def test_annotatableterms_label_gettersetter(graph):

    u = URIRef(EXNS.foo)

    at = AnnotatableTerms(u, graph, EXNS.foo, True)

    at.label = None

    label1 = Literal("A label")
    label2 = Literal("Another label")

    at.label = label1

    assert list(at.label) == [u, label1]

    at.label = [label1, label2]

    assert list(at.label) == [u, label1, label2]