oldaplib 0.3.6__py3-none-any.whl → 0.3.8__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/model.py +1 -0
- oldaplib/src/objectfactory.py +112 -64
- oldaplib/src/version.py +1 -1
- oldaplib/src/xsd/xsd_datetimestamp.py +1 -1
- oldaplib/test/test_externalontologies.py +3 -2
- oldaplib/test/test_objectfactory.py +58 -1
- {oldaplib-0.3.6.dist-info → oldaplib-0.3.8.dist-info}/METADATA +1 -1
- {oldaplib-0.3.6.dist-info → oldaplib-0.3.8.dist-info}/RECORD +9 -9
- {oldaplib-0.3.6.dist-info → oldaplib-0.3.8.dist-info}/WHEEL +0 -0
oldaplib/src/model.py
CHANGED
|
@@ -8,6 +8,7 @@ from typing import Set, Dict, Any, Self
|
|
|
8
8
|
from oldaplib.src.connection import Connection
|
|
9
9
|
from oldaplib.src.enums.action import Action
|
|
10
10
|
from oldaplib.src.enums.attributeclass import AttributeClass
|
|
11
|
+
from oldaplib.src.enums.language import Language
|
|
11
12
|
from oldaplib.src.helpers.attributechange import AttributeChange
|
|
12
13
|
from oldaplib.src.helpers.context import Context
|
|
13
14
|
from oldaplib.src.helpers.numeric import Numeric
|
oldaplib/src/objectfactory.py
CHANGED
|
@@ -99,7 +99,7 @@ class ResourceInstance:
|
|
|
99
99
|
if iri and isinstance(iri, str):
|
|
100
100
|
iri = Iri(Xsd_QName(self.project.projectShortName, iri))
|
|
101
101
|
self._iri = Iri(iri, validate=True) if iri else Iri()
|
|
102
|
-
self._values = {}
|
|
102
|
+
self._values: dict[Xsd_QName, ValueType] = {}
|
|
103
103
|
self._graph = self.project.projectShortName
|
|
104
104
|
self._superclass_objs = {}
|
|
105
105
|
self._changeset = {}
|
|
@@ -170,11 +170,33 @@ class ResourceInstance:
|
|
|
170
170
|
|
|
171
171
|
for propname in self.properties.keys():
|
|
172
172
|
setattr(ResourceInstance, propname.fragment, property(
|
|
173
|
-
partial(ResourceInstance.__get_value,
|
|
174
|
-
partial(ResourceInstance.__set_value,
|
|
175
|
-
partial(ResourceInstance.__del_value,
|
|
173
|
+
partial(ResourceInstance.__get_value, attr=propname),
|
|
174
|
+
partial(ResourceInstance.__set_value, attr=propname),
|
|
175
|
+
partial(ResourceInstance.__del_value, attr=propname)))
|
|
176
176
|
self.clear_changeset()
|
|
177
177
|
|
|
178
|
+
def __setitem__(self, key: Xsd_QName, value: ValueType | Xsd | None):
|
|
179
|
+
if self._values.get(key):
|
|
180
|
+
self.__set_value(value, key)
|
|
181
|
+
else:
|
|
182
|
+
raise OldapErrorValue(f'{self.name}: Property {key} does not exist.')
|
|
183
|
+
|
|
184
|
+
def __getitem__(self, key: Xsd_QName) -> ValueType | Xsd | None:
|
|
185
|
+
if self._values.get(key):
|
|
186
|
+
return self.__get_value(key)
|
|
187
|
+
else:
|
|
188
|
+
raise OldapErrorValue(f'{self.name}: Property {key} does not exist.')
|
|
189
|
+
|
|
190
|
+
def __delitem__(self, key: Xsd_QName):
|
|
191
|
+
if self._values.get(key):
|
|
192
|
+
self.__del_value(key)
|
|
193
|
+
|
|
194
|
+
def get(self, key: Xsd_QName) -> ValueType | Xsd | None:
|
|
195
|
+
if self._values.get(key):
|
|
196
|
+
return self._values[key]
|
|
197
|
+
else:
|
|
198
|
+
return None
|
|
199
|
+
|
|
178
200
|
def validate_value(self, values: ValueType, property: PropertyClass):
|
|
179
201
|
"""
|
|
180
202
|
Validates a set of values against a given property and its constraints. This function ensures
|
|
@@ -330,16 +352,19 @@ class ResourceInstance:
|
|
|
330
352
|
else:
|
|
331
353
|
return False, f'Actor does not have {permission} in project "{self.project.projectShortName}".'
|
|
332
354
|
|
|
333
|
-
def __get_value(self: Self,
|
|
334
|
-
attr = Xsd_QName(prefix, fragment, validate=False)
|
|
355
|
+
def __get_value(self: Self, attr: Xsd_QName | str) -> Xsd | ValueType | None:
|
|
356
|
+
#attr = Xsd_QName(prefix, fragment, validate=False)
|
|
357
|
+
if not isinstance(attr, Xsd_QName):
|
|
358
|
+
attr = Xsd_QName(attr)
|
|
335
359
|
tmp = self._values.get(attr, None)
|
|
336
360
|
if tmp is not None and str(attr) in {'oldap:createdBy', 'oldap:creationDate', 'oldap:lastModifiedBy', 'oldap:lastModificationDate'}:
|
|
337
361
|
return next(iter(tmp))
|
|
338
362
|
return tmp
|
|
339
363
|
|
|
340
|
-
def __set_value(self: Self, value: ValueType | Xsd | None,
|
|
341
|
-
|
|
342
|
-
|
|
364
|
+
def __set_value(self: Self, value: ValueType | Xsd | None, attr: Xsd_QName | str) -> None:
|
|
365
|
+
if not isinstance(attr, Xsd_QName):
|
|
366
|
+
attr = Xsd_QName(attr)
|
|
367
|
+
hasprop = self.properties.get(attr)
|
|
343
368
|
|
|
344
369
|
#
|
|
345
370
|
# Validate
|
|
@@ -347,58 +372,58 @@ class ResourceInstance:
|
|
|
347
372
|
if hasprop.get(HasPropertyAttr.MIN_COUNT): # testing for MIN_COUNT conformance
|
|
348
373
|
if hasprop[HasPropertyAttr.MIN_COUNT] > 0 and not value:
|
|
349
374
|
raise OldapErrorValue(
|
|
350
|
-
f'{self.name}: Property {
|
|
375
|
+
f'{self.name}: Property {attr} with MIN_COUNT={hasprop[HasPropertyAttr.MIN_COUNT]} is missing')
|
|
351
376
|
elif isinstance(value, (list, tuple, set, ObservableSet)) and len(value) < hasprop[HasPropertyAttr.MIN_COUNT]:
|
|
352
377
|
raise OldapErrorValue(
|
|
353
|
-
f'{self.name}: Property {
|
|
378
|
+
f'{self.name}: Property {attr} with MIN_COUNT={hasprop[HasPropertyAttr.MIN_COUNT]} has not enough values')
|
|
354
379
|
if hasprop.get(HasPropertyAttr.MAX_COUNT): # testing for MAX_COUNT conformance
|
|
355
380
|
if isinstance(value, (list, tuple, set, ObservableSet)) and len(value) > hasprop[HasPropertyAttr.MAX_COUNT]:
|
|
356
381
|
raise OldapErrorValue(
|
|
357
|
-
f'{self.name}: Property {
|
|
382
|
+
f'{self.name}: Property {attr} with MAX_COUNT={hasprop[HasPropertyAttr.MIN_COUNT]} has to many values (n={len(value)})')
|
|
358
383
|
if value:
|
|
359
384
|
if isinstance(value, LangString):
|
|
360
385
|
self.validate_value(value, hasprop.prop)
|
|
361
386
|
else:
|
|
362
387
|
if isinstance(value, (list, tuple, set, ObservableSet)):
|
|
363
|
-
for val in self._values[
|
|
388
|
+
for val in self._values[attr]:
|
|
364
389
|
self.validate_value(val, hasprop.prop)
|
|
365
390
|
else:
|
|
366
391
|
self.validate_value(value, hasprop.prop)
|
|
367
392
|
|
|
368
393
|
if not value:
|
|
369
|
-
self._changeset[
|
|
370
|
-
del self._values[
|
|
394
|
+
self._changeset[attr] = AttributeChange(self._values.get(attr), Action.DELETE)
|
|
395
|
+
del self._values[attr]
|
|
371
396
|
elif isinstance(value, (list, tuple, set, LangString)): # we may have multiple values...
|
|
372
|
-
if self._values.get(
|
|
373
|
-
self._changeset[
|
|
397
|
+
if self._values.get(attr):
|
|
398
|
+
self._changeset[attr] = AttributeChange(self._values.get(attr), Action.REPLACE)
|
|
374
399
|
else:
|
|
375
|
-
self._changeset[
|
|
400
|
+
self._changeset[attr] = AttributeChange(None, Action.CREATE)
|
|
376
401
|
if hasprop.prop.datatype == XsdDatatypes.langString:
|
|
377
|
-
self._values[
|
|
402
|
+
self._values[attr] = LangString(value, notifier=self.notifier, notify_data=attr)
|
|
378
403
|
else:
|
|
379
|
-
self._values[
|
|
404
|
+
self._values[attr] = ObservableSet({
|
|
380
405
|
convert2datatype(x, hasprop.prop.datatype) for x in value
|
|
381
|
-
}, notifier=self.notifier, notify_data=
|
|
406
|
+
}, notifier=self.notifier, notify_data=attr)
|
|
382
407
|
else:
|
|
383
|
-
if self._values.get(
|
|
384
|
-
self._changeset[
|
|
408
|
+
if self._values.get(attr):
|
|
409
|
+
self._changeset[attr] = AttributeChange(self._values.get(attr), Action.REPLACE)
|
|
385
410
|
else:
|
|
386
|
-
self._changeset[
|
|
411
|
+
self._changeset[attr] = AttributeChange(None, Action.CREATE)
|
|
387
412
|
try:
|
|
388
|
-
self._values[
|
|
413
|
+
self._values[attr] = ObservableSet({convert2datatype(value, hasprop.prop.datatype)})
|
|
389
414
|
except TypeError:
|
|
390
|
-
self._values[
|
|
415
|
+
self._values[attr] = convert2datatype(value, hasprop.prop.datatype)
|
|
391
416
|
|
|
392
|
-
def __del_value(self: Self,
|
|
393
|
-
|
|
394
|
-
|
|
417
|
+
def __del_value(self: Self, attr: Xsd_QName | str) -> None:
|
|
418
|
+
if not isinstance(attr, Xsd_QName):
|
|
419
|
+
attr = Xsd_QName(attr)
|
|
420
|
+
hasprop = self.properties.get(attr)
|
|
395
421
|
|
|
396
422
|
if hasprop.get(HasPropertyAttr.MIN_COUNT): # testing for MIN_COUNT conformance
|
|
397
423
|
if hasprop[HasPropertyAttr.MIN_COUNT] > 0:
|
|
398
|
-
raise OldapErrorValue(f'{self.name}: Property {
|
|
424
|
+
raise OldapErrorValue(f'{self.name}: Property {attr} with MIN_COUNT={hasprop[HasPropertyAttr.MIN_COUNT]} cannot be deleted.')
|
|
399
425
|
|
|
400
|
-
self._changeset[
|
|
401
|
-
attr = Xsd_QName(prefix, fragment, validate=False)
|
|
426
|
+
self._changeset[attr] = AttributeChange(self._values.get(attr), Action.DELETE)
|
|
402
427
|
del self._values[attr]
|
|
403
428
|
|
|
404
429
|
@property
|
|
@@ -507,26 +532,19 @@ class ResourceInstance:
|
|
|
507
532
|
context = Context(name=con.context_name)
|
|
508
533
|
sparql = context.sparql_context
|
|
509
534
|
sparql += f'''
|
|
510
|
-
SELECT ?predicate ?value
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
GRAPH oldap:admin {{
|
|
524
|
-
?user oldap:hasPermissions ?permset .
|
|
525
|
-
?permset oldap:givesPermission ?DataPermission .
|
|
526
|
-
?DataPermission oldap:permissionValue ?permval .
|
|
527
|
-
}}
|
|
528
|
-
FILTER(?permval >= {DataPermission.DATA_VIEW.numeric.toRdf})
|
|
529
|
-
}}'''
|
|
535
|
+
SELECT ?predicate ?value
|
|
536
|
+
WHERE {{
|
|
537
|
+
GRAPH {graph}:data {{
|
|
538
|
+
{iri.toRdf} ?predicate ?value .
|
|
539
|
+
{iri.toRdf} oldap:grantsPermission ?permset .
|
|
540
|
+
}}
|
|
541
|
+
GRAPH oldap:admin {{
|
|
542
|
+
{con.userIri.toRdf} oldap:hasPermissions ?permset .
|
|
543
|
+
?permset oldap:givesPermission ?DataPermission .
|
|
544
|
+
?DataPermission oldap:permissionValue ?permval .
|
|
545
|
+
}}
|
|
546
|
+
FILTER(?permval >= {DataPermission.DATA_VIEW.numeric.toRdf})
|
|
547
|
+
}}'''
|
|
530
548
|
jsonres = con.query(sparql)
|
|
531
549
|
res = QueryProcessor(context, jsonres)
|
|
532
550
|
objtype = None
|
|
@@ -791,6 +809,47 @@ class ResourceInstanceFactory:
|
|
|
791
809
|
'properties': resclass.properties,
|
|
792
810
|
'superclass': resclass.superclass})
|
|
793
811
|
|
|
812
|
+
@staticmethod
|
|
813
|
+
def read_data(con: IConnection, projectShortName: Xsd_NCName | str, iri: Iri | str) -> dict[Xsd_QName, Any]:
|
|
814
|
+
if not isinstance(iri, Iri):
|
|
815
|
+
iri = Iri(iri, validate=True)
|
|
816
|
+
if not isinstance(projectShortName, Xsd_NCName):
|
|
817
|
+
graph = Xsd_NCName(projectShortName)
|
|
818
|
+
else:
|
|
819
|
+
graph = projectShortName
|
|
820
|
+
|
|
821
|
+
context = Context(name=con.context_name)
|
|
822
|
+
sparql = context.sparql_context
|
|
823
|
+
sparql += f'''
|
|
824
|
+
SELECT ?predicate ?value
|
|
825
|
+
WHERE {{
|
|
826
|
+
GRAPH {graph}:data {{
|
|
827
|
+
{iri.toRdf} ?predicate ?value .
|
|
828
|
+
{iri.toRdf} oldap:grantsPermission ?permset .
|
|
829
|
+
}}
|
|
830
|
+
GRAPH oldap:admin {{
|
|
831
|
+
{con.userIri.toRdf} oldap:hasPermissions ?permset .
|
|
832
|
+
?permset oldap:givesPermission ?DataPermission .
|
|
833
|
+
?DataPermission oldap:permissionValue ?permval .
|
|
834
|
+
}}
|
|
835
|
+
FILTER(?permval >= {DataPermission.DATA_VIEW.numeric.toRdf})
|
|
836
|
+
}}
|
|
837
|
+
'''
|
|
838
|
+
jsonres = con.query(sparql)
|
|
839
|
+
res = QueryProcessor(context, jsonres)
|
|
840
|
+
data = {}
|
|
841
|
+
for r in res:
|
|
842
|
+
if r['predicate'].is_qname:
|
|
843
|
+
if not data.get(r['predicate'].as_qname):
|
|
844
|
+
data[r['predicate'].as_qname] = []
|
|
845
|
+
data[str(r['predicate'].as_qname)].append(str(r['value']))
|
|
846
|
+
else:
|
|
847
|
+
raise OldapErrorInconsistency(f"Expected QName as predicate, got {r['predicate']}")
|
|
848
|
+
if not data.get('rdf:type'):
|
|
849
|
+
raise OldapErrorNotFound(f'Resource with iri <{iri}> not found.')
|
|
850
|
+
return data
|
|
851
|
+
|
|
852
|
+
|
|
794
853
|
def read(self, iri: Iri | str) -> ResourceInstance:
|
|
795
854
|
if not isinstance(iri, Iri):
|
|
796
855
|
iri = Iri(iri, validate=True)
|
|
@@ -799,11 +858,6 @@ class ResourceInstanceFactory:
|
|
|
799
858
|
sparql = context.sparql_context
|
|
800
859
|
sparql += f'''
|
|
801
860
|
SELECT ?predicate ?value
|
|
802
|
-
FROM oldap:onto
|
|
803
|
-
FROM shared:onto
|
|
804
|
-
FROM {graph}:onto
|
|
805
|
-
FROM NAMED oldap:admin
|
|
806
|
-
FROM NAMED {graph}:data
|
|
807
861
|
WHERE {{
|
|
808
862
|
BIND({iri.toRdf} as ?iri)
|
|
809
863
|
GRAPH {graph}:data {{
|
|
@@ -856,11 +910,6 @@ class ResourceInstanceFactory:
|
|
|
856
910
|
else:
|
|
857
911
|
sparql += "SELECT DISTINCT ?s ?t ?p ?o"
|
|
858
912
|
sparql += f'''
|
|
859
|
-
FROM oldap:onto
|
|
860
|
-
FROM shared:onto
|
|
861
|
-
FROM {graph}:onto
|
|
862
|
-
FROM NAMED oldap:admin
|
|
863
|
-
FROM NAMED {graph}:data
|
|
864
913
|
WHERE {{
|
|
865
914
|
GRAPH {graph}:data {{
|
|
866
915
|
?s ?p ?o .
|
|
@@ -870,9 +919,8 @@ class ResourceInstanceFactory:
|
|
|
870
919
|
FILTER(isLiteral(?o) &&
|
|
871
920
|
(datatype(?o) = xsd:string || datatype(?o) = rdf:langString || lang(?o) != ""))
|
|
872
921
|
FILTER(CONTAINS(LCASE(STR(?o)), "{s}")) # case-insensitive substring match
|
|
873
|
-
BIND({self._con.userIri.toRdf} as ?user)
|
|
874
922
|
GRAPH oldap:admin {{
|
|
875
|
-
|
|
923
|
+
{self._con.userIri.toRdf} oldap:hasPermissions ?permset .
|
|
876
924
|
?permset oldap:givesPermission ?DataPermission .
|
|
877
925
|
?DataPermission oldap:permissionValue ?permval .
|
|
878
926
|
}}
|
oldaplib/src/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.8"
|
|
@@ -54,7 +54,7 @@ class Xsd_dateTimeStamp(Xsd):
|
|
|
54
54
|
Constructor string representation of the Xsd_dateTimeStamp instance as ISO datetimestamp
|
|
55
55
|
:return: Constructor string
|
|
56
56
|
"""
|
|
57
|
-
return f'
|
|
57
|
+
return f'Xsd_dateTimeStamp("{self.__value.isoformat()}")'
|
|
58
58
|
|
|
59
59
|
def __eq__(self, other: Self | datetime | str | None) -> bool:
|
|
60
60
|
"""
|
|
@@ -105,7 +105,8 @@ class TestexternalOntologies(unittest.TestCase):
|
|
|
105
105
|
|
|
106
106
|
del eo1
|
|
107
107
|
eo1 = ExternalOntology.read(con=self._connection, projectShortName="testext", prefix="gagaB", ignore_cache=True)
|
|
108
|
-
|
|
108
|
+
with self.assertRaises(OldapErrorImmutable):
|
|
109
|
+
eo1.prefix = "gugus"
|
|
109
110
|
eo1.comment = LangString("Gugus comment@en", "Gugus Kommentar@de")
|
|
110
111
|
del eo1.label[Language.DE]
|
|
111
112
|
eo1.label[Language.FR] = "GAGA B ontologie"
|
|
@@ -113,7 +114,7 @@ class TestexternalOntologies(unittest.TestCase):
|
|
|
113
114
|
|
|
114
115
|
del eo1
|
|
115
116
|
eo1 = ExternalOntology.read(con=self._connection, projectShortName="testext", prefix="gagaB", ignore_cache=True)
|
|
116
|
-
self.assertEqual(eo1.prefix, "
|
|
117
|
+
self.assertEqual(eo1.prefix, "gagaB")
|
|
117
118
|
self.assertEqual(eo1.label, LangString("GAGA B ontology@en", "GAGA B ontologie@fr"))
|
|
118
119
|
self.assertEqual(eo1.comment, LangString("Gugus comment@en", "Gugus Kommentar@de"))
|
|
119
120
|
self.assertEqual(eo1.namespaceIri, NamespaceIRI("http://gaga.org/ns/gagaB/"))
|
|
@@ -350,6 +350,19 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
350
350
|
mycat.create()
|
|
351
351
|
|
|
352
352
|
def test_read_A(self):
|
|
353
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
354
|
+
Book = factory.createObjectInstance('Book')
|
|
355
|
+
b = Book(title="The Life and Times of Scrooge",
|
|
356
|
+
author="test:TuomasHolopainen",
|
|
357
|
+
pubDate="2001-01-01",
|
|
358
|
+
grantsPermission=Iri('oldap:GenericView'))
|
|
359
|
+
b.create()
|
|
360
|
+
data = ResourceInstanceFactory.read_data(con=self._connection, iri=b.iri, projectShortName='test')
|
|
361
|
+
self.assertEqual(data['rdf:type'], ['test:Book'])
|
|
362
|
+
self.assertEqual(data['test:title'], ['The Life and Times of Scrooge'])
|
|
363
|
+
self.assertEqual(data['test:author'], ['test:TuomasHolopainen'])
|
|
364
|
+
|
|
365
|
+
def test_read_B(self):
|
|
353
366
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
354
367
|
Book = factory.createObjectInstance('Book')
|
|
355
368
|
b = Book(title="The Life and Times of Scrooge",
|
|
@@ -366,6 +379,24 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
366
379
|
self.assertEqual(jsonobj['test:pubDate'], ['2001-01-01'])
|
|
367
380
|
self.assertEqual(jsonobj['test:title'], ['The Life and Times of Scrooge'])
|
|
368
381
|
|
|
382
|
+
def test_read_C(self):
|
|
383
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
384
|
+
Book = factory.createObjectInstance('Book')
|
|
385
|
+
b = Book(title="The Life and Times of Scrooge",
|
|
386
|
+
author="test:TuomasHolopainen",
|
|
387
|
+
pubDate="2001-01-01",
|
|
388
|
+
grantsPermission=Iri('oldap:GenericView'))
|
|
389
|
+
b.create()
|
|
390
|
+
bb = Book.read(con=self._connection, iri=b.iri)
|
|
391
|
+
self.assertEqual(bb.name, "Book")
|
|
392
|
+
self.assertEqual(bb.title, {Xsd_string("The Life and Times of Scrooge")})
|
|
393
|
+
self.assertEqual(bb.author, {Iri("test:TuomasHolopainen")})
|
|
394
|
+
jsonobj = bb.toJsonObject()
|
|
395
|
+
self.assertEqual(jsonobj['test:author'], ['test:TuomasHolopainen'])
|
|
396
|
+
self.assertEqual(jsonobj['test:pubDate'], ['2001-01-01'])
|
|
397
|
+
self.assertEqual(jsonobj['test:title'], ['The Life and Times of Scrooge'])
|
|
398
|
+
|
|
399
|
+
|
|
369
400
|
def test_value_setter(self):
|
|
370
401
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
371
402
|
SetterTester = factory.createObjectInstance('SetterTester')
|
|
@@ -419,7 +450,7 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
419
450
|
self.assertEqual(obj2.decimalSetter, {Xsd_decimal(3.14159), Xsd_decimal(2.71828), Xsd_decimal(1.61803)})
|
|
420
451
|
self.assertFalse(obj2.integerSetter)
|
|
421
452
|
|
|
422
|
-
def
|
|
453
|
+
def test_value_modifier_A(self):
|
|
423
454
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
424
455
|
SetterTester = factory.createObjectInstance('SetterTester')
|
|
425
456
|
obj1 = SetterTester(stringSetter="This is a test string",
|
|
@@ -445,6 +476,32 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
445
476
|
self.assertEqual(obj1.integerSetter, {Xsd_int(20), Xsd_int(42)})
|
|
446
477
|
self.assertFalse(obj1.booleanSetter)
|
|
447
478
|
|
|
479
|
+
def test_value_modifier_B(self):
|
|
480
|
+
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
481
|
+
SetterTester = factory.createObjectInstance('SetterTester')
|
|
482
|
+
obj1 = SetterTester(stringSetter="This is a test string",
|
|
483
|
+
langStringSetter=LangString("C'est un teste@fr", "Dies ist eine Test-Zeichenkette@de"),
|
|
484
|
+
decimalSetter=Xsd_decimal(3.14),
|
|
485
|
+
integerSetter={-10, 20},
|
|
486
|
+
booleanSetter=True,
|
|
487
|
+
grantsPermission={Iri('oldap:GenericView'), Iri('oldap:GenericUpdate')})
|
|
488
|
+
obj1.create()
|
|
489
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
490
|
+
obj1[Xsd_QName('test:langStringSetter')][Language.FR] = "Qu'est-ce que c'est?"
|
|
491
|
+
obj1[Xsd_QName('test:integerSetter')].add(42)
|
|
492
|
+
obj1[Xsd_QName('test:integerSetter')].discard(-10)
|
|
493
|
+
obj1[Xsd_QName('test:booleanSetter')] = False
|
|
494
|
+
with self.assertRaises(OldapErrorValue):
|
|
495
|
+
obj1[Xsd_QName('test:stringSetter')].pop()
|
|
496
|
+
with self.assertRaises(OldapErrorValue):
|
|
497
|
+
del obj1[Xsd_QName('test:stringSetter')]
|
|
498
|
+
obj1.update()
|
|
499
|
+
obj1 = SetterTester.read(con=self._connection, iri=obj1.iri)
|
|
500
|
+
self.assertEqual(obj1.stringSetter, {"This is a test string"})
|
|
501
|
+
self.assertEqual(obj1.langStringSetter, LangString("Dies ist eine Test-Zeichenkette@de", "Qu'est-ce que c'est?@fr"))
|
|
502
|
+
self.assertEqual(obj1.integerSetter, {Xsd_int(20), Xsd_int(42)})
|
|
503
|
+
self.assertFalse(obj1.booleanSetter)
|
|
504
|
+
|
|
448
505
|
def test_value_maxcount_mincount(self):
|
|
449
506
|
factory = ResourceInstanceFactory(con=self._connection, project='test')
|
|
450
507
|
Person = factory.createObjectInstance('Person')
|
|
@@ -58,8 +58,8 @@ oldaplib/src/helpers/singletonmeta.py,sha256=bz_c5LFcRxxYirL9EDaFrWlc5WhAzR2uz9k
|
|
|
58
58
|
oldaplib/src/helpers/tools.py,sha256=sNbiOLucTGNFzZmiWwPLFOb80VTXQH0Zd9uCGubhzAk,12721
|
|
59
59
|
oldaplib/src/iconnection.py,sha256=XlOc2Kh4tK_UOHydLQwlWjUFLUze-Aq_vEZpf9KS1-s,3677
|
|
60
60
|
oldaplib/src/in_project.py,sha256=2KuhHPj8DNveFRBeImrRfxlCOYhBK-mcxXYUp6s--j8,10672
|
|
61
|
-
oldaplib/src/model.py,sha256=
|
|
62
|
-
oldaplib/src/objectfactory.py,sha256=
|
|
61
|
+
oldaplib/src/model.py,sha256=VACR3T6zJYFaE5J1PFFdP0OSwhbu4sahoLMWg6_L_rE,19267
|
|
62
|
+
oldaplib/src/objectfactory.py,sha256=JaIDrdOiprLxhJkgCnrUtcp9UdKcHrHPQBG8cBWqvrg,47027
|
|
63
63
|
oldaplib/src/oldaplist.py,sha256=sGAvEEJukRCjM70G0NFaR-L9YPleQTOtdWGExj3oYL8,42933
|
|
64
64
|
oldaplib/src/oldaplist_helpers.py,sha256=1Gur0nS1PCKb9iUtCKPUFDOYjw6vvAwYpe-G3DdxlEc,14213
|
|
65
65
|
oldaplib/src/oldaplistnode.py,sha256=NnC2juEGTtEkDO6OlB9PjSw_zTF-wSsRUgEk-6VV9DA,87344
|
|
@@ -70,7 +70,7 @@ oldaplib/src/propertyclass.py,sha256=pnaDsmyGKQnJaaOHXA0XyLcp4zn1b1vC9sLbjXls4lM
|
|
|
70
70
|
oldaplib/src/resourceclass.py,sha256=EIxyd7Z_w59wDxWLXCaLvhhvh5SjLEUWb8gqmZz8LLM,102046
|
|
71
71
|
oldaplib/src/user.py,sha256=Z4GXPRkaHXx3glUpPXQdFqYMxQPOuqayDwkTAE5RGjU,48820
|
|
72
72
|
oldaplib/src/userdataclass.py,sha256=FbZkcRt0pKbOeqsZ7HbpwoKE-XPWH2AqpHG1GcsrBPo,12364
|
|
73
|
-
oldaplib/src/version.py,sha256=
|
|
73
|
+
oldaplib/src/version.py,sha256=kd0YV9qLZ1Lpx7vbSzAMrAwjgdZJD_tInTnDqY6-nTY,21
|
|
74
74
|
oldaplib/src/xsd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
75
75
|
oldaplib/src/xsd/floatingpoint.py,sha256=rDReKqh0mXyc4F5wslgTUxbeGf3-PGERyughj5_62YI,8852
|
|
76
76
|
oldaplib/src/xsd/iri.py,sha256=w1Dr0z-REi7yPe3GPGnyzGrLVMvLY03kEeK-AmZ9sxw,8383
|
|
@@ -81,7 +81,7 @@ oldaplib/src/xsd/xsd_boolean.py,sha256=fzV_szKf2bq3E-p0mgARSOcuGWdH1T1LGVGkeD4E3
|
|
|
81
81
|
oldaplib/src/xsd/xsd_byte.py,sha256=LTE210keT1O78MnhNdAp4E1F-UhzNX4UYAnUVLopHxA,1017
|
|
82
82
|
oldaplib/src/xsd/xsd_date.py,sha256=FWiW-nBJ7TAp5tQdJfyPSMyu_JcOMyj9cnGKUWx7204,7469
|
|
83
83
|
oldaplib/src/xsd/xsd_datetime.py,sha256=xlnezNLhLk8oH62qeVG_cIqz2CLP07chc762oShq0PY,4566
|
|
84
|
-
oldaplib/src/xsd/xsd_datetimestamp.py,sha256=
|
|
84
|
+
oldaplib/src/xsd/xsd_datetimestamp.py,sha256=zoBaK2oWC34onKJXGh6dLJF68_ZWi3lKkZZFR4NIxv0,4002
|
|
85
85
|
oldaplib/src/xsd/xsd_decimal.py,sha256=f5r_lZXIgRhkQHNjaOEwf-5zBU-cdY2iA_qLuK4qYNs,1377
|
|
86
86
|
oldaplib/src/xsd/xsd_double.py,sha256=O34DokeImcQUhiqBjslvbCFosJtmyzEJlR6JERW0bHc,1423
|
|
87
87
|
oldaplib/src/xsd/xsd_duration.py,sha256=p-JL0dbrbq6nkyKu32yulLsSxS1PuhzkFqJ5yPgtV9M,3320
|
|
@@ -121,12 +121,12 @@ oldaplib/test/test_connection.py,sha256=y_t0v9jbo1BFsDlAjei2ckG0iVnLNc4ShlIRxe8G
|
|
|
121
121
|
oldaplib/test/test_context.py,sha256=atESRnIStobqkydjpVnmpHrcmf6QD9rgEwAZCsHlnXI,4757
|
|
122
122
|
oldaplib/test/test_datamodel.py,sha256=4s9ijonHaMLbL32Rz6JBflyxxG0TizPNbOpFLhp5FGg,59024
|
|
123
123
|
oldaplib/test/test_dtypes.py,sha256=ifXWUc6ExAKGukyM1ziku7Xd9eehg4J7HZy9B63-aPo,8601
|
|
124
|
-
oldaplib/test/test_externalontologies.py,sha256=
|
|
124
|
+
oldaplib/test/test_externalontologies.py,sha256=eExlaKUTsbm1dou_By4_T_qL0iuH5L96v3sjpTYYLWQ,7844
|
|
125
125
|
oldaplib/test/test_hasproperty.py,sha256=r991g8kBTfv1CGs9Hf0fli-AUp7Ob7rOHWYD74h4fjM,11572
|
|
126
126
|
oldaplib/test/test_in_project.py,sha256=DYT-guwRQ9crnfEt7cQZxoEMxThin7QeymNce3jaZx4,7779
|
|
127
127
|
oldaplib/test/test_langstring.py,sha256=37BeKiQzj63G-SyS_paK_SEG7ulRbGrE89Mz40UB_bE,15146
|
|
128
128
|
oldaplib/test/test_language_in.py,sha256=ELqHO-YIsZSCPF3E3rWde4J7rERL7En7sV_pzQ00zgs,8826
|
|
129
|
-
oldaplib/test/test_objectfactory.py,sha256=
|
|
129
|
+
oldaplib/test/test_objectfactory.py,sha256=IrU714mcpI2rterqauYA0XC_wKZdQSNrLAosCvrYo7M,34440
|
|
130
130
|
oldaplib/test/test_observable_dict.py,sha256=GxD0sM0nsVfVRBu92SFGkJ6--YXq4ibBWI4IpjZZzDU,1396
|
|
131
131
|
oldaplib/test/test_observable_set.py,sha256=JWZSoAsr8XIEBXPVgSVJjQQEEc8uSAme5IrFYLYVVXw,6313
|
|
132
132
|
oldaplib/test/test_oldaplist.py,sha256=9wo3tEOHt5bIuXyvSSyTzjhtdKrQHiiAA6EfVBuq4wI,20114
|
|
@@ -157,6 +157,6 @@ oldaplib/testdata/source_type.yaml,sha256=dSihKikw3O-IlGf6anj5KWMoBYLaweLVF1Zojm
|
|
|
157
157
|
oldaplib/testdata/test_move_left_of_toL.yaml,sha256=2m1OSQrQFlsCQxeJrjzBAO74LMprNDo_HuyrYGsOeXI,787
|
|
158
158
|
oldaplib/testdata/testlist.yaml,sha256=AT11nXEG81Sfyb-tr1gQV0H_dZBrOCcFuHf7YtL8P2g,1994
|
|
159
159
|
oldaplib/testit.http,sha256=qW7mnr6aNLXFG6lQdLgyhXILOPN6qc5iFVZclLyVvkY,303
|
|
160
|
-
oldaplib-0.3.
|
|
161
|
-
oldaplib-0.3.
|
|
162
|
-
oldaplib-0.3.
|
|
160
|
+
oldaplib-0.3.8.dist-info/METADATA,sha256=N4D0KOzlouWjyXz5ooC6ld_LhEblkrJNVfuSwwqPTMA,2854
|
|
161
|
+
oldaplib-0.3.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
162
|
+
oldaplib-0.3.8.dist-info/RECORD,,
|
|
File without changes
|