oldaplib 0.3.1__py3-none-any.whl → 0.3.2__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/src/datamodel.py +19 -19
- oldaplib/src/enums/haspropertyattr.py +2 -1
- oldaplib/src/hasproperty.py +22 -23
- oldaplib/src/helpers/Notify.py +7 -6
- oldaplib/src/helpers/irincname.py +50 -4
- oldaplib/src/helpers/observable_dict.py +4 -2
- oldaplib/src/helpers/query_processor.py +2 -1
- oldaplib/src/helpers/tools.py +11 -11
- oldaplib/src/model.py +1 -1
- oldaplib/src/objectfactory.py +22 -22
- oldaplib/src/oldaplist.py +1 -1
- oldaplib/src/permissionset.py +15 -10
- oldaplib/src/propertyclass.py +26 -27
- oldaplib/src/resourceclass.py +88 -86
- oldaplib/src/version.py +1 -1
- oldaplib/src/xsd/xsd_qname.py +21 -0
- oldaplib/test/test_datamodel.py +168 -169
- oldaplib/test/test_hasproperty.py +65 -65
- oldaplib/test/test_objectfactory.py +1 -1
- oldaplib/test/test_observable_dict.py +10 -0
- oldaplib/test/test_oldaplist.py +9 -9
- oldaplib/test/test_oldaplistnode.py +30 -30
- oldaplib/test/test_permissionset.py +14 -14
- oldaplib/test/test_project.py +4 -4
- oldaplib/test/test_propertyclass.py +89 -91
- oldaplib/test/test_resourceclass.py +342 -336
- oldaplib/test/test_user.py +8 -8
- {oldaplib-0.3.1.dist-info → oldaplib-0.3.2.dist-info}/METADATA +1 -1
- {oldaplib-0.3.1.dist-info → oldaplib-0.3.2.dist-info}/RECORD +30 -30
- {oldaplib-0.3.1.dist-info → oldaplib-0.3.2.dist-info}/WHEEL +0 -0
|
@@ -152,8 +152,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
152
152
|
def test_constructor(self):
|
|
153
153
|
p1 = PropertyClass(con=self._connection,
|
|
154
154
|
project=self._project,
|
|
155
|
-
property_class_iri=
|
|
156
|
-
subPropertyOf=
|
|
155
|
+
property_class_iri=Xsd_QName('test:testprop'),
|
|
156
|
+
subPropertyOf=Xsd_QName('test:comment'),
|
|
157
157
|
datatype=XsdDatatypes.langString,
|
|
158
158
|
name=LangString(["Test property@en", "Testprädikat@de"]),
|
|
159
159
|
description=LangString("A property for testing...@en"),
|
|
@@ -162,21 +162,21 @@ class TestResourceClass(unittest.TestCase):
|
|
|
162
162
|
|
|
163
163
|
p2 = PropertyClass(con=self._connection,
|
|
164
164
|
project=self._project,
|
|
165
|
-
property_class_iri=
|
|
165
|
+
property_class_iri=Xsd_QName('test:enumprop'),
|
|
166
166
|
datatype=XsdDatatypes.string,
|
|
167
167
|
name=LangString(["Test enum@en", "Enumerationen@de"]),
|
|
168
168
|
inSet=RdfSet(Xsd_string("yes"), Xsd_string("maybe"), Xsd_string("no")))
|
|
169
169
|
|
|
170
170
|
hasproperties: list[HasProperty] = [
|
|
171
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
172
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
171
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, order=1),
|
|
172
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:test"), minCount=1, order=2),
|
|
173
173
|
HasProperty(con=self._connection, project=self._project, prop=p1, maxCount=1, order=3),
|
|
174
174
|
HasProperty(con=self._connection, project=self._project, prop=p2, minCount=1, maxCount=1, order=4)
|
|
175
175
|
]
|
|
176
176
|
|
|
177
177
|
r1 = ResourceClass(con=self._connection,
|
|
178
178
|
project=self._project,
|
|
179
|
-
owlclass_iri=
|
|
179
|
+
owlclass_iri=Xsd_QName("test:TestResource"),
|
|
180
180
|
label=LangString(["Test resource@en", "Resource de test@fr"]),
|
|
181
181
|
comment=LangString("For testing purposes@en"),
|
|
182
182
|
closed=Xsd_boolean(True),
|
|
@@ -188,41 +188,41 @@ class TestResourceClass(unittest.TestCase):
|
|
|
188
188
|
self.assertTrue(r1[ResClassAttribute.CLOSED])
|
|
189
189
|
self.assertTrue(r1.closed)
|
|
190
190
|
|
|
191
|
-
prop1 = r1[
|
|
192
|
-
self.assertEqual(r1[
|
|
193
|
-
self.assertEqual(r1[
|
|
191
|
+
prop1 = r1[Xsd_QName("test:comment")].prop
|
|
192
|
+
self.assertEqual(r1[Xsd_QName("test:comment")].maxCount, Xsd_integer(1))
|
|
193
|
+
self.assertEqual(r1[Xsd_QName("test:comment")].order, Xsd_decimal(1))
|
|
194
194
|
self.assertIsNotNone(prop1)
|
|
195
195
|
self.assertIsNone(prop1.internal)
|
|
196
|
-
self.assertEqual(prop1.property_class_iri,
|
|
196
|
+
self.assertEqual(prop1.property_class_iri, Xsd_QName("test:comment"))
|
|
197
197
|
self.assertEqual(prop1.datatype, XsdDatatypes.langString)
|
|
198
198
|
self.assertEqual(prop1.name, LangString(["comment@en", "Kommentar@de"]))
|
|
199
199
|
self.assertEqual(prop1.description, LangString("This is a test property@de"))
|
|
200
200
|
self.assertEqual(prop1.uniqueLang, Xsd_boolean(True))
|
|
201
201
|
|
|
202
|
-
prop2 = r1[
|
|
203
|
-
self.assertEqual(r1[
|
|
204
|
-
self.assertEqual(r1[
|
|
202
|
+
prop2 = r1[Xsd_QName("test:test")].prop
|
|
203
|
+
self.assertEqual(r1[Xsd_QName("test:test")].minCount, Xsd_integer(1))
|
|
204
|
+
self.assertEqual(r1[Xsd_QName("test:test")].order, Xsd_decimal(2))
|
|
205
205
|
self.assertIsNone(prop2.internal)
|
|
206
|
-
self.assertEqual(prop2.property_class_iri,
|
|
206
|
+
self.assertEqual(prop2.property_class_iri, Xsd_QName("test:test"))
|
|
207
207
|
self.assertEqual(prop2.datatype, XsdDatatypes.string)
|
|
208
208
|
self.assertEqual(prop2.description, LangString("Property shape for testing purposes"))
|
|
209
209
|
|
|
210
|
-
prop3 = r1[
|
|
211
|
-
self.assertEqual(r1[
|
|
212
|
-
self.assertEqual(r1[
|
|
213
|
-
self.assertEqual(prop3.internal,
|
|
214
|
-
self.assertEqual(prop3.property_class_iri,
|
|
210
|
+
prop3 = r1[Xsd_QName("test:testprop")].prop
|
|
211
|
+
self.assertEqual(r1[Xsd_QName("test:testprop")].maxCount, Xsd_integer(1))
|
|
212
|
+
self.assertEqual(r1[Xsd_QName("test:testprop")].order, Xsd_decimal(3))
|
|
213
|
+
self.assertEqual(prop3.internal, Xsd_QName('test:TestResource'))
|
|
214
|
+
self.assertEqual(prop3.property_class_iri, Xsd_QName("test:testprop"))
|
|
215
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
|
-
self.assertEqual(prop3.subPropertyOf,
|
|
218
|
+
self.assertEqual(prop3.subPropertyOf, Xsd_QName("test:comment"))
|
|
219
219
|
self.assertEqual(prop3.uniqueLang, Xsd_boolean(True))
|
|
220
220
|
self.assertEqual(prop3.languageIn, LanguageIn(Language.EN, Language.DE, Language.FR, Language.IT))
|
|
221
221
|
|
|
222
|
-
prop4 = r1[
|
|
223
|
-
self.assertEqual(r1[
|
|
224
|
-
self.assertEqual(r1[
|
|
225
|
-
self.assertEqual(r1[
|
|
222
|
+
prop4 = r1[Xsd_QName("test:enumprop")].prop
|
|
223
|
+
self.assertEqual(r1[Xsd_QName("test:enumprop")].maxCount, Xsd_integer(1))
|
|
224
|
+
self.assertEqual(r1[Xsd_QName("test:enumprop")].minCount, Xsd_integer(1))
|
|
225
|
+
self.assertEqual(r1[Xsd_QName("test:enumprop")].order, Xsd_decimal(4))
|
|
226
226
|
self.assertEqual(prop4[PropClassAttr.IN],
|
|
227
227
|
RdfSet(Xsd_string("yes"), Xsd_string("maybe"), Xsd_string("no")))
|
|
228
228
|
|
|
@@ -230,14 +230,14 @@ class TestResourceClass(unittest.TestCase):
|
|
|
230
230
|
def test_gaga(self):
|
|
231
231
|
ep = PropertyClass(con=self._connection,
|
|
232
232
|
project="test",
|
|
233
|
-
property_class_iri=
|
|
233
|
+
property_class_iri=Xsd_QName("schema:givenName"),
|
|
234
234
|
datatype=XsdDatatypes.string,
|
|
235
235
|
maxLength=64,
|
|
236
236
|
minLength=3,
|
|
237
237
|
_externalOntology=Xsd_boolean(True))
|
|
238
238
|
ep2 = PropertyClass(con=self._connection,
|
|
239
239
|
project="test",
|
|
240
|
-
property_class_iri=
|
|
240
|
+
property_class_iri=Xsd_QName("schema:comment"),
|
|
241
241
|
toClass='schema:Comment')
|
|
242
242
|
hasproperties: list[HasProperty] = [
|
|
243
243
|
HasProperty(con=self._connection, project=self._project, prop=ep2, minCount=1, order=1),
|
|
@@ -246,24 +246,24 @@ class TestResourceClass(unittest.TestCase):
|
|
|
246
246
|
]
|
|
247
247
|
r1 = ResourceClass(con=self._connection,
|
|
248
248
|
project="test",
|
|
249
|
-
owlclass_iri=
|
|
249
|
+
owlclass_iri=Xsd_QName("test:Gaga"),
|
|
250
250
|
label=LangString(["Test gaga@en", "Resource de gaga@fr"]),
|
|
251
251
|
comment=LangString("For testing purposes@en"),
|
|
252
252
|
closed=Xsd_boolean(True),
|
|
253
253
|
hasproperties=hasproperties)
|
|
254
|
-
p2 = r1[
|
|
254
|
+
p2 = r1[Xsd_QName('schema:description')]
|
|
255
255
|
#r1.write_as_trig("0000000.trig")
|
|
256
256
|
r1.create()
|
|
257
|
-
p2 = r1[
|
|
257
|
+
p2 = r1[Xsd_QName('schema:description')]
|
|
258
258
|
|
|
259
259
|
r2 = ResourceClass.read(con=self._connection,
|
|
260
260
|
project="test",
|
|
261
|
-
owl_class_iri=
|
|
261
|
+
owl_class_iri=Xsd_QName('test:Gaga'),
|
|
262
262
|
ignore_cache=True)
|
|
263
263
|
#r2.write_as_trig("111111111.trig")
|
|
264
|
-
p1 = r2[
|
|
265
|
-
self.assertIsInstance(p1.prop.property_class_iri,
|
|
266
|
-
p2 = r2[
|
|
264
|
+
p1 = r2[Xsd_QName('schema:comment')]
|
|
265
|
+
self.assertIsInstance(p1.prop.property_class_iri, Xsd_QName)
|
|
266
|
+
p2 = r2[Xsd_QName('schema:description')]
|
|
267
267
|
|
|
268
268
|
def test_create_next_generation(self):
|
|
269
269
|
#
|
|
@@ -271,12 +271,12 @@ class TestResourceClass(unittest.TestCase):
|
|
|
271
271
|
#
|
|
272
272
|
p0 = PropertyClass(con=self._connection,
|
|
273
273
|
project="test",
|
|
274
|
-
property_class_iri=
|
|
274
|
+
property_class_iri=Xsd_QName('test:standalone'),
|
|
275
275
|
datatype=XsdDatatypes.integer)
|
|
276
276
|
p0.create()
|
|
277
277
|
p0 = PropertyClass.read(con=self._connection,
|
|
278
278
|
project="test",
|
|
279
|
-
property_class_iri=
|
|
279
|
+
property_class_iri=Xsd_QName('test:standalone'),
|
|
280
280
|
ignore_cache=True)
|
|
281
281
|
|
|
282
282
|
#
|
|
@@ -284,7 +284,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
284
284
|
#
|
|
285
285
|
p1 = PropertyClass(con=self._connection,
|
|
286
286
|
project="test",
|
|
287
|
-
property_class_iri=
|
|
287
|
+
property_class_iri=Xsd_QName('test:internal'),
|
|
288
288
|
datatype=XsdDatatypes.langString,
|
|
289
289
|
name=LangString(["internal@en", "internal@de"]),
|
|
290
290
|
description=LangString("A property for testing...@en"),
|
|
@@ -296,7 +296,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
296
296
|
#
|
|
297
297
|
p2 = PropertyClass(con=self._connection,
|
|
298
298
|
project="test",
|
|
299
|
-
property_class_iri=
|
|
299
|
+
property_class_iri=Xsd_QName('test:internalWithSuper'),
|
|
300
300
|
subPropertyOf=Iri('dcterms:description'),
|
|
301
301
|
datatype=XsdDatatypes.langString,
|
|
302
302
|
name=LangString(["internalWithSuper@en", "internalWithSuper@de"]),
|
|
@@ -310,13 +310,13 @@ class TestResourceClass(unittest.TestCase):
|
|
|
310
310
|
hasproperties: list[HasProperty] = [
|
|
311
311
|
HasProperty(con=self._connection, project=self._project, prop=p1, maxCount=1, order=1),
|
|
312
312
|
HasProperty(con=self._connection, project=self._project, prop=p2, minCount=1, maxCount=1, order=2),
|
|
313
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
314
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
315
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
313
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName('schema:comment'), minCount=1, order=3),
|
|
314
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName('schema:description')),
|
|
315
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName('test:standalone'), maxCount=1, order=4)
|
|
316
316
|
]
|
|
317
317
|
r1 = ResourceClass(con=self._connection,
|
|
318
318
|
project="test",
|
|
319
|
-
owlclass_iri=
|
|
319
|
+
owlclass_iri=Xsd_QName("test:TestResourceNextGeneration"),
|
|
320
320
|
label=LangString(["Test resource@en", "Resource de test@fr"]),
|
|
321
321
|
comment=LangString("For testing purposes@en"),
|
|
322
322
|
closed=Xsd_boolean(True),
|
|
@@ -325,16 +325,16 @@ class TestResourceClass(unittest.TestCase):
|
|
|
325
325
|
|
|
326
326
|
r1 = ResourceClass.read(con=self._connection,
|
|
327
327
|
project="test",
|
|
328
|
-
owl_class_iri=
|
|
328
|
+
owl_class_iri=Xsd_QName('test:TestResourceNextGeneration'),
|
|
329
329
|
ignore_cache=True)
|
|
330
|
-
p1 = r1[
|
|
330
|
+
p1 = r1[Xsd_QName('test:internal')]
|
|
331
331
|
self.assertEqual(p1.prop.datatype, XsdDatatypes.langString)
|
|
332
332
|
self.assertEqual(p1.prop.name, LangString(["internal@en", "internal@de"]))
|
|
333
333
|
self.assertEqual(p1.maxCount, 1)
|
|
334
334
|
self.assertIsNone(p1.minCount)
|
|
335
335
|
self.assertEqual(p1.order, 1)
|
|
336
336
|
|
|
337
|
-
p2 = r1[
|
|
337
|
+
p2 = r1[Xsd_QName('test:internalWithSuper')]
|
|
338
338
|
self.assertEqual(p2.maxCount, 1)
|
|
339
339
|
self.assertEqual(p2.minCount, 1)
|
|
340
340
|
self.assertEqual(p2.order, 2)
|
|
@@ -345,20 +345,20 @@ class TestResourceClass(unittest.TestCase):
|
|
|
345
345
|
self.assertEqual(p2.prop.uniqueLang, Xsd_boolean(True))
|
|
346
346
|
self.assertEqual(p2.prop.languageIn, LanguageIn(Language.EN, Language.DE, Language.FR, Language.IT))
|
|
347
347
|
|
|
348
|
-
p3 = r1[
|
|
348
|
+
p3 = r1[Xsd_QName('schema:comment')]
|
|
349
349
|
self.assertEqual(p3.minCount, 1)
|
|
350
350
|
self.assertIsNone(p3.maxCount)
|
|
351
351
|
self.assertEqual(p3.order, 3)
|
|
352
352
|
self.assertIsNone(p3.group)
|
|
353
|
-
self.assertIsInstance(p3.prop.property_class_iri,
|
|
353
|
+
self.assertIsInstance(p3.prop.property_class_iri, Xsd_QName)
|
|
354
354
|
|
|
355
|
-
p4 = r1[
|
|
355
|
+
p4 = r1[Xsd_QName('schema:description')]
|
|
356
356
|
self.assertIsNone(p4.minCount)
|
|
357
357
|
self.assertIsNone(p4.maxCount)
|
|
358
358
|
self.assertIsNone(p4.order)
|
|
359
|
-
self.assertIsInstance(p4.prop.property_class_iri,
|
|
359
|
+
self.assertIsInstance(p4.prop.property_class_iri, Xsd_QName)
|
|
360
360
|
|
|
361
|
-
p5 = r1[
|
|
361
|
+
p5 = r1[Xsd_QName('test:standalone')]
|
|
362
362
|
self.assertIsNone(p5.minCount)
|
|
363
363
|
self.assertEqual(p5.maxCount, 1)
|
|
364
364
|
self.assertEqual(p5.order, 4)
|
|
@@ -369,7 +369,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
369
369
|
def test_constructor_projectns(self):
|
|
370
370
|
p1 = PropertyClass(con=self._connection,
|
|
371
371
|
project="test",
|
|
372
|
-
property_class_iri=
|
|
372
|
+
property_class_iri=Xsd_QName('test:testpropns'),
|
|
373
373
|
subPropertyOf=Iri('test:comment'),
|
|
374
374
|
datatype=XsdDatatypes.langString,
|
|
375
375
|
name=LangString(["Test property@en", "Testprädikat@de"]),
|
|
@@ -379,7 +379,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
379
379
|
|
|
380
380
|
p2 = PropertyClass(con=self._connection,
|
|
381
381
|
project="test",
|
|
382
|
-
property_class_iri=
|
|
382
|
+
property_class_iri=Xsd_QName('test:enumpropns'),
|
|
383
383
|
datatype=XsdDatatypes.string,
|
|
384
384
|
name=LangString(["Test enum@en", "Enumerationen@de"]),
|
|
385
385
|
inSet=RdfSet(Xsd_string("yes"), Xsd_string("maybe"), Xsd_string("no")))
|
|
@@ -391,7 +391,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
391
391
|
|
|
392
392
|
r1 = ResourceClass(con=self._connection,
|
|
393
393
|
project="test",
|
|
394
|
-
owlclass_iri=
|
|
394
|
+
owlclass_iri=Xsd_QName("test:TestResource"),
|
|
395
395
|
label=LangString(["Test resource@en", "Resource de test@fr"]),
|
|
396
396
|
comment=LangString("For testing purposes@en"),
|
|
397
397
|
closed=Xsd_boolean(True),
|
|
@@ -405,21 +405,21 @@ class TestResourceClass(unittest.TestCase):
|
|
|
405
405
|
|
|
406
406
|
def test_resourceclass_serialize_deserialize_A(self):
|
|
407
407
|
hasproperties: list[HasProperty] = [
|
|
408
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
409
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
408
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, order=1),
|
|
409
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:test"), minCount=1, order=2),
|
|
410
410
|
]
|
|
411
411
|
|
|
412
412
|
r1 = ResourceClass(con=self._connection,
|
|
413
413
|
project=self._project,
|
|
414
|
-
owlclass_iri=
|
|
414
|
+
owlclass_iri=Xsd_QName("test:TestResourceDeepcopyA"),
|
|
415
415
|
hasproperties=hasproperties)
|
|
416
416
|
r1.create()
|
|
417
417
|
jsonstr = json.dumps(r1, default=serializer.encoder_default)
|
|
418
418
|
r2 = json.loads(jsonstr, object_hook=serializer.make_decoder_hook(connection=self._connection))
|
|
419
419
|
|
|
420
|
-
p_a = r1[
|
|
420
|
+
p_a = r1[Xsd_QName("test:comment")].prop
|
|
421
421
|
self.assertIsNone(p_a.internal)
|
|
422
|
-
p_b = r2[
|
|
422
|
+
p_b = r2[Xsd_QName("test:comment")].prop
|
|
423
423
|
self.assertIsNone(p_b.internal)
|
|
424
424
|
|
|
425
425
|
|
|
@@ -427,8 +427,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
427
427
|
def test_resourceclass_serialize_deserialize(self):
|
|
428
428
|
p1 = PropertyClass(con=self._connection,
|
|
429
429
|
project=self._project,
|
|
430
|
-
property_class_iri=
|
|
431
|
-
subPropertyOf=
|
|
430
|
+
property_class_iri=Xsd_QName('test:deepc_prop1'),
|
|
431
|
+
subPropertyOf=Xsd_QName('test:comment'),
|
|
432
432
|
datatype=XsdDatatypes.langString,
|
|
433
433
|
name=LangString(["Test property@en", "Testprädikat@de"]),
|
|
434
434
|
description=LangString("A property for testing...@en"),
|
|
@@ -437,21 +437,21 @@ class TestResourceClass(unittest.TestCase):
|
|
|
437
437
|
|
|
438
438
|
p2 = PropertyClass(con=self._connection,
|
|
439
439
|
project=self._project,
|
|
440
|
-
property_class_iri=
|
|
440
|
+
property_class_iri=Xsd_QName('test:deepc_prop2'),
|
|
441
441
|
datatype=XsdDatatypes.string,
|
|
442
442
|
name=LangString(["Test enum@en", "Enumerationen@de"]),
|
|
443
443
|
inSet=RdfSet(Xsd_string("yes"), Xsd_string("maybe"), Xsd_string("no")))
|
|
444
444
|
|
|
445
445
|
hasproperties: list[HasProperty] = [
|
|
446
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
447
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
446
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, order=1),
|
|
447
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:test"), minCount=1, order=2),
|
|
448
448
|
HasProperty(con=self._connection, project=self._project, prop=p1, maxCount=1, order=3),
|
|
449
449
|
HasProperty(con=self._connection, project=self._project, prop=p2, minCount=1, maxCount=1, order=4)
|
|
450
450
|
]
|
|
451
451
|
|
|
452
452
|
r1 = ResourceClass(con=self._connection,
|
|
453
453
|
project=self._project,
|
|
454
|
-
owlclass_iri=
|
|
454
|
+
owlclass_iri=Xsd_QName("test:TestResourceDeepcopy"),
|
|
455
455
|
label=LangString(["Test resource@en", "Resource de test@fr"]),
|
|
456
456
|
comment=LangString("For testing purposes@en"),
|
|
457
457
|
closed=Xsd_boolean(True),
|
|
@@ -471,11 +471,11 @@ class TestResourceClass(unittest.TestCase):
|
|
|
471
471
|
self.assertTrue(r2[ResClassAttribute.CLOSED])
|
|
472
472
|
self.assertTrue(r2.closed)
|
|
473
473
|
|
|
474
|
-
self.assertEqual(r1[
|
|
475
|
-
self.assertEqual(r1[
|
|
474
|
+
self.assertEqual(r1[Xsd_QName("test:comment")].maxCount, r2[Xsd_QName("test:comment")].maxCount)
|
|
475
|
+
self.assertEqual(r1[Xsd_QName("test:comment")].order, r2[Xsd_QName("test:comment")].order)
|
|
476
476
|
|
|
477
|
-
prop1a = r1[
|
|
478
|
-
prop1b = r2[
|
|
477
|
+
prop1a = r1[Xsd_QName("test:comment")].prop
|
|
478
|
+
prop1b = r2[Xsd_QName("test:comment")].prop
|
|
479
479
|
self.assertIsNotNone(prop1b)
|
|
480
480
|
self.assertIsNone(prop1b.internal)
|
|
481
481
|
self.assertEqual(prop1a.property_class_iri, prop1b.property_class_iri)
|
|
@@ -484,19 +484,19 @@ class TestResourceClass(unittest.TestCase):
|
|
|
484
484
|
self.assertEqual(prop1a.description, prop1b.description)
|
|
485
485
|
self.assertEqual(prop1a.uniqueLang, prop1b.uniqueLang)
|
|
486
486
|
|
|
487
|
-
self.assertEqual(r1[
|
|
488
|
-
self.assertEqual(r1[
|
|
489
|
-
prop2a = r1[
|
|
490
|
-
prop2b = r2[
|
|
487
|
+
self.assertEqual(r1[Xsd_QName("test:test")].minCount, r2[Xsd_QName("test:test")].minCount)
|
|
488
|
+
self.assertEqual(r1[Xsd_QName("test:test")].order, r2[Xsd_QName("test:test")].order)
|
|
489
|
+
prop2a = r1[Xsd_QName("test:test")].prop
|
|
490
|
+
prop2b = r2[Xsd_QName("test:test")].prop
|
|
491
491
|
self.assertIsNone(prop2b.internal)
|
|
492
492
|
self.assertEqual(prop2a.property_class_iri, prop2b.property_class_iri)
|
|
493
493
|
self.assertEqual(prop2a.datatype, prop2b.datatype)
|
|
494
494
|
self.assertEqual(prop2a.description, prop2b.description)
|
|
495
495
|
|
|
496
|
-
self.assertEqual(r1[
|
|
497
|
-
self.assertEqual(r1[
|
|
498
|
-
prop3a = r1[
|
|
499
|
-
prop3b = r2[
|
|
496
|
+
self.assertEqual(r1[Xsd_QName("test:deepc_prop1")].maxCount, r2[Xsd_QName("test:deepc_prop1")].maxCount)
|
|
497
|
+
self.assertEqual(r1[Xsd_QName("test:deepc_prop1")].order, r2[Xsd_QName("test:deepc_prop1")].order)
|
|
498
|
+
prop3a = r1[Xsd_QName("test:deepc_prop1")].prop
|
|
499
|
+
prop3b = r2[Xsd_QName("test:deepc_prop1")].prop
|
|
500
500
|
self.assertEqual(prop3a.internal, prop3b.internal)
|
|
501
501
|
self.assertEqual(prop3a.property_class_iri, prop3b.property_class_iri)
|
|
502
502
|
self.assertEqual(prop3a.type, prop3b.type)
|
|
@@ -506,61 +506,61 @@ class TestResourceClass(unittest.TestCase):
|
|
|
506
506
|
self.assertEqual(prop3a.uniqueLang, prop3b.uniqueLang)
|
|
507
507
|
self.assertEqual(prop3a.languageIn, prop3b.languageIn)
|
|
508
508
|
|
|
509
|
-
self.assertEqual(r1[
|
|
510
|
-
self.assertEqual(r1[
|
|
511
|
-
self.assertEqual(r1[
|
|
512
|
-
prop4a = r1[
|
|
513
|
-
prop4b = r2[
|
|
509
|
+
self.assertEqual(r1[Xsd_QName("test:deepc_prop2")].maxCount, r2[Xsd_QName("test:deepc_prop2")].maxCount)
|
|
510
|
+
self.assertEqual(r1[Xsd_QName("test:deepc_prop2")].minCount, r2[Xsd_QName("test:deepc_prop2")].minCount)
|
|
511
|
+
self.assertEqual(r1[Xsd_QName("test:deepc_prop2")].order, r2[Xsd_QName("test:deepc_prop2")].order)
|
|
512
|
+
prop4a = r1[Xsd_QName("test:deepc_prop2")].prop
|
|
513
|
+
prop4b = r2[Xsd_QName("test:deepc_prop2")].prop
|
|
514
514
|
self.assertEqual(prop4a[PropClassAttr.IN], prop4b[PropClassAttr.IN])
|
|
515
515
|
|
|
516
516
|
def test_reading_sys(self):
|
|
517
517
|
r1 = ResourceClass.read(con=self._connection,
|
|
518
518
|
project=self._sysproject,
|
|
519
|
-
owl_class_iri=
|
|
519
|
+
owl_class_iri=Xsd_QName('oldap:User'),
|
|
520
520
|
ignore_cache=True)
|
|
521
|
-
self.assertEqual(r1.owl_class_iri,
|
|
521
|
+
self.assertEqual(r1.owl_class_iri, Xsd_QName('oldap:User'))
|
|
522
522
|
self.assertEqual(r1.version, SemanticVersion(0, 1, 0))
|
|
523
523
|
self.assertEqual(r1.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
524
524
|
self.assertEqual(r1.created, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
525
525
|
self.assertEqual(r1.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
526
526
|
self.assertEqual(r1.modified, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
527
527
|
|
|
528
|
-
prop1 = r1[
|
|
528
|
+
prop1 = r1[Xsd_QName('dcterms:creator')]
|
|
529
529
|
self.assertEqual(prop1.minCount, Xsd_integer(1))
|
|
530
530
|
self.assertEqual(prop1.maxCount, Xsd_integer(1))
|
|
531
|
-
self.assertEqual(prop1.prop.property_class_iri,
|
|
532
|
-
self.assertEqual(prop1.prop.toClass,
|
|
531
|
+
self.assertEqual(prop1.prop.property_class_iri, Xsd_QName('dcterms:creator'))
|
|
532
|
+
self.assertEqual(prop1.prop.toClass, Xsd_QName('oldap:User'))
|
|
533
533
|
|
|
534
|
-
prop2 = r1[
|
|
534
|
+
prop2 = r1[Xsd_QName('dcterms:created')]
|
|
535
535
|
self.assertEqual(prop2.minCount, Xsd_integer(1))
|
|
536
536
|
self.assertEqual(prop2.maxCount, Xsd_integer(1))
|
|
537
|
-
self.assertEqual(prop2.prop.property_class_iri,
|
|
537
|
+
self.assertEqual(prop2.prop.property_class_iri, Xsd_QName('dcterms:created'))
|
|
538
538
|
self.assertEqual(prop2.prop.datatype, XsdDatatypes.dateTime)
|
|
539
539
|
|
|
540
|
-
prop3 = r1[
|
|
540
|
+
prop3 = r1[Xsd_QName('dcterms:contributor')]
|
|
541
541
|
self.assertEqual(prop3.minCount, Xsd_integer(1))
|
|
542
542
|
self.assertEqual(prop3.maxCount, Xsd_integer(1))
|
|
543
|
-
self.assertEqual(prop3.prop.property_class_iri,
|
|
543
|
+
self.assertEqual(prop3.prop.property_class_iri, Xsd_QName('dcterms:contributor'))
|
|
544
544
|
self.assertEqual(prop3.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
545
545
|
self.assertEqual(prop3.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
546
546
|
self.assertEqual(prop3.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
547
547
|
self.assertEqual(prop3.prop.modified, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
548
|
-
self.assertEqual(prop3.prop.toClass,
|
|
548
|
+
self.assertEqual(prop3.prop.toClass, Xsd_QName('oldap:User'))
|
|
549
549
|
|
|
550
|
-
prop4 = r1[
|
|
550
|
+
prop4 = r1[Xsd_QName('dcterms:modified')]
|
|
551
551
|
self.assertEqual(prop4.minCount, Xsd_integer(1))
|
|
552
552
|
self.assertEqual(prop4.maxCount, Xsd_integer(1))
|
|
553
|
-
self.assertEqual(prop4.prop.property_class_iri,
|
|
553
|
+
self.assertEqual(prop4.prop.property_class_iri, Xsd_QName('dcterms:modified'))
|
|
554
554
|
self.assertEqual(prop4.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
555
555
|
self.assertEqual(prop4.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
556
556
|
self.assertEqual(prop4.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
557
557
|
self.assertEqual(prop4.prop.modified, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
558
558
|
self.assertEqual(prop4.prop.datatype, XsdDatatypes.dateTime)
|
|
559
559
|
|
|
560
|
-
prop5 = r1[
|
|
560
|
+
prop5 = r1[Xsd_QName('oldap:userId')]
|
|
561
561
|
self.assertEqual(prop5.minCount, Xsd_integer(1))
|
|
562
562
|
self.assertEqual(prop5.maxCount, Xsd_integer(1))
|
|
563
|
-
self.assertEqual(prop5.prop.property_class_iri,
|
|
563
|
+
self.assertEqual(prop5.prop.property_class_iri, Xsd_QName('oldap:userId'))
|
|
564
564
|
self.assertEqual(prop5.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
565
565
|
self.assertEqual(prop5.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
566
566
|
self.assertEqual(prop5.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
@@ -569,10 +569,10 @@ class TestResourceClass(unittest.TestCase):
|
|
|
569
569
|
self.assertEqual(prop5.prop.minLength, Xsd_integer(3))
|
|
570
570
|
self.assertEqual(prop5.prop.maxLength, Xsd_integer(32))
|
|
571
571
|
|
|
572
|
-
prop6 = r1[
|
|
572
|
+
prop6 = r1[Xsd_QName('schema:familyName')]
|
|
573
573
|
self.assertEqual(prop6.minCount, Xsd_integer(1))
|
|
574
574
|
self.assertEqual(prop6.maxCount, Xsd_integer(1))
|
|
575
|
-
self.assertEqual(prop6.prop.property_class_iri,
|
|
575
|
+
self.assertEqual(prop6.prop.property_class_iri, Xsd_QName('schema:familyName'))
|
|
576
576
|
self.assertEqual(prop6.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
577
577
|
self.assertEqual(prop6.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
578
578
|
self.assertEqual(prop6.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
@@ -581,10 +581,10 @@ class TestResourceClass(unittest.TestCase):
|
|
|
581
581
|
self.assertEqual(prop6.prop.name, LangString(["Family name@en", "Familiennamen@de", "Nom de famillie@fr", "Nome della famiglia@it"]))
|
|
582
582
|
self.assertEqual(prop6.prop.description, LangString("The family name of some person.@en"))
|
|
583
583
|
|
|
584
|
-
prop7 = r1[
|
|
584
|
+
prop7 = r1[Xsd_QName('schema:givenName')]
|
|
585
585
|
self.assertEqual(prop7.minCount, Xsd_integer(1))
|
|
586
586
|
self.assertEqual(prop7.maxCount, Xsd_integer(1))
|
|
587
|
-
self.assertEqual(prop7.prop.property_class_iri,
|
|
587
|
+
self.assertEqual(prop7.prop.property_class_iri, Xsd_QName('schema:givenName'))
|
|
588
588
|
self.assertEqual(prop7.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
589
589
|
self.assertEqual(prop7.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
590
590
|
self.assertEqual(prop7.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
@@ -593,10 +593,10 @@ class TestResourceClass(unittest.TestCase):
|
|
|
593
593
|
self.assertEqual(prop7.prop.name, LangString(["Given name@en", "Vornamen@de", "Prénom@fr", "Nome@it"]))
|
|
594
594
|
self.assertEqual(prop7.prop.description, LangString("The given name of some person@en"))
|
|
595
595
|
|
|
596
|
-
prop8 = r1[
|
|
596
|
+
prop8 = r1[Xsd_QName('oldap:credentials')]
|
|
597
597
|
self.assertEqual(prop8.minCount, Xsd_integer(1))
|
|
598
598
|
self.assertEqual(prop8.maxCount, Xsd_integer(1))
|
|
599
|
-
self.assertEqual(prop8.prop.property_class_iri,
|
|
599
|
+
self.assertEqual(prop8.prop.property_class_iri, Xsd_QName('oldap:credentials'))
|
|
600
600
|
self.assertEqual(prop8.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
601
601
|
self.assertEqual(prop8.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
602
602
|
self.assertEqual(prop8.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
@@ -605,18 +605,18 @@ class TestResourceClass(unittest.TestCase):
|
|
|
605
605
|
self.assertEqual(prop8.prop.name, LangString(["Password@en", "Passwort@de", "Mot de passe@fr", "Password@it"]))
|
|
606
606
|
self.assertEqual(prop8.prop.description, LangString("Password for user.@en"))
|
|
607
607
|
|
|
608
|
-
prop9 = r1[
|
|
609
|
-
self.assertEqual(prop9.prop.property_class_iri,
|
|
608
|
+
prop9 = r1[Xsd_QName('oldap:inProject')]
|
|
609
|
+
self.assertEqual(prop9.prop.property_class_iri, Xsd_QName('oldap:inProject'))
|
|
610
610
|
self.assertEqual(prop9.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
611
611
|
self.assertEqual(prop9.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
612
612
|
self.assertEqual(prop9.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
613
613
|
self.assertEqual(prop9.prop.modified, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
614
|
-
self.assertEqual(prop9.prop.toClass,
|
|
614
|
+
self.assertEqual(prop9.prop.toClass, Xsd_QName('oldap:Project'))
|
|
615
615
|
|
|
616
|
-
prop10 = r1[
|
|
616
|
+
prop10 = r1[Xsd_QName('oldap:isActive')]
|
|
617
617
|
self.assertEqual(prop10.minCount, Xsd_integer(1))
|
|
618
618
|
self.assertEqual(prop10.maxCount, Xsd_integer(1))
|
|
619
|
-
self.assertEqual(prop10.prop.property_class_iri,
|
|
619
|
+
self.assertEqual(prop10.prop.property_class_iri, Xsd_QName('oldap:isActive'))
|
|
620
620
|
self.assertEqual(prop10.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
621
621
|
self.assertEqual(prop10.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
622
622
|
self.assertEqual(prop10.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
@@ -625,21 +625,21 @@ class TestResourceClass(unittest.TestCase):
|
|
|
625
625
|
self.assertIsNone(prop10.prop.name)
|
|
626
626
|
self.assertIsNone(prop10.prop.description)
|
|
627
627
|
|
|
628
|
-
prop11 = r1[
|
|
629
|
-
self.assertEqual(prop11.prop.property_class_iri,
|
|
628
|
+
prop11 = r1[Xsd_QName('oldap:hasPermissions')]
|
|
629
|
+
self.assertEqual(prop11.prop.property_class_iri, Xsd_QName('oldap:hasPermissions'))
|
|
630
630
|
self.assertEqual(prop11.prop.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
631
631
|
self.assertEqual(prop11.prop.created, Xsd_dateTime('2023-11-04T12:00:00+00:00'))
|
|
632
632
|
self.assertEqual(prop11.prop.contributor, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
633
633
|
self.assertEqual(prop11.prop.modified, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
634
|
-
self.assertEqual(prop11.prop.toClass,
|
|
634
|
+
self.assertEqual(prop11.prop.toClass, Xsd_QName('oldap:PermissionSet'))
|
|
635
635
|
|
|
636
636
|
# @unittest.skip('Work in progress')
|
|
637
637
|
def test_reading(self):
|
|
638
638
|
r1 = ResourceClass.read(con=self._connection,
|
|
639
639
|
project=self._project,
|
|
640
|
-
owl_class_iri=
|
|
640
|
+
owl_class_iri=Xsd_QName('test:testMyRes'),
|
|
641
641
|
ignore_cache=True)
|
|
642
|
-
self.assertEqual(r1.owl_class_iri,
|
|
642
|
+
self.assertEqual(r1.owl_class_iri, Xsd_QName('test:testMyRes'))
|
|
643
643
|
#self.assertEqual(r1.version, SemanticVersion(0, 1, 0))
|
|
644
644
|
self.assertEqual(r1.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
645
645
|
self.assertEqual(r1.created, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
@@ -649,9 +649,9 @@ class TestResourceClass(unittest.TestCase):
|
|
|
649
649
|
self.assertEqual(r1.comment, LangString("Resource for testing..."))
|
|
650
650
|
self.assertTrue(r1.closed)
|
|
651
651
|
|
|
652
|
-
prop1 = r1[
|
|
652
|
+
prop1 = r1[Xsd_QName('test:test')].prop
|
|
653
653
|
self.assertIsNone(prop1.internal)
|
|
654
|
-
self.assertEqual(prop1.property_class_iri,
|
|
654
|
+
self.assertEqual(prop1.property_class_iri, Xsd_QName("test:test"))
|
|
655
655
|
#self.assertEqual(prop1.version, SemanticVersion(0, 1, 0))
|
|
656
656
|
self.assertEqual(prop1.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
657
657
|
self.assertEqual(prop1.created, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
@@ -660,12 +660,12 @@ class TestResourceClass(unittest.TestCase):
|
|
|
660
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
|
-
self.assertEqual(r1[
|
|
664
|
-
self.assertEqual(r1[
|
|
663
|
+
self.assertEqual(r1[Xsd_QName('test:test')].minCount, Xsd_integer(1))
|
|
664
|
+
self.assertEqual(r1[Xsd_QName('test:test')].order, Xsd_decimal(3))
|
|
665
665
|
|
|
666
|
-
prop2 = r1[
|
|
667
|
-
self.assertEqual(prop2.internal,
|
|
668
|
-
self.assertEqual(prop2.property_class_iri,
|
|
666
|
+
prop2 = r1[Xsd_QName('test:hasText')].prop
|
|
667
|
+
self.assertEqual(prop2.internal, Xsd_QName('test:testMyRes'))
|
|
668
|
+
self.assertEqual(prop2.property_class_iri, Xsd_QName("test:hasText"))
|
|
669
669
|
#self.assertEqual(prop2.version, SemanticVersion(1, 0, 0))
|
|
670
670
|
self.assertEqual(prop2.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
671
671
|
self.assertEqual(prop2.created, Xsd_dateTime('2023-11-04T12:00:00Z'))
|
|
@@ -675,11 +675,11 @@ class TestResourceClass(unittest.TestCase):
|
|
|
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..."))
|
|
678
|
-
self.assertEqual(r1[
|
|
679
|
-
self.assertEqual(r1[
|
|
680
|
-
self.assertEqual(r1[
|
|
678
|
+
self.assertEqual(r1[Xsd_QName('test:hasText')].minCount, Xsd_integer(1))
|
|
679
|
+
self.assertEqual(r1[Xsd_QName('test:hasText')].maxCount, Xsd_integer(1))
|
|
680
|
+
self.assertEqual(r1[Xsd_QName('test:hasText')].order, Xsd_decimal(1))
|
|
681
681
|
|
|
682
|
-
prop3 = r1[
|
|
682
|
+
prop3 = r1[Xsd_QName('test:hasEnum')].prop
|
|
683
683
|
self.assertEqual(prop3.type, OwlPropertyType.OwlDataProperty)
|
|
684
684
|
self.assertEqual(prop3.datatype, XsdDatatypes.string)
|
|
685
685
|
self.assertEqual(prop3.inSet,
|
|
@@ -688,23 +688,23 @@ class TestResourceClass(unittest.TestCase):
|
|
|
688
688
|
def test_resource_jsonify(self):
|
|
689
689
|
r1 = ResourceClass.read(con=self._connection,
|
|
690
690
|
project=self._project,
|
|
691
|
-
owl_class_iri=
|
|
691
|
+
owl_class_iri=Xsd_QName('test:testMyRes'),
|
|
692
692
|
ignore_cache=True)
|
|
693
693
|
jsonstr = json.dumps(r1, default=serializer.encoder_default, indent=3)
|
|
694
694
|
r2 = json.loads(jsonstr, object_hook=serializer.make_decoder_hook(connection=self._connection))
|
|
695
|
-
self.assertEqual(r2.owl_class_iri,
|
|
695
|
+
self.assertEqual(r2.owl_class_iri, Xsd_QName('test:testMyRes'))
|
|
696
696
|
#self.assertEqual({Iri('test:testMyResMinimal'), Iri('oldap:Thing')}, {x for x in r2.superclass})
|
|
697
697
|
self.assertEqual(r2.creator, Iri('https://orcid.org/0000-0003-1681-4036'))
|
|
698
698
|
self.assertTrue(r2.closed)
|
|
699
699
|
|
|
700
|
-
hp1 = r2[
|
|
700
|
+
hp1 = r2[Xsd_QName('test:test')]
|
|
701
701
|
self.assertEqual(hp1.minCount, Xsd_integer(1))
|
|
702
702
|
self.assertEqual(hp1.maxCount, Xsd_integer(1))
|
|
703
703
|
self.assertEqual(hp1.order, Xsd_decimal(3))
|
|
704
704
|
p1 = hp1.prop
|
|
705
705
|
self.assertIsNone(p1.internal)
|
|
706
706
|
|
|
707
|
-
hp2 = r2[
|
|
707
|
+
hp2 = r2[Xsd_QName('test:hasText')]
|
|
708
708
|
self.assertEqual(hp2.minCount, Xsd_integer(1))
|
|
709
709
|
self.assertEqual(hp2.maxCount, Xsd_integer(1))
|
|
710
710
|
self.assertEqual(hp2.order, Xsd_decimal(1))
|
|
@@ -715,7 +715,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
715
715
|
self.assertEqual(p2.name, LangString("A text@en", "Ein Text@de"))
|
|
716
716
|
self.assertEqual(p2.description, LangString("A longer text...@en"))
|
|
717
717
|
|
|
718
|
-
hp3 = r2[
|
|
718
|
+
hp3 = r2[Xsd_QName('test:hasEnum')]
|
|
719
719
|
p3 = hp3.prop
|
|
720
720
|
self.assertEqual(p3.datatype, XsdDatatypes.string)
|
|
721
721
|
self.assertEqual(p3.inSet, {'blue', 'red', 'green', 'yellow'})
|
|
@@ -723,27 +723,27 @@ class TestResourceClass(unittest.TestCase):
|
|
|
723
723
|
def test_reading_with_superclass(self):
|
|
724
724
|
r1 = ResourceClass.read(con=self._connection,
|
|
725
725
|
project=self._project,
|
|
726
|
-
owl_class_iri=
|
|
727
|
-
self.assertEqual(r1.owl_class_iri,
|
|
728
|
-
self.assertEqual({
|
|
726
|
+
owl_class_iri=Xsd_QName('test:testMyResInherit'))
|
|
727
|
+
self.assertEqual(r1.owl_class_iri, Xsd_QName('test:testMyResInherit'))
|
|
728
|
+
self.assertEqual({Xsd_QName('test:testMyResMinimal'), Xsd_QName('oldap:Thing')}, {x for x in r1.superclass})
|
|
729
729
|
|
|
730
730
|
# @unittest.skip('Work in progress')
|
|
731
731
|
def test_creating_empty_resource(self):
|
|
732
732
|
r0 = ResourceClass(con=self._connection,
|
|
733
733
|
project=self._project,
|
|
734
|
-
owlclass_iri=
|
|
734
|
+
owlclass_iri=Xsd_QName("test:TestResourceEmpty"))
|
|
735
735
|
|
|
736
736
|
r0.create()
|
|
737
737
|
|
|
738
738
|
def test_creating_resource_incremental(self):
|
|
739
739
|
r0 = ResourceClass(con=self._connection,
|
|
740
740
|
project=self._project,
|
|
741
|
-
owlclass_iri=
|
|
741
|
+
owlclass_iri=Xsd_QName("test:TestResourceIncremental", validate=False))
|
|
742
742
|
r0.create()
|
|
743
743
|
|
|
744
744
|
p1 = PropertyClass(con=self._connection,
|
|
745
745
|
project=self._project,
|
|
746
|
-
property_class_iri=
|
|
746
|
+
property_class_iri=Xsd_QName('test:testIncrementalProp1'),
|
|
747
747
|
subPropertyOf=Iri('test:comment'),
|
|
748
748
|
datatype=XsdDatatypes.langString,
|
|
749
749
|
name=LangString(["Test property@en", "Testprädikat@de"]),
|
|
@@ -751,27 +751,27 @@ class TestResourceClass(unittest.TestCase):
|
|
|
751
751
|
uniqueLang=Xsd_boolean(True),
|
|
752
752
|
languageIn=LanguageIn(Language.EN, Language.DE, Language.FR, Language.IT))
|
|
753
753
|
hp1 = HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, order=1.0)
|
|
754
|
-
r0[
|
|
754
|
+
r0[Xsd_QName('test:testIncrementalProp1')] = hp1
|
|
755
755
|
r0.update()
|
|
756
756
|
|
|
757
757
|
r0 = ResourceClass.read(con=self._connection,
|
|
758
758
|
project=self._project,
|
|
759
|
-
owl_class_iri=
|
|
760
|
-
self.assertEqual(r0.owl_class_iri,
|
|
761
|
-
self.assertTrue(
|
|
762
|
-
hp1 = r0[
|
|
759
|
+
owl_class_iri=Xsd_QName("test:TestResourceIncremental", validate=False))
|
|
760
|
+
self.assertEqual(r0.owl_class_iri, Xsd_QName("test:TestResourceIncremental", validate=False))
|
|
761
|
+
self.assertTrue(Xsd_QName("oldap:Thing", validate=False) in r0.superclass)
|
|
762
|
+
hp1 = r0[Xsd_QName('test:testIncrementalProp1')]
|
|
763
763
|
self.assertEqual(hp1.minCount, 1)
|
|
764
764
|
self.assertIsNone(hp1.maxCount)
|
|
765
765
|
self.assertEqual(hp1.order, 1.0)
|
|
766
|
-
self.assertEqual(hp1.prop.property_class_iri,
|
|
767
|
-
self.assertEqual(hp1.prop.subPropertyOf,
|
|
766
|
+
self.assertEqual(hp1.prop.property_class_iri, Xsd_QName("test:testIncrementalProp1", validate=False))
|
|
767
|
+
self.assertEqual(hp1.prop.subPropertyOf, Xsd_QName("test:comment"))
|
|
768
768
|
self.assertEqual(hp1.prop.datatype, XsdDatatypes.langString)
|
|
769
769
|
|
|
770
770
|
# TODO: Start systematic testing here!!!!!!!!!!!!¨
|
|
771
771
|
def test_creating(self):
|
|
772
772
|
p1 = PropertyClass(con=self._connection,
|
|
773
773
|
project=self._project,
|
|
774
|
-
property_class_iri=
|
|
774
|
+
property_class_iri=Xsd_QName('test:testone'),
|
|
775
775
|
subPropertyOf=Iri('test:comment'),
|
|
776
776
|
datatype=XsdDatatypes.langString,
|
|
777
777
|
name=LangString(["Test property@en", "Testprädikat@de"]),
|
|
@@ -781,29 +781,29 @@ class TestResourceClass(unittest.TestCase):
|
|
|
781
781
|
|
|
782
782
|
p2 = PropertyClass(con=self._connection,
|
|
783
783
|
project=self._project,
|
|
784
|
-
property_class_iri=
|
|
785
|
-
toClass=
|
|
784
|
+
property_class_iri=Xsd_QName('test:testtwo'),
|
|
785
|
+
toClass=Xsd_QName('test:testMyRes'),
|
|
786
786
|
name=LangString(["Excl. Test property@en", "Exkl. Testprädikat@de"]),
|
|
787
787
|
description=LangString("An exclusive property for testing...@en"))
|
|
788
788
|
|
|
789
789
|
p3 = PropertyClass(con=self._connection,
|
|
790
790
|
project=self._project,
|
|
791
|
-
property_class_iri=
|
|
791
|
+
property_class_iri=Xsd_QName('test:testthree'),
|
|
792
792
|
datatype=XsdDatatypes.int,
|
|
793
793
|
name=LangString(["E.N.U.M@en"]),
|
|
794
794
|
description=LangString("An exclusive enum testing...@en"),
|
|
795
795
|
inSet=RdfSet(Xsd_integer(1), Xsd_integer(2), Xsd_integer(3)))
|
|
796
796
|
|
|
797
797
|
hasproperties: list[HasProperty] = [
|
|
798
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
799
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
798
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, order=1),
|
|
799
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:test"), minCount=1, order=2),
|
|
800
800
|
HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, maxCount=1, order=3),
|
|
801
801
|
HasProperty(con=self._connection, project=self._project, prop=p2, minCount=1, order=4),
|
|
802
802
|
HasProperty(con=self._connection, project=self._project, prop=p3, maxCount=1, order=5)
|
|
803
803
|
]
|
|
804
804
|
r1 = ResourceClass(con=self._connection,
|
|
805
805
|
project=self._project,
|
|
806
|
-
owlclass_iri=
|
|
806
|
+
owlclass_iri=Xsd_QName("test:TestResource"),
|
|
807
807
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
808
808
|
comment=LangString("For testing purposes@en"),
|
|
809
809
|
closed=Xsd_boolean(True),
|
|
@@ -811,59 +811,59 @@ class TestResourceClass(unittest.TestCase):
|
|
|
811
811
|
r1.create()
|
|
812
812
|
r2 = ResourceClass.read(con=self._connection,
|
|
813
813
|
project=self._project,
|
|
814
|
-
owl_class_iri=
|
|
814
|
+
owl_class_iri=Xsd_QName("test:TestResource"))
|
|
815
815
|
self.assertEqual(r2.owl_class_iri, Xsd_QName("test:TestResource"))
|
|
816
816
|
self.assertEqual(r2.label, LangString(["CreateResTest@en", "CréationResTeste@fr"]))
|
|
817
817
|
self.assertEqual(r2.comment, LangString("For testing purposes@en"))
|
|
818
818
|
self.assertTrue(r2.closed)
|
|
819
819
|
|
|
820
|
-
prop1 = r2[
|
|
820
|
+
prop1 = r2[Xsd_QName("test:comment")].prop
|
|
821
821
|
self.assertIsNone(prop1.internal)
|
|
822
|
-
self.assertEqual(prop1.property_class_iri,
|
|
822
|
+
self.assertEqual(prop1.property_class_iri, Xsd_QName('test:comment'))
|
|
823
823
|
self.assertEqual(prop1.datatype, XsdDatatypes.langString)
|
|
824
824
|
self.assertTrue(prop1.uniqueLang)
|
|
825
|
-
self.assertEqual(r2[
|
|
825
|
+
self.assertEqual(r2[Xsd_QName("test:comment")].maxCount, Xsd_integer(1))
|
|
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
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
|
-
self.assertEqual(r2[
|
|
832
|
+
self.assertEqual(r2[Xsd_QName("test:comment")].order, Xsd_decimal(1))
|
|
833
833
|
|
|
834
|
-
prop2 = r2[
|
|
834
|
+
prop2 = r2[Xsd_QName("test:test")].prop
|
|
835
835
|
self.assertIsNone(prop1.internal)
|
|
836
|
-
self.assertEqual(prop2.property_class_iri,
|
|
837
|
-
self.assertEqual(r2[
|
|
836
|
+
self.assertEqual(prop2.property_class_iri, Xsd_QName('test:test'))
|
|
837
|
+
self.assertEqual(r2[Xsd_QName("test:test")].minCount, Xsd_integer(1))
|
|
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
841
|
self.assertEqual(prop2.type, OwlPropertyType.OwlDataProperty)
|
|
842
|
-
self.assertEqual(r2[
|
|
842
|
+
self.assertEqual(r2[Xsd_QName("test:test")].order, Xsd_decimal(2))
|
|
843
843
|
|
|
844
|
-
prop3 = r2[
|
|
845
|
-
self.assertEqual(prop3.internal,
|
|
846
|
-
self.assertEqual(prop3.property_class_iri,
|
|
844
|
+
prop3 = r2[Xsd_QName("test:testone")].prop
|
|
845
|
+
self.assertEqual(prop3.internal, Xsd_QName("test:TestResource"))
|
|
846
|
+
self.assertEqual(prop3.property_class_iri, Xsd_QName("test:testone"))
|
|
847
847
|
self.assertEqual(prop3.datatype, XsdDatatypes.langString)
|
|
848
848
|
self.assertEqual(prop3.name, LangString(["Test property@en", "Testprädikat@de"]))
|
|
849
849
|
self.assertEqual(prop3.description, LangString("A property for testing...@en"))
|
|
850
|
-
self.assertEqual(r2[
|
|
851
|
-
self.assertEqual(r2[
|
|
850
|
+
self.assertEqual(r2[Xsd_QName("test:testone")].minCount, Xsd_integer(1))
|
|
851
|
+
self.assertEqual(r2[Xsd_QName("test:testone")].maxCount, Xsd_integer(1))
|
|
852
852
|
self.assertEqual(prop3.languageIn, LanguageIn(Language.EN, Language.DE, Language.FR, Language.IT))
|
|
853
853
|
self.assertTrue(prop3.uniqueLang)
|
|
854
|
-
self.assertEqual(r2[
|
|
854
|
+
self.assertEqual(r2[Xsd_QName("test:testone")].order, Xsd_decimal(3))
|
|
855
855
|
|
|
856
|
-
prop4 = r2[
|
|
857
|
-
self.assertEqual(prop4.internal,
|
|
858
|
-
self.assertEqual(prop4.property_class_iri,
|
|
859
|
-
self.assertEqual(prop4.toClass,
|
|
856
|
+
prop4 = r2[Xsd_QName("test:testtwo")].prop
|
|
857
|
+
self.assertEqual(prop4.internal, Xsd_QName("test:TestResource"))
|
|
858
|
+
self.assertEqual(prop4.property_class_iri, Xsd_QName("test:testtwo"))
|
|
859
|
+
self.assertEqual(prop4.toClass, Xsd_QName('test:testMyRes'))
|
|
860
860
|
self.assertEqual(prop4.name, LangString(["Excl. Test property@en", "Exkl. Testprädikat@de"]))
|
|
861
861
|
self.assertEqual(prop4.description, LangString("An exclusive property for testing...@en"))
|
|
862
|
-
self.assertEqual(r2[
|
|
863
|
-
self.assertEqual(r2[
|
|
862
|
+
self.assertEqual(r2[Xsd_QName("test:testtwo")].minCount, Xsd_integer(1))
|
|
863
|
+
self.assertEqual(r2[Xsd_QName("test:testtwo")].order, Xsd_decimal(4))
|
|
864
864
|
|
|
865
|
-
prop5 = r2[
|
|
866
|
-
self.assertEqual(prop5.internal,
|
|
865
|
+
prop5 = r2[Xsd_QName("test:testthree")].prop
|
|
866
|
+
self.assertEqual(prop5.internal, Xsd_QName("test:TestResource"))
|
|
867
867
|
self.assertEqual(prop5.inSet, RdfSet(Xsd_integer(1), Xsd_integer(2), Xsd_integer(3)))
|
|
868
868
|
# r2[Iri("test:testthree")].prop.inSet.add(Xsd_integer(4))
|
|
869
869
|
# del r2[Iri("test:testthree")].maxCount
|
|
@@ -876,8 +876,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
876
876
|
def test_creating_nopermission(self):
|
|
877
877
|
p1 = PropertyClass(con=self._unpriv,
|
|
878
878
|
project=self._project,
|
|
879
|
-
property_class_iri=
|
|
880
|
-
subPropertyOf=
|
|
879
|
+
property_class_iri=Xsd_QName('test:testone_np'),
|
|
880
|
+
subPropertyOf=Xsd_QName('test:comment'),
|
|
881
881
|
datatype=XsdDatatypes.langString,
|
|
882
882
|
name=LangString(["Test property@en", "Testprädikat@de"]),
|
|
883
883
|
description=LangString("A property for testing...@en"),
|
|
@@ -886,29 +886,29 @@ class TestResourceClass(unittest.TestCase):
|
|
|
886
886
|
|
|
887
887
|
p2 = PropertyClass(con=self._unpriv,
|
|
888
888
|
project=self._project,
|
|
889
|
-
property_class_iri=
|
|
890
|
-
toClass=
|
|
889
|
+
property_class_iri=Xsd_QName('test:testtwo_np'),
|
|
890
|
+
toClass=Xsd_QName('test:testMyRes'),
|
|
891
891
|
name=LangString(["Excl. Test property@en", "Exkl. Testprädikat@de"]),
|
|
892
892
|
description=LangString("An exclusive property for testing...@en"))
|
|
893
893
|
|
|
894
894
|
p3 = PropertyClass(con=self._unpriv,
|
|
895
895
|
project=self._project,
|
|
896
|
-
property_class_iri=
|
|
896
|
+
property_class_iri=Xsd_QName('test:testthree_np'),
|
|
897
897
|
datatype=XsdDatatypes.int,
|
|
898
898
|
name=LangString(["E.N.U.M@en"]),
|
|
899
899
|
description=LangString("An exclusive enum testing...@en"),
|
|
900
900
|
inSet=RdfSet(Xsd_integer(1), Xsd_integer(2), Xsd_integer(3)))
|
|
901
901
|
|
|
902
902
|
hasproperties: list[HasProperty] = [
|
|
903
|
-
HasProperty(con=self._unpriv, project=self._project, prop=
|
|
904
|
-
HasProperty(con=self._unpriv, project=self._project, prop=
|
|
903
|
+
HasProperty(con=self._unpriv, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, order=1),
|
|
904
|
+
HasProperty(con=self._unpriv, project=self._project, prop=Xsd_QName("test:test"), minCount=1, order=2),
|
|
905
905
|
HasProperty(con=self._unpriv, project=self._project, prop=p1, minCount=1, maxCount=1, order=3),
|
|
906
906
|
HasProperty(con=self._unpriv, project=self._project, prop=p2, minCount=1, order=4),
|
|
907
907
|
HasProperty(con=self._unpriv, project=self._project, prop=p3, order=5)
|
|
908
908
|
]
|
|
909
909
|
r1 = ResourceClass(con=self._unpriv,
|
|
910
910
|
project=self._project,
|
|
911
|
-
owlclass_iri=
|
|
911
|
+
owlclass_iri=Xsd_QName("test:TestResource_np"),
|
|
912
912
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
913
913
|
comment=LangString("For testing purposes@en"),
|
|
914
914
|
closed=Xsd_boolean(True),
|
|
@@ -917,11 +917,11 @@ class TestResourceClass(unittest.TestCase):
|
|
|
917
917
|
with self.assertRaises(OldapErrorNoPermission):
|
|
918
918
|
r1.create()
|
|
919
919
|
|
|
920
|
-
|
|
921
920
|
def test_creating_with_superclass(self):
|
|
921
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
922
922
|
p1 = PropertyClass(con=self._connection,
|
|
923
923
|
project=self._project,
|
|
924
|
-
property_class_iri=
|
|
924
|
+
property_class_iri=Xsd_QName('test:sctest_prop1'),
|
|
925
925
|
datatype=XsdDatatypes.string,
|
|
926
926
|
name=LangString(["TestProp1"]))
|
|
927
927
|
hasproperties: list[HasProperty] = [
|
|
@@ -929,8 +929,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
929
929
|
]
|
|
930
930
|
r1 = ResourceClass(con=self._connection,
|
|
931
931
|
project=self._project,
|
|
932
|
-
owlclass_iri=
|
|
933
|
-
superclass={"test:testMyResMinimal", '
|
|
932
|
+
owlclass_iri=Xsd_QName("test:ResWithSuperclasses"),
|
|
933
|
+
superclass={"test:testMyResMinimal", 'crm:E22_Man-Made_Object'},
|
|
934
934
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
935
935
|
comment=LangString("For testing purposes@en"),
|
|
936
936
|
closed=Xsd_boolean(True),
|
|
@@ -938,35 +938,36 @@ class TestResourceClass(unittest.TestCase):
|
|
|
938
938
|
r1.create()
|
|
939
939
|
r2 = ResourceClass.read(con=self._connection,
|
|
940
940
|
project=self._project,
|
|
941
|
-
owl_class_iri=
|
|
941
|
+
owl_class_iri=Xsd_QName('test:ResWithSuperclasses'))
|
|
942
942
|
s = set(r2.superclass.keys())
|
|
943
|
-
self.assertEqual({"oldap:Thing", "test:testMyResMinimal", '
|
|
943
|
+
self.assertEqual({"oldap:Thing", "test:testMyResMinimal", 'crm:E22_Man-Made_Object'}, s)
|
|
944
944
|
|
|
945
945
|
def test_updating_superclass_add(self):
|
|
946
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
946
947
|
r1 = ResourceClass(con=self._connection,
|
|
947
948
|
project=self._project,
|
|
948
|
-
owlclass_iri=
|
|
949
|
+
owlclass_iri=Xsd_QName("test:Superclass1"),
|
|
949
950
|
label=LangString(["Superclass1@en", "Superclass1@fr"]),
|
|
950
951
|
closed=Xsd_boolean(True))
|
|
951
952
|
r1.create()
|
|
952
953
|
|
|
953
954
|
r2 = ResourceClass(con=self._connection,
|
|
954
955
|
project=self._project,
|
|
955
|
-
owlclass_iri=
|
|
956
|
+
owlclass_iri=Xsd_QName("test:Superclass2"),
|
|
956
957
|
label=LangString(["Superclass2@en", "Superclass2@fr"]),
|
|
957
958
|
closed=Xsd_boolean(True))
|
|
958
959
|
r2.create()
|
|
959
960
|
|
|
960
961
|
r3 = ResourceClass(con=self._connection,
|
|
961
962
|
project=self._project,
|
|
962
|
-
owlclass_iri=
|
|
963
|
+
owlclass_iri=Xsd_QName("test:Superclass3"),
|
|
963
964
|
label=LangString(["Superclass2@en", "Superclass2@fr"]),
|
|
964
965
|
closed=Xsd_boolean(True))
|
|
965
966
|
r3.create()
|
|
966
967
|
|
|
967
968
|
p1 = PropertyClass(con=self._connection,
|
|
968
969
|
project=self._project,
|
|
969
|
-
property_class_iri=
|
|
970
|
+
property_class_iri=Xsd_QName('test:thingtest_prop1'),
|
|
970
971
|
datatype=XsdDatatypes.string,
|
|
971
972
|
name=LangString(["ThingTestProp1"]))
|
|
972
973
|
hasproperties: list[HasProperty] = [
|
|
@@ -974,8 +975,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
974
975
|
]
|
|
975
976
|
r = ResourceClass(con=self._connection,
|
|
976
977
|
project=self._project,
|
|
977
|
-
owlclass_iri=
|
|
978
|
-
superclass={'
|
|
978
|
+
owlclass_iri=Xsd_QName("test:ResWithSuperThingAdd"),
|
|
979
|
+
superclass={'crm:E22_Man-Made_Object', "test:Superclass1"},
|
|
979
980
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
980
981
|
comment=LangString("For testing purposes@en"),
|
|
981
982
|
closed=Xsd_boolean(True),
|
|
@@ -983,40 +984,41 @@ class TestResourceClass(unittest.TestCase):
|
|
|
983
984
|
r.create()
|
|
984
985
|
r = ResourceClass.read(con=self._connection,
|
|
985
986
|
project=self._project,
|
|
986
|
-
owl_class_iri=
|
|
987
|
+
owl_class_iri=Xsd_QName('test:ResWithSuperThingAdd'))
|
|
987
988
|
r.add_superclasses({'test:Superclass2', 'test:Superclass3'})
|
|
988
989
|
r.update()
|
|
989
990
|
r = ResourceClass.read(con=self._connection,
|
|
990
991
|
project=self._project,
|
|
991
|
-
owl_class_iri=
|
|
992
|
+
owl_class_iri=Xsd_QName('test:ResWithSuperThingAdd'))
|
|
992
993
|
s = set(r.superclass.keys())
|
|
993
|
-
self.assertEqual(s, {"oldap:Thing", '
|
|
994
|
+
self.assertEqual(s, {"oldap:Thing", 'crm:E22_Man-Made_Object', "test:Superclass1", "test:Superclass2", "test:Superclass3"})
|
|
994
995
|
|
|
995
996
|
def test_updating_superclass_del(self):
|
|
997
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
996
998
|
r1 = ResourceClass(con=self._connection,
|
|
997
999
|
project=self._project,
|
|
998
|
-
owlclass_iri=
|
|
1000
|
+
owlclass_iri=Xsd_QName("test:SuperclassDel1"),
|
|
999
1001
|
label=LangString(["SuperclassDel1@en", "SuperclassDel1@fr"]),
|
|
1000
1002
|
closed=Xsd_boolean(True))
|
|
1001
1003
|
r1.create()
|
|
1002
1004
|
|
|
1003
1005
|
r2 = ResourceClass(con=self._connection,
|
|
1004
1006
|
project=self._project,
|
|
1005
|
-
owlclass_iri=
|
|
1007
|
+
owlclass_iri=Xsd_QName("test:SuperclassDel2"),
|
|
1006
1008
|
label=LangString(["SuperclassDel2@en", "SuperclassDel2@fr"]),
|
|
1007
1009
|
closed=Xsd_boolean(True))
|
|
1008
1010
|
r2.create()
|
|
1009
1011
|
|
|
1010
1012
|
r3 = ResourceClass(con=self._connection,
|
|
1011
1013
|
project=self._project,
|
|
1012
|
-
owlclass_iri=
|
|
1014
|
+
owlclass_iri=Xsd_QName("test:SuperclassDel3"),
|
|
1013
1015
|
label=LangString(["SuperclassDel3@en", "SuperclassDel3@fr"]),
|
|
1014
1016
|
closed=Xsd_boolean(True))
|
|
1015
1017
|
r3.create()
|
|
1016
1018
|
|
|
1017
1019
|
p1 = PropertyClass(con=self._connection,
|
|
1018
1020
|
project=self._project,
|
|
1019
|
-
property_class_iri=
|
|
1021
|
+
property_class_iri=Xsd_QName('test:deltest_prop1'),
|
|
1020
1022
|
datatype=XsdDatatypes.string,
|
|
1021
1023
|
name=LangString(["DelTestProp1"]))
|
|
1022
1024
|
hasproperties: list[HasProperty] = [
|
|
@@ -1024,9 +1026,9 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1024
1026
|
]
|
|
1025
1027
|
r = ResourceClass(con=self._connection,
|
|
1026
1028
|
project=self._project,
|
|
1027
|
-
owlclass_iri=
|
|
1029
|
+
owlclass_iri=Xsd_QName("test:ResWithManySuper2"),
|
|
1028
1030
|
superclass={
|
|
1029
|
-
'
|
|
1031
|
+
'crm:E22_Man-Made_Object',
|
|
1030
1032
|
"test:SuperclassDel1",
|
|
1031
1033
|
"test:SuperclassDel2",
|
|
1032
1034
|
"test:SuperclassDel3"},
|
|
@@ -1037,19 +1039,20 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1037
1039
|
r.create()
|
|
1038
1040
|
r = ResourceClass.read(con=self._connection,
|
|
1039
1041
|
project=self._project,
|
|
1040
|
-
owl_class_iri=
|
|
1042
|
+
owl_class_iri=Xsd_QName("test:ResWithManySuper2"))
|
|
1041
1043
|
r.del_superclasses({'test:SuperclassDel1', 'test:SuperclassDel3'})
|
|
1042
1044
|
r.update()
|
|
1043
1045
|
r = ResourceClass.read(con=self._connection,
|
|
1044
1046
|
project=self._project,
|
|
1045
|
-
owl_class_iri=
|
|
1047
|
+
owl_class_iri=Xsd_QName("test:ResWithManySuper2"))
|
|
1046
1048
|
s = set(r.superclass.keys())
|
|
1047
|
-
self.assertEqual(s, {"oldap:Thing", '
|
|
1049
|
+
self.assertEqual(s, {"oldap:Thing", 'crm:E22_Man-Made_Object', "test:SuperclassDel2"})
|
|
1048
1050
|
|
|
1049
1051
|
def test_creating_with_thing_sc(self):
|
|
1052
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
1050
1053
|
p1 = PropertyClass(con=self._connection,
|
|
1051
1054
|
project=self._project,
|
|
1052
|
-
property_class_iri=
|
|
1055
|
+
property_class_iri=Xsd_QName('test:thingtest_prop1'),
|
|
1053
1056
|
datatype=XsdDatatypes.string,
|
|
1054
1057
|
name=LangString(["ThingTestProp1"]))
|
|
1055
1058
|
hasproperties: list[HasProperty] = [
|
|
@@ -1057,8 +1060,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1057
1060
|
]
|
|
1058
1061
|
r1 = ResourceClass(con=self._connection,
|
|
1059
1062
|
project=self._project,
|
|
1060
|
-
owlclass_iri=
|
|
1061
|
-
superclass={'oldap:Thing', '
|
|
1063
|
+
owlclass_iri=Xsd_QName("test:ResWithSuperThing"),
|
|
1064
|
+
superclass={'oldap:Thing', 'crm:E22_Man-Made_Object'},
|
|
1062
1065
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1063
1066
|
comment=LangString("For testing purposes@en"),
|
|
1064
1067
|
closed=Xsd_boolean(True),
|
|
@@ -1066,19 +1069,19 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1066
1069
|
r1.create()
|
|
1067
1070
|
r2 = ResourceClass.read(con=self._connection,
|
|
1068
1071
|
project=self._project,
|
|
1069
|
-
owl_class_iri=
|
|
1072
|
+
owl_class_iri=Xsd_QName('test:ResWithSuperThing'))
|
|
1070
1073
|
s = set(r2.superclass.keys())
|
|
1071
|
-
self.assertEqual({'oldap:Thing',
|
|
1074
|
+
self.assertEqual({'oldap:Thing', Xsd_QName('crm:E22_Man-Made_Object')}, s)
|
|
1072
1075
|
|
|
1073
1076
|
# @unittest.skip('Work in progress')
|
|
1074
1077
|
def test_double_creation(self):
|
|
1075
1078
|
hasproperties: list[HasProperty] = [
|
|
1076
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
1077
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
1079
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment")),
|
|
1080
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:test")),
|
|
1078
1081
|
]
|
|
1079
1082
|
r1 = ResourceClass(con=self._connection,
|
|
1080
1083
|
project=self._project,
|
|
1081
|
-
owlclass_iri=
|
|
1084
|
+
owlclass_iri=Xsd_QName("test:testMyResMinimal"),
|
|
1082
1085
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1083
1086
|
comment=LangString("For testing purposes@en"),
|
|
1084
1087
|
closed=Xsd_boolean(True),
|
|
@@ -1091,157 +1094,157 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1091
1094
|
def test_updating_resclass_attributes_add(self):
|
|
1092
1095
|
r1 = ResourceClass.read(con=self._connection,
|
|
1093
1096
|
project=self._project,
|
|
1094
|
-
owl_class_iri=
|
|
1097
|
+
owl_class_iri=Xsd_QName("test:testMyRes"))
|
|
1095
1098
|
r1.label.add("labello@it")
|
|
1096
1099
|
r1.update()
|
|
1097
1100
|
r2 = ResourceClass.read(con=self._connection,
|
|
1098
1101
|
project=self._project,
|
|
1099
|
-
owl_class_iri=
|
|
1102
|
+
owl_class_iri=Xsd_QName("test:testMyRes"))
|
|
1100
1103
|
self.assertEqual(r1.label, LangString("My Resource@en", "Meine Ressource@de", "Ma Resource@fr", "labello@it"))
|
|
1101
1104
|
|
|
1102
1105
|
def test_updating_resclass_attributes(self):
|
|
1103
1106
|
r1 = ResourceClass.read(con=self._connection,
|
|
1104
1107
|
project=self._project,
|
|
1105
|
-
owl_class_iri=
|
|
1108
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimalA"))
|
|
1106
1109
|
#self.assertTrue(r1.closed)
|
|
1107
1110
|
r1[ResClassAttribute.LABEL] = LangString(["Minimal Resource@en", "Kleinste Resource@de", "Plus petite ressource@fr"])
|
|
1108
1111
|
r1[ResClassAttribute.COMMENT] = LangString("Eine Beschreibung einer minimalen Ressource")
|
|
1109
|
-
r1[ResClassAttribute.SUPERCLASS] =
|
|
1112
|
+
r1[ResClassAttribute.SUPERCLASS] = Xsd_QName("test:testMyRes")
|
|
1110
1113
|
r1.update()
|
|
1111
1114
|
r2 = ResourceClass.read(con=self._connection,
|
|
1112
1115
|
project=self._project,
|
|
1113
|
-
owl_class_iri=
|
|
1116
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimalA"))
|
|
1114
1117
|
self.assertEqual(LangString(["Minimal Resource@en", "Kleinste Resource@de", "Plus petite ressource@fr"]), r2.label)
|
|
1115
1118
|
self.assertEqual(LangString("Eine Beschreibung einer minimalen Ressource"), r2.comment)
|
|
1116
|
-
self.assertEqual({
|
|
1119
|
+
self.assertEqual({Xsd_QName('test:testMyRes'), Xsd_QName('oldap:Thing')}, set(r2.superclass))
|
|
1117
1120
|
|
|
1118
1121
|
|
|
1119
1122
|
def test_updating_add_ext_prop(self):
|
|
1120
1123
|
r1 = ResourceClass.read(con=self._connection,
|
|
1121
1124
|
project=self._project,
|
|
1122
|
-
owl_class_iri=
|
|
1125
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimalA"))
|
|
1123
1126
|
self.assertTrue(r1.closed)
|
|
1124
1127
|
|
|
1125
1128
|
r1[ResClassAttribute.LABEL] = LangString(["Minimal Resource@en", "Kleinste Resource@de", "Plus petite ressource@fr"])
|
|
1126
1129
|
r1[ResClassAttribute.COMMENT] = LangString("Eine Beschreibung einer minimalen Ressource")
|
|
1127
|
-
r1[ResClassAttribute.SUPERCLASS] =
|
|
1130
|
+
r1[ResClassAttribute.SUPERCLASS] = Xsd_QName("test:testMyRes")
|
|
1128
1131
|
r1[ResClassAttribute.CLOSED] = Xsd_boolean(False)
|
|
1129
1132
|
|
|
1130
1133
|
#
|
|
1131
1134
|
# Add an external, shared property defined by its own sh:PropertyShape instance
|
|
1132
1135
|
#
|
|
1133
|
-
r1[
|
|
1136
|
+
r1[Xsd_QName('test:test')] = HasProperty(con=self._connection,
|
|
1134
1137
|
project=self._project,
|
|
1135
|
-
prop=
|
|
1138
|
+
prop=Xsd_QName("test:test"),
|
|
1136
1139
|
minCount=1,
|
|
1137
1140
|
order=3,
|
|
1138
1141
|
notifier=r1.notifier,
|
|
1139
|
-
notify_data=
|
|
1142
|
+
notify_data=Xsd_QName("test:test"))
|
|
1140
1143
|
r1.update()
|
|
1141
1144
|
del r1
|
|
1142
1145
|
r2 = ResourceClass.read(con=self._connection,
|
|
1143
1146
|
project=self._project,
|
|
1144
|
-
owl_class_iri=
|
|
1147
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimalA"))
|
|
1145
1148
|
self.assertEqual(LangString(["Minimal Resource@en", "Kleinste Resource@de", "Plus petite ressource@fr"]), r2.label)
|
|
1146
1149
|
self.assertEqual(LangString("Eine Beschreibung einer minimalen Ressource"), r2.comment)
|
|
1147
|
-
self.assertEqual({
|
|
1148
|
-
self.assertIsInstance(r2.superclass[
|
|
1150
|
+
self.assertEqual({Xsd_QName('test:testMyRes'), Xsd_QName('oldap:Thing')}, set(r2.superclass))
|
|
1151
|
+
self.assertIsInstance(r2.superclass[Xsd_QName('test:testMyRes')], ResourceClass)
|
|
1149
1152
|
self.assertFalse(r2[ResClassAttribute.CLOSED])
|
|
1150
1153
|
|
|
1151
|
-
prop1 = r2[
|
|
1154
|
+
prop1 = r2[Xsd_QName('test:test')].prop
|
|
1152
1155
|
self.assertIsNone(prop1.internal)
|
|
1153
|
-
self.assertEqual(prop1.property_class_iri,
|
|
1154
|
-
self.assertEqual(r2[
|
|
1156
|
+
self.assertEqual(prop1.property_class_iri, Xsd_QName('test:test'))
|
|
1157
|
+
self.assertEqual(r2[Xsd_QName('test:test')].minCount, Xsd_integer(1))
|
|
1155
1158
|
self.assertEqual(prop1.name, LangString("Test"))
|
|
1156
1159
|
self.assertEqual(prop1.description, LangString("Property shape for testing purposes"))
|
|
1157
1160
|
self.assertEqual(prop1.datatype, XsdDatatypes.string)
|
|
1158
|
-
self.assertEqual(r2[
|
|
1161
|
+
self.assertEqual(r2[Xsd_QName('test:test')].order, Xsd_decimal(3))
|
|
1159
1162
|
self.assertEqual(prop1.type, OwlPropertyType.OwlDataProperty)
|
|
1160
1163
|
|
|
1161
1164
|
def test_updating_add_int_prop(self):
|
|
1162
1165
|
r1 = ResourceClass.read(con=self._connection,
|
|
1163
1166
|
project=self._project,
|
|
1164
|
-
owl_class_iri=
|
|
1167
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimalB"))
|
|
1165
1168
|
self.assertTrue(r1.closed)
|
|
1166
1169
|
r1[ResClassAttribute.LABEL] = LangString(["Minimal Resource@en", "Kleinste Resource@de", "Plus petite ressource@fr"])
|
|
1167
1170
|
r1[ResClassAttribute.COMMENT] = LangString("Eine Beschreibung einer minimalen Ressource")
|
|
1168
|
-
r1[ResClassAttribute.SUPERCLASS] =
|
|
1171
|
+
r1[ResClassAttribute.SUPERCLASS] = Xsd_QName("test:testMyRes")
|
|
1169
1172
|
r1[ResClassAttribute.CLOSED] = Xsd_boolean(False)
|
|
1170
1173
|
|
|
1171
1174
|
p = PropertyClass(con=self._connection,
|
|
1172
1175
|
project=self._project,
|
|
1173
|
-
toClass=
|
|
1174
|
-
r1[
|
|
1176
|
+
toClass=Xsd_QName('test:Person'))
|
|
1177
|
+
r1[Xsd_QName('dcterms:contributor')] = HasProperty(con=self._connection, project=self._project, prop=p, maxCount=Xsd_integer(1))
|
|
1175
1178
|
|
|
1176
1179
|
r1.update()
|
|
1177
1180
|
del r1
|
|
1178
1181
|
r2 = ResourceClass.read(con=self._connection,
|
|
1179
1182
|
project=self._project,
|
|
1180
|
-
owl_class_iri=
|
|
1181
|
-
prop1 = r2[
|
|
1183
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimalB"))
|
|
1184
|
+
prop1 = r2[Xsd_QName('dcterms:contributor')].prop
|
|
1182
1185
|
self.assertEqual(prop1.internal, Xsd_QName("test:testMyResMinimalB"))
|
|
1183
1186
|
self.assertEqual(prop1.toClass, Xsd_QName('test:Person'))
|
|
1184
|
-
self.assertEqual(r2[
|
|
1187
|
+
self.assertEqual(r2[Xsd_QName('dcterms:contributor')].maxCount, Xsd_integer(1))
|
|
1185
1188
|
self.assertEqual(prop1.type, OwlPropertyType.OwlObjectProperty)
|
|
1186
1189
|
|
|
1187
1190
|
# @unittest.skip('Work in progress')
|
|
1188
1191
|
def test_updating_add(self):
|
|
1189
1192
|
r1 = ResourceClass.read(con=self._connection,
|
|
1190
1193
|
project=self._project,
|
|
1191
|
-
owl_class_iri=
|
|
1194
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimalC"))
|
|
1192
1195
|
self.assertTrue(r1.closed)
|
|
1193
1196
|
r1[ResClassAttribute.LABEL] = LangString(["Minimal Resource@en", "Kleinste Resource@de", "Plus petite ressource@fr"])
|
|
1194
1197
|
r1[ResClassAttribute.COMMENT] = LangString("Eine Beschreibung einer minimalen Ressource")
|
|
1195
|
-
r1[ResClassAttribute.SUPERCLASS] =
|
|
1198
|
+
r1[ResClassAttribute.SUPERCLASS] = Xsd_QName("test:testMyRes")
|
|
1196
1199
|
r1[ResClassAttribute.CLOSED] = Xsd_boolean(False)
|
|
1197
1200
|
|
|
1198
1201
|
#
|
|
1199
1202
|
# Add an external, shared property defined by its own sh:PropertyShape instance
|
|
1200
1203
|
#
|
|
1201
|
-
r1[
|
|
1204
|
+
r1[Xsd_QName('test:test')] = HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:test"), minCount=1, order=3)
|
|
1202
1205
|
|
|
1203
1206
|
#
|
|
1204
1207
|
# Adding an internal, private property
|
|
1205
1208
|
#
|
|
1206
1209
|
p = PropertyClass(con=self._connection,
|
|
1207
1210
|
project=self._project,
|
|
1208
|
-
toClass=
|
|
1209
|
-
r1[
|
|
1211
|
+
toClass=Xsd_QName('test:Person'))
|
|
1212
|
+
r1[Xsd_QName('dcterms:creator')] = HasProperty(con=self._connection, project=self._project, prop=p, maxCount=Xsd_integer(1))
|
|
1210
1213
|
|
|
1211
1214
|
p2 = PropertyClass(con=self._connection,
|
|
1212
1215
|
project=self._project,
|
|
1213
1216
|
datatype=XsdDatatypes.string,
|
|
1214
1217
|
inSet=RdfSet(Xsd_string('A'), Xsd_string('B'), Xsd_string('C'), Xsd_string('D'))
|
|
1215
1218
|
)
|
|
1216
|
-
r1[
|
|
1219
|
+
r1[Xsd_QName('test:color')] = HasProperty(con=self._connection, project=self._project, prop=p2)
|
|
1217
1220
|
r1.update()
|
|
1218
1221
|
del r1
|
|
1219
1222
|
r2 = ResourceClass.read(con=self._connection,
|
|
1220
1223
|
project=self._project,
|
|
1221
|
-
owl_class_iri=
|
|
1224
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimalC"))
|
|
1222
1225
|
self.assertEqual(LangString(["Minimal Resource@en", "Kleinste Resource@de", "Plus petite ressource@fr"]), r2.label)
|
|
1223
1226
|
self.assertEqual(LangString("Eine Beschreibung einer minimalen Ressource"), r2.comment)
|
|
1224
|
-
self.assertEqual({
|
|
1225
|
-
self.assertIsInstance(r2.superclass[
|
|
1227
|
+
self.assertEqual({Xsd_QName("oldap:Thing"), Xsd_QName("test:testMyRes")}, set(r2.superclass))
|
|
1228
|
+
self.assertIsInstance(r2.superclass[Xsd_QName('test:testMyRes')], ResourceClass)
|
|
1226
1229
|
self.assertFalse(r2[ResClassAttribute.CLOSED])
|
|
1227
1230
|
|
|
1228
|
-
prop1 = r2[
|
|
1231
|
+
prop1 = r2[Xsd_QName('test:test')].prop
|
|
1229
1232
|
self.assertIsNone(prop1.internal)
|
|
1230
|
-
self.assertEqual(prop1.property_class_iri,
|
|
1233
|
+
self.assertEqual(prop1.property_class_iri, Xsd_QName('test:test'))
|
|
1231
1234
|
self.assertEqual(prop1.name, LangString("Test"))
|
|
1232
1235
|
self.assertEqual(prop1.description, LangString("Property shape for testing purposes"))
|
|
1233
1236
|
self.assertEqual(prop1.datatype, XsdDatatypes.string)
|
|
1234
1237
|
self.assertEqual(prop1.type, OwlPropertyType.OwlDataProperty)
|
|
1235
|
-
self.assertEqual(r2[
|
|
1236
|
-
self.assertEqual(r2[
|
|
1238
|
+
self.assertEqual(r2[Xsd_QName('test:test')].minCount, Xsd_integer(1))
|
|
1239
|
+
self.assertEqual(r2[Xsd_QName('test:test')].order, Xsd_decimal(3))
|
|
1237
1240
|
|
|
1238
|
-
prop2 = r2[
|
|
1241
|
+
prop2 = r2[Xsd_QName('dcterms:creator')].prop
|
|
1239
1242
|
self.assertEqual(prop2.internal, Xsd_QName("test:testMyResMinimalC"))
|
|
1240
1243
|
self.assertEqual(prop2.toClass, Xsd_QName('test:Person'))
|
|
1241
|
-
self.assertEqual(r2[
|
|
1244
|
+
self.assertEqual(r2[Xsd_QName('dcterms:creator')].maxCount, Xsd_integer(1))
|
|
1242
1245
|
self.assertEqual(prop1.type, OwlPropertyType.OwlDataProperty)
|
|
1243
1246
|
|
|
1244
|
-
prop3 = r2[
|
|
1247
|
+
prop3 = r2[Xsd_QName('test:color')].prop
|
|
1245
1248
|
self.assertEqual(prop3.internal, Xsd_QName("test:testMyResMinimalC"))
|
|
1246
1249
|
self.assertEqual(prop3.inSet, RdfSet(Xsd_string('A'), Xsd_string('B'), Xsd_string('C'), Xsd_string('D')))
|
|
1247
1250
|
|
|
@@ -1308,38 +1311,39 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1308
1311
|
def test_updating(self):
|
|
1309
1312
|
r1 = ResourceClass.read(con=self._connection,
|
|
1310
1313
|
project=self._project,
|
|
1311
|
-
owl_class_iri=
|
|
1312
|
-
self.assertEqual(r1[
|
|
1313
|
-
self.assertEqual(r1[
|
|
1314
|
-
self.assertEqual(r1[
|
|
1315
|
-
self.assertEqual(r1[
|
|
1314
|
+
owl_class_iri=Xsd_QName("test:testMyRes"))
|
|
1315
|
+
self.assertEqual(r1[Xsd_QName('test:hasText')].maxCount, Xsd_integer(1))
|
|
1316
|
+
self.assertEqual(r1[Xsd_QName('test:hasText')].minCount, Xsd_integer(1))
|
|
1317
|
+
self.assertEqual(r1[Xsd_QName('test:hasText')].prop.languageIn, LanguageIn(Language.EN, Language.DE))
|
|
1318
|
+
self.assertEqual(r1[Xsd_QName('test:hasText')].prop.name, LangString(["A text@en", "Ein Text@de"]))
|
|
1316
1319
|
|
|
1317
1320
|
r1.label[Language.IT] = "La mia risorsa"
|
|
1318
1321
|
r1.closed = Xsd_boolean(False)
|
|
1319
|
-
r1[ResClassAttribute.SUPERCLASS] = {
|
|
1320
|
-
r1[
|
|
1321
|
-
r1[
|
|
1322
|
-
r1[
|
|
1323
|
-
r1[
|
|
1322
|
+
r1[ResClassAttribute.SUPERCLASS] = {Xsd_QName("oldap:Thing"), Xsd_QName('dcterms:TopGaga')}
|
|
1323
|
+
r1[Xsd_QName('test:hasText')].prop.name[Language.FR] = "Un Texte Français"
|
|
1324
|
+
r1[Xsd_QName('test:hasText')].maxCount = Xsd_integer(12) # TODO !!!!!!!!!!!!!!!!!!
|
|
1325
|
+
r1[Xsd_QName('test:hasText')].prop.languageIn = LanguageIn(Language.DE, Language.FR, Language.IT)
|
|
1326
|
+
r1[Xsd_QName('test:hasEnum')].prop.inSet = RdfSet(Xsd_string('L'), Xsd_string('a'), Xsd_string('b'))
|
|
1324
1327
|
|
|
1325
1328
|
r1.update()
|
|
1326
1329
|
|
|
1327
1330
|
r2 = ResourceClass.read(con=self._connection,
|
|
1328
1331
|
project=self._project,
|
|
1329
|
-
owl_class_iri=
|
|
1332
|
+
owl_class_iri=Xsd_QName("test:testMyRes"))
|
|
1330
1333
|
self.assertEqual(r2.label, LangString(["My Resource@en", "Meine Ressource@de", "Ma Resource@fr", "La mia risorsa@it"]))
|
|
1331
1334
|
self.assertFalse(r2.closed)
|
|
1332
|
-
self.assertEqual({
|
|
1333
|
-
self.assertIsNone(r2.superclass[
|
|
1334
|
-
self.assertEqual(r2[
|
|
1335
|
-
self.assertEqual(r2[
|
|
1336
|
-
self.assertEqual(r2[
|
|
1337
|
-
self.assertEqual(r2[
|
|
1335
|
+
self.assertEqual({Xsd_QName("oldap:Thing"), Xsd_QName('dcterms:TopGaga')}, set(r2.superclass))
|
|
1336
|
+
self.assertIsNone(r2.superclass[Xsd_QName('dcterms:TopGaga')])
|
|
1337
|
+
self.assertEqual(r2[Xsd_QName('test:hasText')].prop.name, LangString(["A text@en", "Ein Text@de", "Un Texte Français@fr"]))
|
|
1338
|
+
self.assertEqual(r2[Xsd_QName('test:hasText')].maxCount, Xsd_integer(12)) # TODO !!!!!!!!!!!!!!!!
|
|
1339
|
+
self.assertEqual(r2[Xsd_QName('test:hasText')].prop.languageIn, LanguageIn(Language.DE, Language.FR, Language.IT))
|
|
1340
|
+
self.assertEqual(r2[Xsd_QName('test:hasEnum')].prop.inSet, RdfSet(Xsd_string('L'), Xsd_string('a'), Xsd_string('b')))
|
|
1338
1341
|
|
|
1339
1342
|
def test_updating_sc_A(self):
|
|
1343
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
1340
1344
|
p1 = PropertyClass(con=self._connection,
|
|
1341
1345
|
project=self._project,
|
|
1342
|
-
property_class_iri=
|
|
1346
|
+
property_class_iri=Xsd_QName('test:p1'),
|
|
1343
1347
|
datatype=XsdDatatypes.string,
|
|
1344
1348
|
name=LangString(["P1"]))
|
|
1345
1349
|
hasproperties: list[HasProperty] = [
|
|
@@ -1347,8 +1351,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1347
1351
|
]
|
|
1348
1352
|
r1 = ResourceClass(con=self._connection,
|
|
1349
1353
|
project=self._project,
|
|
1350
|
-
owlclass_iri=
|
|
1351
|
-
superclass={"oldap:Thing", '
|
|
1354
|
+
owlclass_iri=Xsd_QName("test:Crazy"),
|
|
1355
|
+
superclass={"oldap:Thing", 'crm:E22_Man-Made_Object'},
|
|
1352
1356
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1353
1357
|
comment=LangString("For testing purposes@en"),
|
|
1354
1358
|
closed=Xsd_boolean(True),
|
|
@@ -1357,19 +1361,20 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1357
1361
|
del r1
|
|
1358
1362
|
r1 = ResourceClass.read(con=self._connection,
|
|
1359
1363
|
project=self._project,
|
|
1360
|
-
owl_class_iri=
|
|
1361
|
-
del r1.superclass[
|
|
1364
|
+
owl_class_iri=Xsd_QName('test:Crazy'))
|
|
1365
|
+
del r1.superclass[Xsd_QName('crm:E22_Man-Made_Object')]
|
|
1362
1366
|
r1.update()
|
|
1363
1367
|
del r1
|
|
1364
1368
|
r1 = ResourceClass.read(con=self._connection,
|
|
1365
1369
|
project=self._project,
|
|
1366
|
-
owl_class_iri=
|
|
1370
|
+
owl_class_iri=Xsd_QName('test:Crazy'))
|
|
1367
1371
|
self.assertEqual({"oldap:Thing"}, set(r1.superclass))
|
|
1368
1372
|
|
|
1369
1373
|
def test_updating_sc_B(self):
|
|
1374
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
1370
1375
|
p1 = PropertyClass(con=self._connection,
|
|
1371
1376
|
project=self._project,
|
|
1372
|
-
property_class_iri=
|
|
1377
|
+
property_class_iri=Xsd_QName('test:p2'),
|
|
1373
1378
|
datatype=XsdDatatypes.string,
|
|
1374
1379
|
name=LangString(["P2"]))
|
|
1375
1380
|
hasproperties: list[HasProperty] = [
|
|
@@ -1377,8 +1382,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1377
1382
|
]
|
|
1378
1383
|
r1 = ResourceClass(con=self._connection,
|
|
1379
1384
|
project=self._project,
|
|
1380
|
-
owlclass_iri=
|
|
1381
|
-
superclass={"test:testMyRes", '
|
|
1385
|
+
owlclass_iri=Xsd_QName("test:CrazyB"),
|
|
1386
|
+
superclass={"test:testMyRes", 'crm:E22_Man-Made_Object'},
|
|
1382
1387
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1383
1388
|
comment=LangString("For testing purposes@en"),
|
|
1384
1389
|
closed=Xsd_boolean(True),
|
|
@@ -1387,19 +1392,21 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1387
1392
|
del r1
|
|
1388
1393
|
r1 = ResourceClass.read(con=self._connection,
|
|
1389
1394
|
project=self._project,
|
|
1390
|
-
owl_class_iri=
|
|
1391
|
-
del r1.superclass[
|
|
1395
|
+
owl_class_iri=Xsd_QName('test:CrazyB'))
|
|
1396
|
+
del r1.superclass[Xsd_QName("test:testMyRes")]
|
|
1392
1397
|
r1.update()
|
|
1393
1398
|
del r1
|
|
1394
1399
|
r1 = ResourceClass.read(con=self._connection,
|
|
1395
1400
|
project=self._project,
|
|
1396
|
-
owl_class_iri=
|
|
1397
|
-
self.assertEqual({
|
|
1401
|
+
owl_class_iri=Xsd_QName('test:CrazyB'))
|
|
1402
|
+
self.assertEqual({Xsd_QName("oldap:Thing"), Xsd_QName('crm:E22_Man-Made_Object')}, set(r1.superclass))
|
|
1398
1403
|
|
|
1399
1404
|
def test_updating_sc_C(self):
|
|
1405
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
1406
|
+
self._context[Xsd_NCName('gaga')] = NamespaceIRI('http://gaga.com/ns/')
|
|
1400
1407
|
p1 = PropertyClass(con=self._connection,
|
|
1401
1408
|
project=self._project,
|
|
1402
|
-
property_class_iri=
|
|
1409
|
+
property_class_iri=Xsd_QName('test:p3'),
|
|
1403
1410
|
datatype=XsdDatatypes.string,
|
|
1404
1411
|
name=LangString(["P3"]))
|
|
1405
1412
|
hasproperties: list[HasProperty] = [
|
|
@@ -1407,8 +1414,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1407
1414
|
]
|
|
1408
1415
|
r1 = ResourceClass(con=self._connection,
|
|
1409
1416
|
project=self._project,
|
|
1410
|
-
owlclass_iri=
|
|
1411
|
-
superclass={"test:testMyRes", '
|
|
1417
|
+
owlclass_iri=Xsd_QName("test:CrazyC"),
|
|
1418
|
+
superclass={"test:testMyRes", 'crm:E22_Man-Made_Object', 'test:testMyResMinimal'},
|
|
1412
1419
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1413
1420
|
comment=LangString("For testing purposes@en"),
|
|
1414
1421
|
closed=Xsd_boolean(True),
|
|
@@ -1417,22 +1424,23 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1417
1424
|
del r1
|
|
1418
1425
|
r1 = ResourceClass.read(con=self._connection,
|
|
1419
1426
|
project=self._project,
|
|
1420
|
-
owl_class_iri=
|
|
1427
|
+
owl_class_iri=Xsd_QName('test:CrazyC'))
|
|
1421
1428
|
del r1.superclass['test:testMyResMinimal']
|
|
1422
|
-
r1.superclass[
|
|
1429
|
+
r1.superclass[Xsd_QName('gaga:DasWirdNichtGehen')] = None
|
|
1423
1430
|
r1.update()
|
|
1424
1431
|
r1 = ResourceClass.read(con=self._connection,
|
|
1425
1432
|
project=self._project,
|
|
1426
|
-
owl_class_iri=
|
|
1433
|
+
owl_class_iri=Xsd_QName('test:CrazyC'))
|
|
1427
1434
|
self.assertEqual({"oldap:Thing",
|
|
1428
1435
|
"test:testMyRes",
|
|
1429
|
-
'
|
|
1430
|
-
'
|
|
1436
|
+
'crm:E22_Man-Made_Object',
|
|
1437
|
+
'gaga:DasWirdNichtGehen'}, set(r1.superclass))
|
|
1431
1438
|
|
|
1432
1439
|
def test_updating_sc_D(self):
|
|
1440
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
1433
1441
|
p1 = PropertyClass(con=self._connection,
|
|
1434
1442
|
project=self._project,
|
|
1435
|
-
property_class_iri=
|
|
1443
|
+
property_class_iri=Xsd_QName('test:p4'),
|
|
1436
1444
|
datatype=XsdDatatypes.string,
|
|
1437
1445
|
name=LangString(["P4"]))
|
|
1438
1446
|
hasproperties: list[HasProperty] = [
|
|
@@ -1440,8 +1448,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1440
1448
|
]
|
|
1441
1449
|
r1 = ResourceClass(con=self._connection,
|
|
1442
1450
|
project=self._project,
|
|
1443
|
-
owlclass_iri=
|
|
1444
|
-
superclass={"test:testMyRes", '
|
|
1451
|
+
owlclass_iri=Xsd_QName("test:CrazyD"),
|
|
1452
|
+
superclass={"test:testMyRes", 'crm:E22_Man-Made_Object', 'test:testMyResMinimal'},
|
|
1445
1453
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1446
1454
|
comment=LangString("For testing purposes@en"),
|
|
1447
1455
|
closed=Xsd_boolean(True),
|
|
@@ -1452,13 +1460,14 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1452
1460
|
r1.update()
|
|
1453
1461
|
r1 = ResourceClass.read(con=self._connection,
|
|
1454
1462
|
project=self._project,
|
|
1455
|
-
owl_class_iri=
|
|
1463
|
+
owl_class_iri=Xsd_QName('test:CrazyD'))
|
|
1456
1464
|
self.assertIsNone(r1[ResClassAttribute.LABEL])
|
|
1457
1465
|
|
|
1458
1466
|
def test_updating_sc_E(self):
|
|
1467
|
+
self._context[Xsd_NCName('crm')] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
1459
1468
|
p1 = PropertyClass(con=self._connection,
|
|
1460
1469
|
project=self._project,
|
|
1461
|
-
property_class_iri=
|
|
1470
|
+
property_class_iri=Xsd_QName('test:p5'),
|
|
1462
1471
|
datatype=XsdDatatypes.string,
|
|
1463
1472
|
name=LangString(["P5"]))
|
|
1464
1473
|
hasproperties: list[HasProperty] = [
|
|
@@ -1466,8 +1475,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1466
1475
|
]
|
|
1467
1476
|
r1 = ResourceClass(con=self._connection,
|
|
1468
1477
|
project=self._project,
|
|
1469
|
-
owlclass_iri=
|
|
1470
|
-
superclass={"test:testMyRes", '
|
|
1478
|
+
owlclass_iri=Xsd_QName("test:CrazyE"),
|
|
1479
|
+
superclass={"test:testMyRes", 'crm:E22_Man-Made_Object', 'test:testMyResMinimal'},
|
|
1471
1480
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1472
1481
|
comment=LangString("For testing purposes@en"),
|
|
1473
1482
|
closed=Xsd_boolean(True),
|
|
@@ -1478,25 +1487,25 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1478
1487
|
r1.update()
|
|
1479
1488
|
r1 = ResourceClass.read(con=self._connection,
|
|
1480
1489
|
project=self._project,
|
|
1481
|
-
owl_class_iri=
|
|
1490
|
+
owl_class_iri=Xsd_QName('test:CrazyE'))
|
|
1482
1491
|
self.assertIsNone(r1[ResClassAttribute.LABEL])
|
|
1483
1492
|
|
|
1484
1493
|
def test_updating_sc_F(self):
|
|
1485
1494
|
r1 = ResourceClass(con=self._connection,
|
|
1486
1495
|
project=self._project,
|
|
1487
|
-
owlclass_iri=
|
|
1496
|
+
owlclass_iri=Xsd_QName("test:CrazyF"),
|
|
1488
1497
|
label=LangString(["LabelF english@en", "Label F french@fr"]),
|
|
1489
1498
|
comment=LangString("commentF english@en"))
|
|
1490
1499
|
r1.create()
|
|
1491
1500
|
r1 = ResourceClass.read(con=self._connection,
|
|
1492
1501
|
project=self._project,
|
|
1493
|
-
owl_class_iri=
|
|
1502
|
+
owl_class_iri=Xsd_QName('test:CrazyF'))
|
|
1494
1503
|
del r1.label[Language.EN]
|
|
1495
1504
|
r1.label.add("Label F italian@it")
|
|
1496
1505
|
r1.update()
|
|
1497
1506
|
r1 = ResourceClass.read(con=self._connection,
|
|
1498
1507
|
project=self._project,
|
|
1499
|
-
owl_class_iri=
|
|
1508
|
+
owl_class_iri=Xsd_QName('test:CrazyF'))
|
|
1500
1509
|
self.assertEqual(r1.label, LangString(["Label F french@fr", "Label F italian@it"]))
|
|
1501
1510
|
#
|
|
1502
1511
|
# Testing if also OWL ontology has been updated
|
|
@@ -1518,8 +1527,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1518
1527
|
def test_delete_props(self):
|
|
1519
1528
|
p1 = PropertyClass(con=self._connection,
|
|
1520
1529
|
project=self._project,
|
|
1521
|
-
property_class_iri=
|
|
1522
|
-
subPropertyOf=
|
|
1530
|
+
property_class_iri=Xsd_QName('test:propA'),
|
|
1531
|
+
subPropertyOf=Xsd_QName('test:comment'),
|
|
1523
1532
|
datatype=XsdDatatypes.langString,
|
|
1524
1533
|
name=LangString(["Test property@en", "Testprädikat@de"]),
|
|
1525
1534
|
description=LangString("A property for testing...@en"),
|
|
@@ -1528,27 +1537,27 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1528
1537
|
|
|
1529
1538
|
p2 = PropertyClass(con=self._connection,
|
|
1530
1539
|
project=self._project,
|
|
1531
|
-
property_class_iri=
|
|
1532
|
-
toClass=
|
|
1540
|
+
property_class_iri=Xsd_QName('test:propB'),
|
|
1541
|
+
toClass=Xsd_QName('test:testMyRes'),
|
|
1533
1542
|
name=LangString(["Excl. Test property@en", "Exkl. Testprädikat@de"]),
|
|
1534
1543
|
description=LangString("An exclusive property for testing...@en"))
|
|
1535
1544
|
|
|
1536
1545
|
p3 = PropertyClass(con=self._connection,
|
|
1537
1546
|
project=self._project,
|
|
1538
|
-
property_class_iri=
|
|
1547
|
+
property_class_iri=Xsd_QName('test:propC'),
|
|
1539
1548
|
datatype=XsdDatatypes.int,
|
|
1540
1549
|
inSet=RdfSet(Xsd_integer(10), Xsd_integer(20), Xsd_integer(30)))
|
|
1541
1550
|
|
|
1542
1551
|
hasproperties: list[HasProperty] = [
|
|
1543
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
1544
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
1552
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), order=1),
|
|
1553
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:test"), order=2),
|
|
1545
1554
|
HasProperty(con=self._connection, project=self._project, prop=p1, maxCount=Xsd_integer(1), minCount=Xsd_integer(1), order=3),
|
|
1546
1555
|
HasProperty(con=self._connection, project=self._project, prop=p2, minCount=Xsd_integer(1), order=4),
|
|
1547
1556
|
HasProperty(con=self._connection, project=self._project, prop=p3, order=5),
|
|
1548
1557
|
]
|
|
1549
1558
|
r1 = ResourceClass(con=self._connection,
|
|
1550
1559
|
project=self._project,
|
|
1551
|
-
owlclass_iri=
|
|
1560
|
+
owlclass_iri=Xsd_QName("test:TestResourceDelProps"),
|
|
1552
1561
|
superclass="test:testMyResMinimal",
|
|
1553
1562
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1554
1563
|
comment=LangString("For testing purposes@en"),
|
|
@@ -1559,15 +1568,15 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1559
1568
|
|
|
1560
1569
|
r2 = ResourceClass.read(con=self._connection,
|
|
1561
1570
|
project=self._project,
|
|
1562
|
-
owl_class_iri=
|
|
1563
|
-
del r2[
|
|
1564
|
-
del r2[
|
|
1565
|
-
del r2[
|
|
1571
|
+
owl_class_iri=Xsd_QName("test:TestResourceDelProps"), ignore_cache=True)
|
|
1572
|
+
del r2[Xsd_QName('test:propB')]
|
|
1573
|
+
del r2[Xsd_QName("test:test")] # OWL is not yet removed (rdfs:subClassOf is still there)
|
|
1574
|
+
del r2[Xsd_QName('test:propC')]
|
|
1566
1575
|
r2.update()
|
|
1567
1576
|
|
|
1568
1577
|
r3 = ResourceClass.read(con=self._connection,
|
|
1569
1578
|
project=self._project,
|
|
1570
|
-
owl_class_iri=
|
|
1579
|
+
owl_class_iri=Xsd_QName("test:TestResourceDelProps"), ignore_cache=True)
|
|
1571
1580
|
|
|
1572
1581
|
self.assertTrue(check_prop_empty(self._connection, self._context, Graph.SHACL, 'test:testMyResMinimal', 'test:propB'))
|
|
1573
1582
|
self.assertTrue(check_prop_empty(self._connection, self._context, Graph.ONTO, 'test:testMyResMinimal', 'test:propB'))
|
|
@@ -1582,8 +1591,8 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1582
1591
|
def test_delete(self):
|
|
1583
1592
|
p1 = PropertyClass(con=self._connection,
|
|
1584
1593
|
project=self._project,
|
|
1585
|
-
property_class_iri=
|
|
1586
|
-
subPropertyOf=
|
|
1594
|
+
property_class_iri=Xsd_QName('test:deleteA'),
|
|
1595
|
+
subPropertyOf=Xsd_QName('test:comment'),
|
|
1587
1596
|
datatype=XsdDatatypes.langString,
|
|
1588
1597
|
name=LangString(["Test property@en", "Testprädikat@de"]),
|
|
1589
1598
|
description=LangString("A property for testing...@en"),
|
|
@@ -1592,27 +1601,27 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1592
1601
|
|
|
1593
1602
|
p2 = PropertyClass(con=self._connection,
|
|
1594
1603
|
project=self._project,
|
|
1595
|
-
property_class_iri=
|
|
1604
|
+
property_class_iri=Xsd_QName('test:deleteB'),
|
|
1596
1605
|
toClass=Iri('test:testMyRes'),
|
|
1597
1606
|
name=LangString(["Excl. Test property@en", "Exkl. Testprädikat@de"]),
|
|
1598
1607
|
description=LangString("A property for testing...@en"))
|
|
1599
1608
|
|
|
1600
1609
|
p3 = PropertyClass(con=self._connection,
|
|
1601
1610
|
project=self._project,
|
|
1602
|
-
property_class_iri=
|
|
1611
|
+
property_class_iri=Xsd_QName('test:deleteC'),
|
|
1603
1612
|
datatype=XsdDatatypes.int,
|
|
1604
1613
|
inSet=RdfSet(Xsd_integer(10), Xsd_integer(20), Xsd_integer(30)))
|
|
1605
1614
|
|
|
1606
1615
|
hasproperties: list[HasProperty] = [
|
|
1607
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
1608
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
1616
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), order=1),
|
|
1617
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:test"), order=2),
|
|
1609
1618
|
HasProperty(con=self._connection, project=self._project, prop=p1, maxCount=Xsd_integer(1), minCount=Xsd_integer(1), order=3),
|
|
1610
1619
|
HasProperty(con=self._connection, project=self._project, prop=p2, minCount=Xsd_integer(1), order=4),
|
|
1611
1620
|
HasProperty(con=self._connection, project=self._project, prop=p3, order=5)
|
|
1612
1621
|
]
|
|
1613
1622
|
r1 = ResourceClass(con=self._connection,
|
|
1614
1623
|
project=self._project,
|
|
1615
|
-
owlclass_iri=
|
|
1624
|
+
owlclass_iri=Xsd_QName("test:TestResourceDelete"),
|
|
1616
1625
|
superclass="test:testMyResMinimal",
|
|
1617
1626
|
label=LangString(["DeleteResTest@en", "EffaçerResTeste@fr"]),
|
|
1618
1627
|
comment=LangString("For testing purposes@en"),
|
|
@@ -1623,20 +1632,21 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1623
1632
|
|
|
1624
1633
|
r2 = ResourceClass.read(con=self._connection,
|
|
1625
1634
|
project=self._project,
|
|
1626
|
-
owl_class_iri=
|
|
1635
|
+
owl_class_iri=Xsd_QName("test:TestResourceDelete"))
|
|
1627
1636
|
r2.delete()
|
|
1628
1637
|
|
|
1629
1638
|
self.assertTrue(check_res_empty(self._connection, self._context, Graph.SHACL, 'test:TestResourceDelete'))
|
|
1630
1639
|
self.assertTrue(check_res_empty(self._connection, self._context, Graph.ONTO, 'test:TestResourceDelete'))
|
|
1631
1640
|
superclass = ResourceClass.read(con=self._connection,
|
|
1632
1641
|
project=self._project,
|
|
1633
|
-
owl_class_iri=
|
|
1642
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimal"))
|
|
1634
1643
|
self.assertEqual(Iri("test:testMyResMinimal"), superclass.owl_class_iri)
|
|
1635
1644
|
|
|
1645
|
+
# TODO!! TEST FAILES BECAUSE OF OBJECTFACTORY NOT YET FIXED!!!
|
|
1636
1646
|
def test_in_use_case(self):
|
|
1637
1647
|
p1 = PropertyClass(con=self._connection,
|
|
1638
1648
|
project=self._project,
|
|
1639
|
-
property_class_iri=
|
|
1649
|
+
property_class_iri=Xsd_QName('test:prop_A'),
|
|
1640
1650
|
datatype=XsdDatatypes.string,
|
|
1641
1651
|
name=LangString(["Test property A@en", "Testprädikat A@de"]),
|
|
1642
1652
|
description=LangString("A property for testing...@en"))
|
|
@@ -1646,7 +1656,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1646
1656
|
]
|
|
1647
1657
|
r1 = ResourceClass(con=self._connection,
|
|
1648
1658
|
project=self._project,
|
|
1649
|
-
owlclass_iri=
|
|
1659
|
+
owlclass_iri=Xsd_QName("test:TestResourceInUse"),
|
|
1650
1660
|
superclass="test:testMyResMinimal",
|
|
1651
1661
|
label=LangString(["CreateResTest@en", "CréationResTeste@fr"]),
|
|
1652
1662
|
comment=LangString("For testing purposes@en"),
|
|
@@ -1655,7 +1665,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1655
1665
|
r1.create()
|
|
1656
1666
|
r1 = ResourceClass.read(con=self._connection,
|
|
1657
1667
|
project=self._project,
|
|
1658
|
-
owl_class_iri=
|
|
1668
|
+
owl_class_iri=Xsd_QName("test:TestResourceInUse"), ignore_cache=True)
|
|
1659
1669
|
|
|
1660
1670
|
factory = ResourceInstanceFactory(con=self._connection, project=self._project)
|
|
1661
1671
|
TestResourceInUse = factory.createObjectInstance('TestResourceInUse')
|
|
@@ -1679,22 +1689,18 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1679
1689
|
|
|
1680
1690
|
r1 = ResourceClass.read(con=self._connection,
|
|
1681
1691
|
project=self._project,
|
|
1682
|
-
owl_class_iri=
|
|
1692
|
+
owl_class_iri=Xsd_QName("test:TestResourceInUse"), ignore_cache=True)
|
|
1683
1693
|
r1.add_superclasses("dcterms:waseliwas")
|
|
1684
1694
|
with self.assertRaises(OldapErrorInUse):
|
|
1685
1695
|
r1.update()
|
|
1686
1696
|
|
|
1687
1697
|
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
1698
|
# @unittest.skip('Work in progress')
|
|
1694
1699
|
def test_write_trig(self):
|
|
1700
|
+
self._context[Xsd_NCName('andromeda')] = NamespaceIRI('http://andromeda.com/cluster1/')
|
|
1695
1701
|
project_id = PropertyClass(con=self._connection,
|
|
1696
1702
|
project=self._project,
|
|
1697
|
-
property_class_iri=
|
|
1703
|
+
property_class_iri=Xsd_QName('test:projectId'),
|
|
1698
1704
|
datatype=XsdDatatypes.langString,
|
|
1699
1705
|
name=LangString(["Project ID@en", "Projekt ID@de"]),
|
|
1700
1706
|
description=LangString(["Unique ID for project@en", "Eindeutige ID für Projekt@de"]),
|
|
@@ -1702,7 +1708,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1702
1708
|
uniqueLang=Xsd_boolean(True))
|
|
1703
1709
|
project_name = PropertyClass(con=self._connection,
|
|
1704
1710
|
project=self._project,
|
|
1705
|
-
property_class_iri=
|
|
1711
|
+
property_class_iri=Xsd_QName('test:projectName'),
|
|
1706
1712
|
datatype=XsdDatatypes.langString,
|
|
1707
1713
|
name=LangString(["Project name@en", "Projektname@de"]),
|
|
1708
1714
|
description=LangString(["A description of the project@en", "EineBeschreibung des Projekts@de"]),
|
|
@@ -1715,12 +1721,12 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1715
1721
|
]
|
|
1716
1722
|
superclass = ResourceClass.read(con=self._connection,
|
|
1717
1723
|
project=self._project,
|
|
1718
|
-
owl_class_iri=
|
|
1724
|
+
owl_class_iri=Xsd_QName("test:testMyResMinimal"))
|
|
1719
1725
|
|
|
1720
1726
|
r1 = ResourceClass(con=self._connection,
|
|
1721
1727
|
project=self._project,
|
|
1722
|
-
owlclass_iri=
|
|
1723
|
-
superclass={"test:testMyResMinimal",
|
|
1728
|
+
owlclass_iri=Xsd_QName("test:Project"),
|
|
1729
|
+
superclass={"test:testMyResMinimal", Xsd_QName('andromeda:Cepheid42')},
|
|
1724
1730
|
label=LangString(["Project@en", "Projekt@de"]),
|
|
1725
1731
|
comment=LangString(["Definiton of a project@en", "Definition eines Projektes@de"]),
|
|
1726
1732
|
closed=Xsd_boolean(True),
|
|
@@ -1730,7 +1736,7 @@ class TestResourceClass(unittest.TestCase):
|
|
|
1730
1736
|
r1.update()
|
|
1731
1737
|
r1.read(con=self._connection,
|
|
1732
1738
|
project=self._project,
|
|
1733
|
-
owl_class_iri=
|
|
1739
|
+
owl_class_iri=Xsd_QName("test:Project"), ignore_cache=True)
|
|
1734
1740
|
r1.write_as_trig("gaga.trig")
|
|
1735
1741
|
|
|
1736
1742
|
|