oldaplib 0.3.3__py3-none-any.whl → 0.3.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oldaplib/ontologies/admin-testing.trig +2 -4
- oldaplib/ontologies/admin.trig +2 -4
- oldaplib/ontologies/oldap.trig +221 -131
- oldaplib/ontologies/shared.trig +0 -3
- oldaplib/src/datamodel.py +109 -17
- oldaplib/src/dtypes/namespaceiri.py +16 -1
- oldaplib/src/enums/externalontologyattr.py +22 -0
- oldaplib/src/enums/owlpropertytype.py +10 -0
- oldaplib/src/enums/projectattr.py +0 -1
- oldaplib/src/enums/propertyclassattr.py +3 -1
- oldaplib/src/externalontology.py +554 -0
- oldaplib/src/hasproperty.py +5 -0
- oldaplib/src/helpers/context.py +4 -4
- oldaplib/src/helpers/langstring.py +11 -2
- oldaplib/src/helpers/observable_dict.py +4 -1
- oldaplib/src/helpers/observable_set.py +135 -80
- oldaplib/src/helpers/query_processor.py +3 -0
- oldaplib/src/model.py +1 -1
- oldaplib/src/oldaplist.py +2 -2
- oldaplib/src/oldaplistnode.py +2 -2
- oldaplib/src/permissionset.py +3 -3
- oldaplib/src/project.py +47 -113
- oldaplib/src/propertyclass.py +64 -24
- oldaplib/src/resourceclass.py +7 -5
- oldaplib/src/version.py +1 -1
- oldaplib/src/xsd/iri.py +3 -0
- oldaplib/src/xsd/xsd_anyuri.py +5 -5
- oldaplib/src/xsd/xsd_qname.py +5 -2
- oldaplib/test/test_context.py +0 -4
- oldaplib/test/test_datamodel.py +50 -1
- oldaplib/test/test_dtypes.py +3 -2
- oldaplib/test/test_externalontologies.py +175 -0
- oldaplib/test/test_project.py +31 -76
- oldaplib/test/test_propertyclass.py +93 -6
- oldaplib/test/test_resourceclass.py +10 -10
- oldaplib/testdata/connection_test.trig +29 -12
- oldaplib/testdata/datamodel_test.trig +1 -1
- oldaplib/testdata/objectfactory_test.trig +2 -1
- {oldaplib-0.3.3.dist-info → oldaplib-0.3.4.dist-info}/METADATA +1 -1
- {oldaplib-0.3.3.dist-info → oldaplib-0.3.4.dist-info}/RECORD +41 -38
- {oldaplib-0.3.3.dist-info → oldaplib-0.3.4.dist-info}/WHEEL +0 -0
oldaplib/test/test_dtypes.py
CHANGED
|
@@ -13,6 +13,7 @@ from oldaplib.src.helpers.numeric import Numeric
|
|
|
13
13
|
from oldaplib.src.helpers.oldaperror import OldapErrorValue, OldapErrorType
|
|
14
14
|
from oldaplib.src.helpers.query_processor import QueryProcessor
|
|
15
15
|
from oldaplib.src.helpers.serializer import serializer
|
|
16
|
+
from oldaplib.src.xsd.iri import Iri
|
|
16
17
|
from oldaplib.src.xsd.xsd import Xsd
|
|
17
18
|
from oldaplib.src.xsd.xsd_anyuri import Xsd_anyURI
|
|
18
19
|
from oldaplib.src.xsd.xsd_float import Xsd_float
|
|
@@ -93,7 +94,7 @@ class MyTestCase(unittest.TestCase):
|
|
|
93
94
|
ns1 = NamespaceIRI('http://www.org/test/')
|
|
94
95
|
self.assertEqual(str(ns1), 'http://www.org/test/')
|
|
95
96
|
self.assertEqual(repr(ns1), 'NamespaceIRI("http://www.org/test/")')
|
|
96
|
-
self.assertEqual(ns1.toRdf, '
|
|
97
|
+
self.assertEqual(ns1.toRdf, '<http://www.org/test/>')
|
|
97
98
|
self.assertEqual(ns1 + "gaga", Xsd_anyURI("http://www.org/test/gaga"))
|
|
98
99
|
|
|
99
100
|
ns2 = NamespaceIRI('http://www.org/test#')
|
|
@@ -106,7 +107,7 @@ class MyTestCase(unittest.TestCase):
|
|
|
106
107
|
|
|
107
108
|
self.create_triple("NamespaceIRI", ns1)
|
|
108
109
|
valx = self.get_triple("NamespaceIRI")
|
|
109
|
-
self.assertIsInstance(valx,
|
|
110
|
+
self.assertIsInstance(valx, Iri)
|
|
110
111
|
if isinstance(valx, Xsd_anyURI):
|
|
111
112
|
self.assertEqual(ns1, NamespaceIRI(valx))
|
|
112
113
|
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from time import sleep
|
|
4
|
+
from tkinter.font import names
|
|
5
|
+
|
|
6
|
+
from oldaplib.src.connection import Connection
|
|
7
|
+
from oldaplib.src.datamodel import DataModel
|
|
8
|
+
from oldaplib.src.dtypes.namespaceiri import NamespaceIRI
|
|
9
|
+
from oldaplib.src.enums.language import Language
|
|
10
|
+
from oldaplib.src.externalontology import ExternalOntology
|
|
11
|
+
from oldaplib.src.helpers.context import Context
|
|
12
|
+
from oldaplib.src.helpers.langstring import LangString
|
|
13
|
+
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapError, OldapErrorImmutable
|
|
14
|
+
from oldaplib.src.project import Project
|
|
15
|
+
from oldaplib.src.xsd.iri import Iri
|
|
16
|
+
from oldaplib.src.xsd.xsd_qname import Xsd_QName
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def find_project_root(current_path):
|
|
20
|
+
# Climb up the directory hierarchy and check for a marker file
|
|
21
|
+
path = Path(current_path).absolute()
|
|
22
|
+
while not (path / 'pyproject.toml').exists():
|
|
23
|
+
if path.parent == path:
|
|
24
|
+
# Root of the filesystem, file not found
|
|
25
|
+
raise RuntimeError('Project root not found')
|
|
26
|
+
path = path.parent
|
|
27
|
+
return path
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TestexternalOntologies(unittest.TestCase):
|
|
31
|
+
|
|
32
|
+
_connection: Connection
|
|
33
|
+
_unpriv: Connection
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def setUpClass(cls):
|
|
37
|
+
super().setUpClass()
|
|
38
|
+
project_root = find_project_root(__file__)
|
|
39
|
+
cls._context = Context(name="DEFAULT")
|
|
40
|
+
|
|
41
|
+
cls._connection = Connection(userId="rosenth",
|
|
42
|
+
credentials="RioGrande",
|
|
43
|
+
context_name="DEFAULT")
|
|
44
|
+
cls._unpriv = Connection(userId="fornaro",
|
|
45
|
+
credentials="RioGrande",
|
|
46
|
+
context_name="DEFAULT")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
cls._connection.clear_graph(Xsd_QName('oldap:admin'))
|
|
50
|
+
file = project_root / 'oldaplib' / 'ontologies' / 'admin.trig'
|
|
51
|
+
cls._connection.upload_turtle(file)
|
|
52
|
+
file = project_root / 'oldaplib' / 'ontologies' / 'admin-testing.trig'
|
|
53
|
+
cls._connection.upload_turtle(file)
|
|
54
|
+
sleep(1) # upload may take a while...
|
|
55
|
+
|
|
56
|
+
project = Project(con=cls._connection,
|
|
57
|
+
projectIri=Iri("http://extonto.test.org/test"),
|
|
58
|
+
projectShortName="testext",
|
|
59
|
+
namespaceIri=NamespaceIRI("http://extonto.test.org/test/ns/"))
|
|
60
|
+
project.create()
|
|
61
|
+
|
|
62
|
+
dm = DataModel(con=cls._connection, project=project)
|
|
63
|
+
dm.create()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def tearDownClass(cls):
|
|
68
|
+
cls._connection.clear_graph(Xsd_QName('testext:shacl'))
|
|
69
|
+
cls._connection.clear_graph(Xsd_QName('testext:onto'))
|
|
70
|
+
#cls._connection.upload_turtle("oldaplib/ontologies/admin.trig")
|
|
71
|
+
#sleep(1) # upload may take a while...
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
def test_create(self):
|
|
75
|
+
p = Project.read(con=self._connection, projectIri_SName="testext", ignore_cache=True)
|
|
76
|
+
dm = DataModel.read(con=self._connection, project="testext", ignore_cache=True)
|
|
77
|
+
|
|
78
|
+
eo1 = ExternalOntology(con=self._connection,
|
|
79
|
+
projectShortName="testext",
|
|
80
|
+
prefix="gagaA",
|
|
81
|
+
label=LangString("GAGA A ontology@en", "Gaga A Ontologie@de"),
|
|
82
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaA/"))
|
|
83
|
+
eo1.create()
|
|
84
|
+
del eo1
|
|
85
|
+
|
|
86
|
+
eo1 = ExternalOntology.read(con=self._connection, projectShortName="testext", prefix="gagaA", ignore_cache=True)
|
|
87
|
+
self.assertEqual(eo1.prefix, "gagaA")
|
|
88
|
+
self.assertEqual(eo1.label, LangString("GAGA A ontology@en", "Gaga A Ontologie@de"))
|
|
89
|
+
self.assertEqual(eo1.namespaceIri, NamespaceIRI("http://gaga.org/ns/gagaA/"))
|
|
90
|
+
|
|
91
|
+
ExternalOntology.delete_all(con=self._connection, projectShortName="testext")
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_update(self):
|
|
96
|
+
p = Project.read(con=self._connection, projectIri_SName="testext", ignore_cache=True)
|
|
97
|
+
dm = DataModel.read(con=self._connection, project="testext", ignore_cache=True)
|
|
98
|
+
|
|
99
|
+
eo1 = ExternalOntology(con=self._connection,
|
|
100
|
+
projectShortName="testext",
|
|
101
|
+
prefix="gagaB",
|
|
102
|
+
label=LangString("GAGA B ontology@en", "Gaga B Ontologie@de"),
|
|
103
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaB/"))
|
|
104
|
+
eo1.create()
|
|
105
|
+
|
|
106
|
+
del eo1
|
|
107
|
+
eo1 = ExternalOntology.read(con=self._connection, projectShortName="testext", prefix="gagaB", ignore_cache=True)
|
|
108
|
+
eo1.prefix = "gugus"
|
|
109
|
+
eo1.comment = LangString("Gugus comment@en", "Gugus Kommentar@de")
|
|
110
|
+
del eo1.label[Language.DE]
|
|
111
|
+
eo1.label[Language.FR] = "GAGA B ontologie"
|
|
112
|
+
eo1.update()
|
|
113
|
+
|
|
114
|
+
del eo1
|
|
115
|
+
eo1 = ExternalOntology.read(con=self._connection, projectShortName="testext", prefix="gagaB", ignore_cache=True)
|
|
116
|
+
self.assertEqual(eo1.prefix, "gugus")
|
|
117
|
+
self.assertEqual(eo1.label, LangString("GAGA B ontology@en", "GAGA B ontologie@fr"))
|
|
118
|
+
self.assertEqual(eo1.comment, LangString("Gugus comment@en", "Gugus Kommentar@de"))
|
|
119
|
+
self.assertEqual(eo1.namespaceIri, NamespaceIRI("http://gaga.org/ns/gagaB/"))
|
|
120
|
+
|
|
121
|
+
with self.assertRaises(OldapErrorImmutable):
|
|
122
|
+
eo1.namespaceIri = NamespaceIRI("http://gaga.org/ns/gaga2/new/")
|
|
123
|
+
|
|
124
|
+
ExternalOntology.delete_all(con=self._connection, projectShortName="testext")
|
|
125
|
+
|
|
126
|
+
def test_search(self):
|
|
127
|
+
p = Project.read(con=self._connection, projectIri_SName="testext", ignore_cache=True)
|
|
128
|
+
dm = DataModel.read(con=self._connection, project="testext", ignore_cache=True)
|
|
129
|
+
|
|
130
|
+
eo1 = ExternalOntology(con=self._connection,
|
|
131
|
+
projectShortName="testext",
|
|
132
|
+
prefix="gagaC",
|
|
133
|
+
label=LangString("GAGA C ontology@en", "Gaga C Ontologie@de"),
|
|
134
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaC/"))
|
|
135
|
+
eo1.create()
|
|
136
|
+
|
|
137
|
+
eo2 = ExternalOntology(con=self._connection,
|
|
138
|
+
projectShortName="testext",
|
|
139
|
+
prefix="gagaD",
|
|
140
|
+
label=LangString("GAGA D ontology@en", "Gaga D Ontologie@de"),
|
|
141
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaD/"))
|
|
142
|
+
eo2.create()
|
|
143
|
+
|
|
144
|
+
res = ExternalOntology.search(con=self._connection, projectShortName="testext")
|
|
145
|
+
qnames = [x.extonto_qname for x in res]
|
|
146
|
+
self.assertEqual(set(qnames), {Xsd_QName('testext:gagaC'), Xsd_QName('testext:gagaD')})
|
|
147
|
+
|
|
148
|
+
ExternalOntology.delete_all(con=self._connection, projectShortName="testext")
|
|
149
|
+
|
|
150
|
+
def test_delete(self):
|
|
151
|
+
p = Project.read(con=self._connection, projectIri_SName="testext", ignore_cache=True)
|
|
152
|
+
dm = DataModel.read(con=self._connection, project="testext", ignore_cache=True)
|
|
153
|
+
|
|
154
|
+
eo1 = ExternalOntology(con=self._connection,
|
|
155
|
+
projectShortName="testext",
|
|
156
|
+
prefix="gagaE",
|
|
157
|
+
label=LangString("GAGA E ontology@en", "Gaga E Ontologie@de"),
|
|
158
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaE/"))
|
|
159
|
+
eo1.create()
|
|
160
|
+
|
|
161
|
+
eo2 = ExternalOntology(con=self._connection,
|
|
162
|
+
projectShortName="testext",
|
|
163
|
+
prefix="gagaF",
|
|
164
|
+
label=LangString("GAGA F ontology@en", "Gaga F Ontologie@de"),
|
|
165
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaF/"))
|
|
166
|
+
eo2.create()
|
|
167
|
+
res = ExternalOntology.search(con=self._connection, projectShortName="testext", prefix="gagaF")
|
|
168
|
+
self.assertEqual(len(res), 1)
|
|
169
|
+
res[0].delete()
|
|
170
|
+
|
|
171
|
+
ExternalOntology.delete_all(con=self._connection, projectShortName="testext")
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
oldaplib/test/test_project.py
CHANGED
|
@@ -16,7 +16,8 @@ from oldaplib.src.xsd.xsd_qname import Xsd_QName
|
|
|
16
16
|
from oldaplib.src.xsd.xsd_ncname import Xsd_NCName
|
|
17
17
|
from oldaplib.src.xsd.xsd_date import Xsd_date
|
|
18
18
|
from oldaplib.src.helpers.langstring import LangString
|
|
19
|
-
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorInconsistency, OldapErrorNoPermission
|
|
19
|
+
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorInconsistency, OldapErrorNoPermission, \
|
|
20
|
+
OldapErrorAlreadyExists
|
|
20
21
|
from oldaplib.src.project import Project, ProjectSearchResult
|
|
21
22
|
from oldaplib.src.helpers.serializer import serializer
|
|
22
23
|
|
|
@@ -90,6 +91,9 @@ class Testproject(unittest.TestCase):
|
|
|
90
91
|
self.assertEqual(project.projectEnd, project2.projectEnd)
|
|
91
92
|
|
|
92
93
|
|
|
94
|
+
def test_project_read_with_uses_ontologies(self):
|
|
95
|
+
project = Project.read(con=self._connection, projectIri_SName="hyha", ignore_cache=True)
|
|
96
|
+
|
|
93
97
|
# @unittest.skip('Work in progress')
|
|
94
98
|
def test_project_read(self):
|
|
95
99
|
project = Project.read(con=self._connection, projectIri_SName=Iri("oldap:SystemProject"), ignore_cache=True)
|
|
@@ -260,83 +264,33 @@ class Testproject(unittest.TestCase):
|
|
|
260
264
|
project = Project.read(con=self._connection, projectIri_SName="unittest6", ignore_cache=True)
|
|
261
265
|
project.delete()
|
|
262
266
|
|
|
263
|
-
def
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
project.create()
|
|
276
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesA", ignore_cache=True)
|
|
277
|
-
self.assertEqual(project.usesExternalOntology, {
|
|
278
|
-
Xsd_NCName("prefix1"): NamespaceIRI("http://prefix1.org/"),
|
|
279
|
-
Xsd_NCName("prefix2"): NamespaceIRI("http://prefix2.org/")
|
|
280
|
-
})
|
|
267
|
+
def test_duplicate_project_create(self):
|
|
268
|
+
project1 = Project(con=self._connection,
|
|
269
|
+
projectShortName="unittestXX",
|
|
270
|
+
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestXX#"),
|
|
271
|
+
label=LangString(["unittestXX@en", "unittestXX@de"]))
|
|
272
|
+
project1.create()
|
|
273
|
+
project2 = Project(con=self._connection,
|
|
274
|
+
projectShortName="unittestXX",
|
|
275
|
+
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestYY#"),
|
|
276
|
+
label=LangString(["unittestXX@en", "unittestXX@de"]))
|
|
277
|
+
with self.assertRaises(OldapErrorAlreadyExists) as ex:
|
|
278
|
+
project2.create()
|
|
281
279
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
projectStart=Xsd_date(2024, 3, 3),
|
|
289
|
-
projectEnd=Xsd_date(2027, 3, 2),
|
|
290
|
-
usesExternalOntology={
|
|
291
|
-
Xsd_NCName("prefix1"): NamespaceIRI("http://prefix1.org/"),
|
|
292
|
-
Xsd_NCName("prefix2"): NamespaceIRI("http://prefix2.org/")
|
|
293
|
-
})
|
|
294
|
-
project.create()
|
|
295
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesB", ignore_cache=True)
|
|
296
|
-
del project.usesExternalOntology
|
|
297
|
-
project.update()
|
|
298
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesB", ignore_cache=True)
|
|
299
|
-
self.assertIsNone(project.usesExternalOntology)
|
|
300
|
-
|
|
301
|
-
def test_project_create_with_external_ontologies_C(self):
|
|
302
|
-
project = Project(con=self._connection,
|
|
303
|
-
projectShortName="WithExternalOntologiesC",
|
|
304
|
-
label=LangString("External Ontologies"),
|
|
305
|
-
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestXX#"),
|
|
306
|
-
comment=LangString(["For testingXX@en", "Für TestsXX@de"]),
|
|
307
|
-
projectStart=Xsd_date(2024, 3, 3),
|
|
308
|
-
projectEnd=Xsd_date(2027, 3, 2))
|
|
309
|
-
project.create()
|
|
310
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesC", ignore_cache=True)
|
|
311
|
-
project.usesExternalOntology = {Xsd_NCName('prefix') : NamespaceIRI('http://prefix.org/')}
|
|
312
|
-
project.update()
|
|
313
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesC", ignore_cache=True)
|
|
314
|
-
self.assertEqual(project.usesExternalOntology, {Xsd_NCName('prefix') : NamespaceIRI('http://prefix.org/')})
|
|
315
|
-
|
|
316
|
-
def test_project_create_with_external_ontologies_D(self):
|
|
317
|
-
project = Project(con=self._connection,
|
|
318
|
-
projectShortName="WithExternalOntologiesD",
|
|
319
|
-
label=LangString("External Ontologies"),
|
|
320
|
-
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestXX#"),
|
|
321
|
-
comment=LangString(["For testingXX@en", "Für TestsXX@de"]),
|
|
322
|
-
projectStart=Xsd_date(2024, 3, 3),
|
|
323
|
-
projectEnd=Xsd_date(2027, 3, 2),
|
|
324
|
-
usesExternalOntology={
|
|
325
|
-
Xsd_NCName("prefix1"): NamespaceIRI("http://prefix1.org/"),
|
|
326
|
-
Xsd_NCName("prefix2"): NamespaceIRI("http://prefix2.org/")
|
|
327
|
-
})
|
|
328
|
-
project.create()
|
|
329
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesD", ignore_cache=True)
|
|
330
|
-
del project.usesExternalOntology['prefix1']
|
|
331
|
-
project.usesExternalOntology[Xsd_NCName('prefix2')] = NamespaceIRI("http://prefix2.org/CHANGED/")
|
|
332
|
-
project.usesExternalOntology[Xsd_NCName('prefix3')] = NamespaceIRI("http://prefix3.org/")
|
|
333
|
-
project.update()
|
|
334
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesD", ignore_cache=True)
|
|
335
|
-
self.assertEqual(project.usesExternalOntology, {
|
|
336
|
-
Xsd_NCName("prefix2"): NamespaceIRI("http://prefix2.org/CHANGED/"),
|
|
337
|
-
Xsd_NCName("prefix3"): NamespaceIRI("http://prefix3.org/")
|
|
338
|
-
})
|
|
280
|
+
project3 = Project(con=self._connection,
|
|
281
|
+
projectShortName="unittestYY",
|
|
282
|
+
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestXX#"),
|
|
283
|
+
label=LangString(["unittestXX@en", "unittestXX@de"]))
|
|
284
|
+
with self.assertRaises(OldapErrorAlreadyExists) as ex:
|
|
285
|
+
project3.create()
|
|
339
286
|
|
|
287
|
+
project4 = Project(con=self._connection,
|
|
288
|
+
projectIri=project1.projectIri,
|
|
289
|
+
projectShortName="unittestZZ",
|
|
290
|
+
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestZZ#"),
|
|
291
|
+
label=LangString(["unittestZZ@en", "unittestZZ@de"]))
|
|
292
|
+
with self.assertRaises(OldapErrorAlreadyExists) as ex:
|
|
293
|
+
project4.create()
|
|
340
294
|
|
|
341
295
|
def test_project_create_without_label_comment(self):
|
|
342
296
|
project = Project(con=self._connection,
|
|
@@ -352,6 +306,7 @@ class Testproject(unittest.TestCase):
|
|
|
352
306
|
project = Project.read(con=self._connection, projectIri_SName="emptyfieldsXX", ignore_cache=True)
|
|
353
307
|
project.delete()
|
|
354
308
|
|
|
309
|
+
|
|
355
310
|
def test_project_create_empty_fields(self):
|
|
356
311
|
project = Project(con=self._connection,
|
|
357
312
|
projectShortName="emptyfields1",
|
|
@@ -16,6 +16,7 @@ from oldaplib.src.enums.propertyclassattr import PropClassAttr
|
|
|
16
16
|
from oldaplib.src.enums.xsd_datatypes import XsdDatatypes
|
|
17
17
|
from oldaplib.src.helpers.context import Context
|
|
18
18
|
from oldaplib.src.helpers.langstring import LangString, LangStringChange
|
|
19
|
+
from oldaplib.src.helpers.observable_set import ObservableSet
|
|
19
20
|
from oldaplib.src.helpers.oldaperror import OldapErrorAlreadyExists, OldapErrorValue, OldapErrorNoPermission, \
|
|
20
21
|
OldapErrorInconsistency
|
|
21
22
|
from oldaplib.src.helpers.query_processor import QueryProcessor
|
|
@@ -70,6 +71,8 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
70
71
|
cls._connection.upload_turtle(file)
|
|
71
72
|
sleep(1) # upload may take a while...
|
|
72
73
|
cls._project = Project.read(cls._connection, "test")
|
|
74
|
+
cls._sysproject = Project.read(cls._connection, "oldap")
|
|
75
|
+
|
|
73
76
|
|
|
74
77
|
@classmethod
|
|
75
78
|
def tearDownClass(cls):
|
|
@@ -90,6 +93,7 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
90
93
|
self.assertEqual(p.get(PropClassAttr.DATATYPE), XsdDatatypes.string)
|
|
91
94
|
self.assertEqual(p.get(PropClassAttr.NAME), LangString(["Test property@en", "Testprädikat@de"]))
|
|
92
95
|
self.assertEqual(p.get(PropClassAttr.DESCRIPTION), LangString("A property for testing...@en", "Property für Tests@de"))
|
|
96
|
+
self.assertEqual(p.get(PropClassAttr.TYPE), {OwlPropertyType.OwlDataProperty})
|
|
93
97
|
|
|
94
98
|
def test_star_propertyclass_constructor(self):
|
|
95
99
|
p = PropertyClass(con=self._connection,
|
|
@@ -104,6 +108,7 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
104
108
|
self.assertEqual(p.get(PropClassAttr.DATATYPE), XsdDatatypes.string)
|
|
105
109
|
self.assertEqual(p.get(PropClassAttr.NAME), LangString(["Test property@en", "Testprädikat@de"]))
|
|
106
110
|
self.assertEqual(p.get(PropClassAttr.DESCRIPTION), LangString("A property for testing...@en", "Property für Tests@de"))
|
|
111
|
+
self.assertEqual(p[PropClassAttr.TYPE], {OwlPropertyType.StatementProperty, OwlPropertyType.OwlDataProperty})
|
|
107
112
|
|
|
108
113
|
def test_propertyclass_inset_datatypes(self):
|
|
109
114
|
p = PropertyClass(con=self._connection,
|
|
@@ -166,6 +171,7 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
166
171
|
project=self._project,
|
|
167
172
|
toClass=Xsd_QName('test:Person'))
|
|
168
173
|
self.assertEqual(p2.get(PropClassAttr.CLASS), Xsd_QName('test:Person'))
|
|
174
|
+
self.assertEqual(p2.get(PropClassAttr.TYPE), {OwlPropertyType.OwlObjectProperty})
|
|
169
175
|
|
|
170
176
|
def test_propertyclass_toclass_constructor_invalid_A(self):
|
|
171
177
|
with self.assertRaises(OldapErrorValue):
|
|
@@ -212,6 +218,24 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
212
218
|
self.assertEqual(p4a.get(PropClassAttr.LANGUAGE_IN), LanguageIn(Language.EN, Language.FR))
|
|
213
219
|
self.assertEqual(p4a.get(PropClassAttr.DATATYPE), XsdDatatypes.langString)
|
|
214
220
|
|
|
221
|
+
def test_propertyclass_owltype_constructor(self):
|
|
222
|
+
p4 = PropertyClass(con=self._connection,
|
|
223
|
+
project=self._project,
|
|
224
|
+
property_class_iri=Xsd_QName('test:testprop4c'),
|
|
225
|
+
type={OwlPropertyType.SymmetricProperty},
|
|
226
|
+
datatype=XsdDatatypes.string)
|
|
227
|
+
p4.create()
|
|
228
|
+
self.assertEqual(p4.get(PropClassAttr.TYPE), {OwlPropertyType.SymmetricProperty, OwlPropertyType.OwlDataProperty})
|
|
229
|
+
p4 = PropertyClass.read(con=self._connection,
|
|
230
|
+
project=self._project,
|
|
231
|
+
property_class_iri=Xsd_QName('test:testprop4c'),
|
|
232
|
+
ignore_cache=True)
|
|
233
|
+
self.assertEqual(p4.get(PropClassAttr.TYPE), {OwlPropertyType.SymmetricProperty, OwlPropertyType.OwlDataProperty})
|
|
234
|
+
|
|
235
|
+
p4.type.add(OwlPropertyType.TransitiveProperty)
|
|
236
|
+
p4.update()
|
|
237
|
+
self.assertEqual(p4.get(PropClassAttr.TYPE), {OwlPropertyType.SymmetricProperty, OwlPropertyType.TransitiveProperty, OwlPropertyType.OwlDataProperty})
|
|
238
|
+
|
|
215
239
|
def test_propertyclass_inconsistent_constructor(self):
|
|
216
240
|
with self.assertRaises(OldapErrorValue):
|
|
217
241
|
p5 = PropertyClass(con=self._connection,
|
|
@@ -238,6 +262,12 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
238
262
|
self.assertEqual(p6.get(PropClassAttr.DATATYPE), XsdDatatypes.langString)
|
|
239
263
|
|
|
240
264
|
|
|
265
|
+
def test_propertyclass_read_projectshape(self):
|
|
266
|
+
p = PropertyClass.read(con=self._connection,
|
|
267
|
+
project=self._sysproject,
|
|
268
|
+
property_class_iri=Xsd_QName('oldap:namespaceIri'),
|
|
269
|
+
ignore_cache=True)
|
|
270
|
+
|
|
241
271
|
# @unittest.skip('Work in progress')
|
|
242
272
|
def test_propertyclass_read_shacl(self):
|
|
243
273
|
p1 = PropertyClass.read(con=self._connection,
|
|
@@ -255,8 +285,8 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
255
285
|
self.assertEqual(p1.description, LangString("This is a test property@de"))
|
|
256
286
|
self.assertIsNone(p1.get(PropClassAttr.SUBPROPERTY_OF))
|
|
257
287
|
self.assertIsNone(p1.subPropertyOf)
|
|
258
|
-
self.assertEqual(p1.get(PropClassAttr.TYPE), OwlPropertyType.OwlDataProperty)
|
|
259
|
-
self.assertEqual(p1.type, OwlPropertyType.OwlDataProperty)
|
|
288
|
+
self.assertEqual(p1.get(PropClassAttr.TYPE), {OwlPropertyType.OwlDataProperty})
|
|
289
|
+
self.assertEqual(p1.type, {OwlPropertyType.OwlDataProperty})
|
|
260
290
|
self.assertEqual(p1.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
261
291
|
self.assertEqual(p1.created, Xsd_dateTime("2023-11-04T12:00:00Z"))
|
|
262
292
|
|
|
@@ -268,7 +298,7 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
268
298
|
self.assertEqual(p2[PropClassAttr.NAME], LangString("Test"))
|
|
269
299
|
self.assertEqual(p2[PropClassAttr.DESCRIPTION], LangString("Property shape for testing purposes"))
|
|
270
300
|
self.assertEqual(p2[PropClassAttr.DATATYPE], XsdDatatypes.string)
|
|
271
|
-
self.assertEqual(p2[PropClassAttr.TYPE], OwlPropertyType.OwlDataProperty)
|
|
301
|
+
self.assertEqual(p2[PropClassAttr.TYPE], {OwlPropertyType.OwlDataProperty})
|
|
272
302
|
|
|
273
303
|
p3 = PropertyClass.read(con=self._connection,
|
|
274
304
|
project=self._project,
|
|
@@ -342,14 +372,20 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
342
372
|
def test_propertyclass_create_D(self):
|
|
343
373
|
pX = PropertyClass(
|
|
344
374
|
con=self._connection,
|
|
345
|
-
#graph=Xsd_NCName('test'),
|
|
346
375
|
project=self._project,
|
|
347
|
-
property_class_iri=Xsd_QName('test:
|
|
376
|
+
property_class_iri=Xsd_QName('test:testWriteABC'),
|
|
377
|
+
datatype=XsdDatatypes.int
|
|
378
|
+
)
|
|
379
|
+
pX.create()
|
|
380
|
+
pX = PropertyClass(
|
|
381
|
+
con=self._connection,
|
|
382
|
+
project=self._project,
|
|
383
|
+
property_class_iri=Xsd_QName('test:testWriteABC'),
|
|
348
384
|
datatype=XsdDatatypes.int
|
|
349
385
|
)
|
|
350
386
|
with self.assertRaises(OldapErrorAlreadyExists) as ex:
|
|
351
387
|
pX.create()
|
|
352
|
-
self.assertEqual(str(ex.exception), 'Property "test:
|
|
388
|
+
self.assertEqual(str(ex.exception), 'Property "test:testWriteABC" already exists.')
|
|
353
389
|
|
|
354
390
|
def test_propertyclass_create_E(self):
|
|
355
391
|
p = PropertyClass(
|
|
@@ -367,6 +403,19 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
367
403
|
self.assertTrue(p.statementProperty)
|
|
368
404
|
self.assertEqual(p.get(PropClassAttr.DATATYPE), XsdDatatypes.string)
|
|
369
405
|
|
|
406
|
+
def test_propertyclass_create_F(self):
|
|
407
|
+
p4 = PropertyClass(con=self._connection,
|
|
408
|
+
project=self._project,
|
|
409
|
+
property_class_iri=Xsd_QName('test:testpropF'),
|
|
410
|
+
type={OwlPropertyType.SymmetricProperty},
|
|
411
|
+
datatype=XsdDatatypes.string)
|
|
412
|
+
p4.create()
|
|
413
|
+
p4 = PropertyClass.read(con=self._connection,
|
|
414
|
+
project=self._project,
|
|
415
|
+
property_class_iri=Xsd_QName('test:testpropF'),
|
|
416
|
+
ignore_cache=True)
|
|
417
|
+
self.assertEqual(p4.get(PropClassAttr.TYPE), {OwlPropertyType.SymmetricProperty, OwlPropertyType.OwlDataProperty})
|
|
418
|
+
|
|
370
419
|
def test_propertyclass_create_nopermission(self):
|
|
371
420
|
p1 = PropertyClass(
|
|
372
421
|
con=self._unpriv,
|
|
@@ -763,6 +812,44 @@ class TestPropertyClass(unittest.TestCase):
|
|
|
763
812
|
for r in res:
|
|
764
813
|
self.assertIn(r['comment'], [Xsd_string("description english@en"), Xsd_string("description français@fr")])
|
|
765
814
|
|
|
815
|
+
def test_propertyclass_update7(self):
|
|
816
|
+
p7 = PropertyClass(con=self._connection,
|
|
817
|
+
project=self._project,
|
|
818
|
+
property_class_iri=Xsd_QName('test:testprop7'),
|
|
819
|
+
type={OwlPropertyType.SymmetricProperty},
|
|
820
|
+
datatype=XsdDatatypes.string)
|
|
821
|
+
p7.create()
|
|
822
|
+
p7 = PropertyClass.read(con=self._connection,
|
|
823
|
+
project=self._project,
|
|
824
|
+
property_class_iri=Xsd_QName('test:testprop7'),
|
|
825
|
+
ignore_cache=True)
|
|
826
|
+
p7.type.add(OwlPropertyType.TransitiveProperty)
|
|
827
|
+
p7.update()
|
|
828
|
+
p7 = PropertyClass.read(con=self._connection,
|
|
829
|
+
project=self._project,
|
|
830
|
+
property_class_iri=Xsd_QName('test:testprop7'),
|
|
831
|
+
ignore_cache=True)
|
|
832
|
+
self.assertEqual(p7.get(PropClassAttr.TYPE), {OwlPropertyType.SymmetricProperty, OwlPropertyType.TransitiveProperty, OwlPropertyType.OwlDataProperty})
|
|
833
|
+
|
|
834
|
+
def test_propertyclass_update8(self):
|
|
835
|
+
p8 = PropertyClass(con=self._connection,
|
|
836
|
+
project=self._project,
|
|
837
|
+
property_class_iri=Xsd_QName('test:testprop8'),
|
|
838
|
+
type={OwlPropertyType.SymmetricProperty, OwlPropertyType.TransitiveProperty},
|
|
839
|
+
datatype=XsdDatatypes.string)
|
|
840
|
+
p8.create()
|
|
841
|
+
p8 = PropertyClass.read(con=self._connection,
|
|
842
|
+
project=self._project,
|
|
843
|
+
property_class_iri=Xsd_QName('test:testprop8'),
|
|
844
|
+
ignore_cache=True)
|
|
845
|
+
p8.type.remove(OwlPropertyType.TransitiveProperty)
|
|
846
|
+
p8.update()
|
|
847
|
+
p8 = PropertyClass.read(con=self._connection,
|
|
848
|
+
project=self._project,
|
|
849
|
+
property_class_iri=Xsd_QName('test:testprop8'),
|
|
850
|
+
ignore_cache=True)
|
|
851
|
+
self.assertEqual(p8.get(PropClassAttr.TYPE), {OwlPropertyType.SymmetricProperty, OwlPropertyType.OwlDataProperty})
|
|
852
|
+
|
|
766
853
|
# @unittest.skip('Work in progress')
|
|
767
854
|
def test_propertyclass_delete_attrs(self):
|
|
768
855
|
p1 = PropertyClass(
|
|
@@ -212,7 +212,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
212
212
|
self.assertEqual(r1[Xsd_QName("test:testprop")].order, Xsd_decimal(3))
|
|
213
213
|
self.assertEqual(prop3.internal, Xsd_QName('test:TestResource'))
|
|
214
214
|
self.assertEqual(prop3.property_class_iri, Xsd_QName("test:testprop"))
|
|
215
|
-
self.assertEqual(prop3.type, OwlPropertyType.OwlDataProperty)
|
|
215
|
+
self.assertEqual(prop3.type, {OwlPropertyType.OwlDataProperty})
|
|
216
216
|
self.assertEqual(prop3.datatype, XsdDatatypes.langString)
|
|
217
217
|
self.assertEqual(prop3.name, LangString(["Test property@en", "Testprädikat@de"]))
|
|
218
218
|
self.assertEqual(prop3.subPropertyOf, Xsd_QName("test:comment"))
|
|
@@ -657,7 +657,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
657
657
|
self.assertEqual(prop1.created, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
658
658
|
self.assertEqual(prop1.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
659
659
|
self.assertEqual(prop1.modified, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
660
|
-
self.assertEqual(prop1.type, OwlPropertyType.OwlDataProperty)
|
|
660
|
+
self.assertEqual(prop1.type, {OwlPropertyType.OwlDataProperty})
|
|
661
661
|
self.assertEqual(prop1.datatype, XsdDatatypes.string)
|
|
662
662
|
self.assertEqual(prop1.description, LangString("Property shape for testing purposes"))
|
|
663
663
|
self.assertEqual(r1[Xsd_QName('test:test')].minCount, Xsd_integer(1))
|
|
@@ -671,7 +671,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
671
671
|
self.assertEqual(prop2.created, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
672
672
|
self.assertEqual(prop2.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
673
673
|
self.assertEqual(prop2.modified, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
674
|
-
self.assertEqual(prop2.type, OwlPropertyType.OwlDataProperty)
|
|
674
|
+
self.assertEqual(prop2.type, {OwlPropertyType.OwlDataProperty})
|
|
675
675
|
self.assertEqual(prop2.datatype, XsdDatatypes.langString)
|
|
676
676
|
self.assertEqual(prop2.name, LangString(["A text@en", "Ein Text@de"]))
|
|
677
677
|
self.assertEqual(prop2.description, LangString("A longer text..."))
|
|
@@ -680,7 +680,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
680
680
|
self.assertEqual(r1[Xsd_QName('test:hasText')].order, Xsd_decimal(1))
|
|
681
681
|
|
|
682
682
|
prop3 = r1[Xsd_QName('test:hasEnum')].prop
|
|
683
|
-
self.assertEqual(prop3.type, OwlPropertyType.OwlDataProperty)
|
|
683
|
+
self.assertEqual(prop3.type, {OwlPropertyType.OwlDataProperty})
|
|
684
684
|
self.assertEqual(prop3.datatype, XsdDatatypes.string)
|
|
685
685
|
self.assertEqual(prop3.inSet,
|
|
686
686
|
RdfSet(Xsd_string('red'), Xsd_string('green'), Xsd_string('blue'), Xsd_string('yellow')))
|
|
@@ -826,7 +826,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
826
826
|
self.assertEqual(prop1.name, LangString(["comment@en", "Kommentar@de"]))
|
|
827
827
|
self.assertEqual(prop1.description, LangString("This is a test property@de"))
|
|
828
828
|
self.assertIsNone(prop1.subPropertyOf)
|
|
829
|
-
self.assertEqual(prop1.type, OwlPropertyType.OwlDataProperty)
|
|
829
|
+
self.assertEqual(prop1.type, {OwlPropertyType.OwlDataProperty})
|
|
830
830
|
self.assertEqual(prop1.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
831
831
|
self.assertEqual(prop1.created, Xsd_dateTime("2023-11-04T12:00:00Z"))
|
|
832
832
|
self.assertEqual(r2[Xsd_QName("test:comment")].order, Xsd_decimal(1))
|
|
@@ -838,7 +838,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
838
838
|
self.assertEqual(prop2.name, LangString("Test"))
|
|
839
839
|
self.assertEqual(prop2.description, LangString("Property shape for testing purposes"))
|
|
840
840
|
self.assertEqual(prop2.datatype, XsdDatatypes.string)
|
|
841
|
-
self.assertEqual(prop2.type, OwlPropertyType.OwlDataProperty)
|
|
841
|
+
self.assertEqual(prop2.type, {OwlPropertyType.OwlDataProperty})
|
|
842
842
|
self.assertEqual(r2[Xsd_QName("test:test")].order, Xsd_decimal(2))
|
|
843
843
|
|
|
844
844
|
prop3 = r2[Xsd_QName("test:testone")].prop
|
|
@@ -1159,7 +1159,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1159
1159
|
self.assertEqual(prop1.description, LangString("Property shape for testing purposes"))
|
|
1160
1160
|
self.assertEqual(prop1.datatype, XsdDatatypes.string)
|
|
1161
1161
|
self.assertEqual(r2[Xsd_QName('test:test')].order, Xsd_decimal(3))
|
|
1162
|
-
self.assertEqual(prop1.type, OwlPropertyType.OwlDataProperty)
|
|
1162
|
+
self.assertEqual(prop1.type, {OwlPropertyType.OwlDataProperty})
|
|
1163
1163
|
|
|
1164
1164
|
def test_updating_add_int_prop(self):
|
|
1165
1165
|
r1 = ResourceClass.read(con=self._connection,
|
|
@@ -1185,7 +1185,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1185
1185
|
self.assertEqual(prop1.internal, Xsd_QName("test:testMyResMinimalB"))
|
|
1186
1186
|
self.assertEqual(prop1.toClass, Xsd_QName('test:Person'))
|
|
1187
1187
|
self.assertEqual(r2[Xsd_QName('dcterms:contributor')].maxCount, Xsd_integer(1))
|
|
1188
|
-
self.assertEqual(prop1.type, OwlPropertyType.OwlObjectProperty)
|
|
1188
|
+
self.assertEqual(prop1.type, {OwlPropertyType.OwlObjectProperty})
|
|
1189
1189
|
|
|
1190
1190
|
# @unittest.skip('Work in progress')
|
|
1191
1191
|
def test_updating_add(self):
|
|
@@ -1234,7 +1234,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1234
1234
|
self.assertEqual(prop1.name, LangString("Test"))
|
|
1235
1235
|
self.assertEqual(prop1.description, LangString("Property shape for testing purposes"))
|
|
1236
1236
|
self.assertEqual(prop1.datatype, XsdDatatypes.string)
|
|
1237
|
-
self.assertEqual(prop1.type, OwlPropertyType.OwlDataProperty)
|
|
1237
|
+
self.assertEqual(prop1.type, {OwlPropertyType.OwlDataProperty})
|
|
1238
1238
|
self.assertEqual(r2[Xsd_QName('test:test')].minCount, Xsd_integer(1))
|
|
1239
1239
|
self.assertEqual(r2[Xsd_QName('test:test')].order, Xsd_decimal(3))
|
|
1240
1240
|
|
|
@@ -1242,7 +1242,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1242
1242
|
self.assertEqual(prop2.internal, Xsd_QName("test:testMyResMinimalC"))
|
|
1243
1243
|
self.assertEqual(prop2.toClass, Xsd_QName('test:Person'))
|
|
1244
1244
|
self.assertEqual(r2[Xsd_QName('dcterms:creator')].maxCount, Xsd_integer(1))
|
|
1245
|
-
self.assertEqual(prop1.type, OwlPropertyType.OwlDataProperty)
|
|
1245
|
+
self.assertEqual(prop1.type, {OwlPropertyType.OwlDataProperty})
|
|
1246
1246
|
|
|
1247
1247
|
prop3 = r2[Xsd_QName('test:color')].prop
|
|
1248
1248
|
self.assertEqual(prop3.internal, Xsd_QName("test:testMyResMinimalC"))
|