oldaplib 0.3.1__py3-none-any.whl → 0.3.3__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 +89 -87
- 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.3.dist-info}/METADATA +1 -1
- {oldaplib-0.3.1.dist-info → oldaplib-0.3.3.dist-info}/RECORD +30 -30
- {oldaplib-0.3.1.dist-info → oldaplib-0.3.3.dist-info}/WHEEL +0 -0
|
@@ -11,7 +11,6 @@ from oldaplib.src.helpers.langstring import LangString
|
|
|
11
11
|
from oldaplib.src.project import Project
|
|
12
12
|
from oldaplib.src.propertyclass import PropertyClass
|
|
13
13
|
from oldaplib.src.resourceclass import ResourceClass
|
|
14
|
-
from oldaplib.src.xsd.iri import Iri
|
|
15
14
|
from oldaplib.src.xsd.xsd_boolean import Xsd_boolean
|
|
16
15
|
from oldaplib.src.xsd.xsd_decimal import Xsd_decimal
|
|
17
16
|
from oldaplib.src.xsd.xsd_integer import Xsd_integer
|
|
@@ -38,6 +37,7 @@ class TestHasProperty(unittest.TestCase):
|
|
|
38
37
|
|
|
39
38
|
cls._context = Context(name="DEFAULT")
|
|
40
39
|
cls._context['test'] = NamespaceIRI("http://oldap.org/test#")
|
|
40
|
+
cls._context['crm'] = NamespaceIRI('http://www.cidoc-crm.org/cidoc-crm/')
|
|
41
41
|
cls._context.use('test', 'dcterms')
|
|
42
42
|
|
|
43
43
|
cls._connection = Connection(userId="rosenth",
|
|
@@ -64,17 +64,17 @@ class TestHasProperty(unittest.TestCase):
|
|
|
64
64
|
def test_creation(self):
|
|
65
65
|
p1 = PropertyClass(con=self._connection,
|
|
66
66
|
project=self._project,
|
|
67
|
-
property_class_iri=
|
|
67
|
+
property_class_iri=Xsd_QName('test:hasprop_test_A'),
|
|
68
68
|
datatype=XsdDatatypes.string,
|
|
69
69
|
name=LangString(["HasPropTest A"]))
|
|
70
70
|
hasproperties: list[HasProperty] = [
|
|
71
|
-
HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, maxCount=1, group=
|
|
72
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
71
|
+
HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, maxCount=1, group=Xsd_QName('test:group'), order=1),
|
|
72
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, group=Xsd_QName('test:group'), order=2),
|
|
73
73
|
]
|
|
74
74
|
r1 = ResourceClass(con=self._connection,
|
|
75
75
|
project=self._project,
|
|
76
|
-
owlclass_iri=
|
|
77
|
-
superclass={'oldap:Thing', '
|
|
76
|
+
owlclass_iri=Xsd_QName("test:HasPropertyTest_A"),
|
|
77
|
+
superclass={'oldap:Thing', 'crm:E22_Man-Made_Object'},
|
|
78
78
|
label=LangString(["HAsProptestA@en", "PropeTesteA@fr"]),
|
|
79
79
|
comment=LangString("For testing purposes@en"),
|
|
80
80
|
closed=Xsd_boolean(True),
|
|
@@ -83,31 +83,31 @@ class TestHasProperty(unittest.TestCase):
|
|
|
83
83
|
|
|
84
84
|
r1 = ResourceClass.read(con=self._connection,
|
|
85
85
|
project=self._project,
|
|
86
|
-
owl_class_iri=
|
|
87
|
-
self.assertEqual(r1[
|
|
88
|
-
self.assertEqual(r1[
|
|
89
|
-
self.assertEqual(r1[
|
|
90
|
-
self.assertEqual(r1[
|
|
86
|
+
owl_class_iri=Xsd_QName("test:HasPropertyTest_A"))
|
|
87
|
+
self.assertEqual(r1[Xsd_QName('test:hasprop_test_A')].minCount, Xsd_integer(1))
|
|
88
|
+
self.assertEqual(r1[Xsd_QName('test:hasprop_test_A')].maxCount, Xsd_integer(1))
|
|
89
|
+
self.assertEqual(r1[Xsd_QName('test:hasprop_test_A')].order, Xsd_decimal(1))
|
|
90
|
+
self.assertEqual(r1[Xsd_QName('test:hasprop_test_A')].group, Xsd_QName('test:group'))
|
|
91
91
|
|
|
92
|
-
self.assertIsNone(r1[
|
|
93
|
-
self.assertEqual(r1[
|
|
94
|
-
self.assertEqual(r1[
|
|
95
|
-
self.assertEqual(r1[
|
|
92
|
+
self.assertIsNone(r1[Xsd_QName("test:comment")].minCount)
|
|
93
|
+
self.assertEqual(r1[Xsd_QName("test:comment")].maxCount, Xsd_integer(1))
|
|
94
|
+
self.assertEqual(r1[Xsd_QName("test:comment")].order, Xsd_decimal(2))
|
|
95
|
+
self.assertEqual(r1[Xsd_QName("test:comment")].group, Xsd_QName('test:group'))
|
|
96
96
|
|
|
97
97
|
def test_modification_replace(self):
|
|
98
98
|
p1 = PropertyClass(con=self._connection,
|
|
99
99
|
project=self._project,
|
|
100
|
-
property_class_iri=
|
|
100
|
+
property_class_iri=Xsd_QName('test:hasprop_test_B'),
|
|
101
101
|
datatype=XsdDatatypes.string,
|
|
102
102
|
name=LangString(["HasPropTest B"]))
|
|
103
103
|
hasproperties: list[HasProperty] = [
|
|
104
|
-
HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, maxCount=1, group=
|
|
105
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
104
|
+
HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, maxCount=1, group=Xsd_QName('test:group'), order=1),
|
|
105
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, group=Xsd_QName('test:group'), order=2),
|
|
106
106
|
]
|
|
107
107
|
r1 = ResourceClass(con=self._connection,
|
|
108
108
|
project=self._project,
|
|
109
|
-
owlclass_iri=
|
|
110
|
-
superclass={'oldap:Thing', '
|
|
109
|
+
owlclass_iri=Xsd_QName("test:HasPropertyTest_B"),
|
|
110
|
+
superclass={'oldap:Thing', 'crm:E22_Man-Made_Object'},
|
|
111
111
|
label=LangString(["HasProptestB@en", "PropeTesteB@fr"]),
|
|
112
112
|
comment=LangString("For testing purposes@en"),
|
|
113
113
|
closed=Xsd_boolean(True),
|
|
@@ -116,41 +116,41 @@ class TestHasProperty(unittest.TestCase):
|
|
|
116
116
|
|
|
117
117
|
r1 = ResourceClass.read(con=self._connection,
|
|
118
118
|
project=self._project,
|
|
119
|
-
owl_class_iri=
|
|
120
|
-
r1[
|
|
121
|
-
r1[
|
|
122
|
-
r1[
|
|
119
|
+
owl_class_iri=Xsd_QName("test:HasPropertyTest_B"))
|
|
120
|
+
r1[Xsd_QName('test:hasprop_test_B')].maxCount = Xsd_integer(2)
|
|
121
|
+
r1[Xsd_QName('test:hasprop_test_B')].order = Xsd_decimal(2)
|
|
122
|
+
r1[Xsd_QName('test:hasprop_test_B')].group = Xsd_QName('test:groupB')
|
|
123
123
|
|
|
124
|
-
r1[
|
|
125
|
-
r1[
|
|
126
|
-
r1[
|
|
124
|
+
r1[Xsd_QName('test:comment')].maxCount = Xsd_integer(2)
|
|
125
|
+
r1[Xsd_QName('test:comment')].order = Xsd_decimal(1)
|
|
126
|
+
r1[Xsd_QName('test:comment')].group = Xsd_QName('test:groupB')
|
|
127
127
|
|
|
128
128
|
r1.update()
|
|
129
129
|
r1 = ResourceClass.read(con=self._connection,
|
|
130
130
|
project=self._project,
|
|
131
|
-
owl_class_iri=
|
|
132
|
-
self.assertEqual(Xsd_integer(2), r1[
|
|
133
|
-
self.assertEqual(Xsd_decimal(2), r1[
|
|
134
|
-
self.assertEqual(
|
|
131
|
+
owl_class_iri=Xsd_QName("test:HasPropertyTest_B"))
|
|
132
|
+
self.assertEqual(Xsd_integer(2), r1[Xsd_QName('test:hasprop_test_B')].maxCount)
|
|
133
|
+
self.assertEqual(Xsd_decimal(2), r1[Xsd_QName('test:hasprop_test_B')].order)
|
|
134
|
+
self.assertEqual(Xsd_QName('test:groupB'), r1[Xsd_QName('test:hasprop_test_B')].group)
|
|
135
135
|
|
|
136
|
-
self.assertEqual(Xsd_integer(2), r1[
|
|
137
|
-
self.assertEqual(Xsd_decimal(1), r1[
|
|
138
|
-
self.assertEqual(
|
|
136
|
+
self.assertEqual(Xsd_integer(2), r1[Xsd_QName('test:comment')].maxCount)
|
|
137
|
+
self.assertEqual(Xsd_decimal(1), r1[Xsd_QName('test:comment')].order)
|
|
138
|
+
self.assertEqual(Xsd_QName('test:groupB'), r1[Xsd_QName('test:comment')].group)
|
|
139
139
|
|
|
140
140
|
def test_modification_add(self):
|
|
141
141
|
p1 = PropertyClass(con=self._connection,
|
|
142
142
|
project=self._project,
|
|
143
|
-
property_class_iri=
|
|
143
|
+
property_class_iri=Xsd_QName('test:hasprop_test_C'),
|
|
144
144
|
datatype=XsdDatatypes.string,
|
|
145
145
|
name=LangString(["HasPropTest C"]))
|
|
146
146
|
hasproperties: list[HasProperty] = [
|
|
147
147
|
HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, order=1),
|
|
148
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
148
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, group=Xsd_QName('test:group')),
|
|
149
149
|
]
|
|
150
150
|
r1 = ResourceClass(con=self._connection,
|
|
151
151
|
project=self._project,
|
|
152
|
-
owlclass_iri=
|
|
153
|
-
superclass={'oldap:Thing', '
|
|
152
|
+
owlclass_iri=Xsd_QName("test:HasPropertyTest_C"),
|
|
153
|
+
superclass={'oldap:Thing', 'crm:E22_Man-Made_Object'},
|
|
154
154
|
label=LangString(["HasProptestC@en", "PropeTesteC@fr"]),
|
|
155
155
|
comment=LangString("For testing purposes@en"),
|
|
156
156
|
closed=Xsd_boolean(True),
|
|
@@ -159,34 +159,34 @@ class TestHasProperty(unittest.TestCase):
|
|
|
159
159
|
|
|
160
160
|
r1 = ResourceClass.read(con=self._connection,
|
|
161
161
|
project=self._project,
|
|
162
|
-
owl_class_iri=
|
|
163
|
-
r1[
|
|
164
|
-
#r1[
|
|
165
|
-
#r1[
|
|
166
|
-
#r1[
|
|
162
|
+
owl_class_iri=Xsd_QName("test:HasPropertyTest_C"))
|
|
163
|
+
r1[Xsd_QName('test:hasprop_test_C')].maxCount = Xsd_integer(10)
|
|
164
|
+
#r1[Xsd_QName('test:hasprop_test_C')].group = Xsd_QName('test:group')
|
|
165
|
+
#r1[Xsd_QName("test:comment")].minCount = Xsd_integer(1)
|
|
166
|
+
#r1[Xsd_QName("test:comment")].order = Xsd_decimal(1)
|
|
167
167
|
r1.update()
|
|
168
168
|
r1 = ResourceClass.read(con=self._connection,
|
|
169
169
|
project=self._project,
|
|
170
|
-
owl_class_iri=
|
|
171
|
-
self.assertEqual(Xsd_integer(10), r1[
|
|
172
|
-
#self.assertEqual(
|
|
173
|
-
#self.assertEqual(Xsd_integer(1), r1[
|
|
174
|
-
#self.assertEqual(Xsd_decimal(1), r1[
|
|
170
|
+
owl_class_iri=Xsd_QName("test:HasPropertyTest_C"))
|
|
171
|
+
self.assertEqual(Xsd_integer(10), r1[Xsd_QName('test:hasprop_test_C')].maxCount)
|
|
172
|
+
#self.assertEqual(Xsd_QName('test:group'), r1[Xsd_QName('test:hasprop_test_C')].group)
|
|
173
|
+
#self.assertEqual(Xsd_integer(1), r1[Xsd_QName("test:comment")].minCount)
|
|
174
|
+
#self.assertEqual(Xsd_decimal(1), r1[Xsd_QName("test:comment")].order)
|
|
175
175
|
|
|
176
176
|
def test_modification_delete(self):
|
|
177
177
|
p1 = PropertyClass(con=self._connection,
|
|
178
178
|
project=self._project,
|
|
179
|
-
property_class_iri=
|
|
179
|
+
property_class_iri=Xsd_QName('test:hasprop_test_D'),
|
|
180
180
|
datatype=XsdDatatypes.string,
|
|
181
181
|
name=LangString(["HasPropTest D"]))
|
|
182
182
|
hasproperties: list[HasProperty] = [
|
|
183
|
-
HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, maxCount=1, group=
|
|
184
|
-
HasProperty(con=self._connection, project=self._project, prop=
|
|
183
|
+
HasProperty(con=self._connection, project=self._project, prop=p1, minCount=1, maxCount=1, group=Xsd_QName('test:group'), order=1),
|
|
184
|
+
HasProperty(con=self._connection, project=self._project, prop=Xsd_QName("test:comment"), maxCount=1, group=Xsd_QName('test:group'), order=2),
|
|
185
185
|
]
|
|
186
186
|
r1 = ResourceClass(con=self._connection,
|
|
187
187
|
project=self._project,
|
|
188
|
-
owlclass_iri=
|
|
189
|
-
superclass={'oldap:Thing', '
|
|
188
|
+
owlclass_iri=Xsd_QName("test:HasPropertyTest_D"),
|
|
189
|
+
superclass={'oldap:Thing', 'crm:E22_Man-Made_Object'},
|
|
190
190
|
label=LangString(["HasProptestC@en", "PropeTesteC@fr"]),
|
|
191
191
|
comment=LangString("For testing purposes@en"),
|
|
192
192
|
closed=Xsd_boolean(True),
|
|
@@ -195,22 +195,22 @@ class TestHasProperty(unittest.TestCase):
|
|
|
195
195
|
|
|
196
196
|
r1 = ResourceClass.read(con=self._connection,
|
|
197
197
|
project=self._project,
|
|
198
|
-
owl_class_iri=
|
|
199
|
-
del r1[
|
|
200
|
-
del r1[
|
|
201
|
-
del r1[
|
|
202
|
-
del r1[
|
|
203
|
-
del r1[
|
|
198
|
+
owl_class_iri=Xsd_QName("test:HasPropertyTest_D"))
|
|
199
|
+
del r1[Xsd_QName('test:hasprop_test_D')].maxCount
|
|
200
|
+
del r1[Xsd_QName('test:hasprop_test_D')].order
|
|
201
|
+
del r1[Xsd_QName('test:comment')].maxCount
|
|
202
|
+
del r1[Xsd_QName('test:comment')].group
|
|
203
|
+
del r1[Xsd_QName('test:comment')].order
|
|
204
204
|
r1.update()
|
|
205
205
|
|
|
206
206
|
r1 = ResourceClass.read(con=self._connection,
|
|
207
207
|
project=self._project,
|
|
208
|
-
owl_class_iri=
|
|
209
|
-
self.assertIsNone(r1[
|
|
210
|
-
self.assertIsNone(r1[
|
|
211
|
-
self.assertIsNone(r1[
|
|
212
|
-
self.assertIsNone(r1[
|
|
213
|
-
self.assertIsNone(r1[
|
|
208
|
+
owl_class_iri=Xsd_QName("test:HasPropertyTest_D"))
|
|
209
|
+
self.assertIsNone(r1[Xsd_QName('test:hasprop_test_D')].maxCount)
|
|
210
|
+
self.assertIsNone(r1[Xsd_QName('test:hasprop_test_D')].order)
|
|
211
|
+
self.assertIsNone(r1[Xsd_QName('test:comment')].maxCount)
|
|
212
|
+
self.assertIsNone(r1[Xsd_QName('test:comment')].group)
|
|
213
|
+
self.assertIsNone(r1[Xsd_QName('test:comment')].order)
|
|
214
214
|
|
|
215
215
|
|
|
216
216
|
|
|
@@ -106,7 +106,7 @@ class TestObjectFactory(unittest.TestCase):
|
|
|
106
106
|
sleep(1) # upload may take a while...
|
|
107
107
|
|
|
108
108
|
user = User.read(cls._connection, "rosenth")
|
|
109
|
-
user.hasPermissions.add(Iri('oldap:GenericUpdate'))
|
|
109
|
+
user.hasPermissions.add(Iri('oldap:GenericUpdate')) # TODO: SHOULD WORK WITH Xsd_QName
|
|
110
110
|
user.update()
|
|
111
111
|
|
|
112
112
|
ps = PermissionSet(con=cls._connection,
|
|
@@ -5,6 +5,9 @@ from enum import Enum
|
|
|
5
5
|
from oldaplib.src.helpers.observable_dict import ObservableDict
|
|
6
6
|
from oldaplib.src.helpers.serializer import serializer
|
|
7
7
|
from oldaplib.src.xsd.iri import Iri
|
|
8
|
+
from oldaplib.src.xsd.xsd_integer import Xsd_integer
|
|
9
|
+
from oldaplib.src.xsd.xsd_ncname import Xsd_NCName
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
class TestObservableDict(unittest.TestCase):
|
|
10
13
|
|
|
@@ -27,3 +30,10 @@ class TestObservableDict(unittest.TestCase):
|
|
|
27
30
|
obs2 = json.loads(jsonstr, object_hook=serializer.decoder_hook)
|
|
28
31
|
pass
|
|
29
32
|
self.assertEqual(obs2, {Iri('http://gaga.com/a'): 1, Iri('http://gaga.com/b'): 2, Iri('http://gaga.com/c'): 3, Iri('http://gaga.com/d'): 4})
|
|
33
|
+
|
|
34
|
+
def test_json2(self):
|
|
35
|
+
obs = ObservableDict()
|
|
36
|
+
jsonstr = json.dumps(obs, default=serializer.encoder_default)
|
|
37
|
+
print(jsonstr)
|
|
38
|
+
obs2 = json.loads(jsonstr, object_hook=serializer.decoder_hook)
|
|
39
|
+
print(obs2)
|
oldaplib/test/test_oldaplist.py
CHANGED
|
@@ -330,18 +330,18 @@ class TestOldapList(unittest.TestCase):
|
|
|
330
330
|
|
|
331
331
|
selection = PropertyClass(con=self._connection,
|
|
332
332
|
project=self._project,
|
|
333
|
-
property_class_iri=
|
|
333
|
+
property_class_iri=Xsd_QName(f'{dm_name}:selection'),
|
|
334
334
|
toClass=node_classIri,
|
|
335
335
|
name=LangString(["Selection@en", "Selektion@de"]))
|
|
336
336
|
|
|
337
337
|
resobj = ResourceClass(con=self._connection,
|
|
338
338
|
project=self._project,
|
|
339
|
-
owlclass_iri=
|
|
339
|
+
owlclass_iri=Xsd_QName(f'{dm_name}:Resobj'),
|
|
340
340
|
label=LangString(["Resobj@en", "Resobj@de"]),
|
|
341
341
|
hasproperties=[
|
|
342
342
|
HasProperty(con=self._connection, project=self._project, prop=selection, maxCount=Xsd_integer(1),
|
|
343
343
|
minCount=Xsd_integer(1), order=1)])
|
|
344
|
-
dm[
|
|
344
|
+
dm[Xsd_QName(f'{dm_name}:resobj')] = resobj
|
|
345
345
|
dm.update()
|
|
346
346
|
dm = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
347
347
|
|
|
@@ -373,22 +373,22 @@ class TestOldapList(unittest.TestCase):
|
|
|
373
373
|
iris = OldapList.search(con=self._connection,
|
|
374
374
|
project=self._project,
|
|
375
375
|
prefLabel=Xsd_string("Animals", "en"))
|
|
376
|
-
self.assertEqual(iris, [
|
|
376
|
+
self.assertEqual(iris, [Xsd_QName('test:animals')])
|
|
377
377
|
|
|
378
378
|
iris = OldapList.search(con=self._connection,
|
|
379
379
|
project=self._project,
|
|
380
380
|
prefLabel=Xsd_string("Animals"))
|
|
381
|
-
self.assertEqual(iris, [
|
|
381
|
+
self.assertEqual(iris, [Xsd_QName('test:animals')])
|
|
382
382
|
|
|
383
383
|
iris = OldapList.search(con=self._connection,
|
|
384
384
|
project=self._project,
|
|
385
385
|
prefLabel=Xsd_string("Pflanzen", "de"))
|
|
386
|
-
self.assertEqual(iris, [
|
|
386
|
+
self.assertEqual(iris, [Xsd_QName('test:plants')])
|
|
387
387
|
|
|
388
388
|
iris = OldapList.search(con=self._connection,
|
|
389
389
|
project=self._project,
|
|
390
390
|
prefLabel=Xsd_string("Tier"))
|
|
391
|
-
self.assertEqual(iris, [
|
|
391
|
+
self.assertEqual(iris, [Xsd_QName('test:animals')])
|
|
392
392
|
|
|
393
393
|
iris = OldapList.search(con=self._connection,
|
|
394
394
|
project=self._project,
|
|
@@ -404,8 +404,8 @@ class TestOldapList(unittest.TestCase):
|
|
|
404
404
|
iris = OldapList.search(con=self._connection,
|
|
405
405
|
project=self._project,
|
|
406
406
|
definition=Xsd_string("hierarchical"))
|
|
407
|
-
self.assertTrue(
|
|
408
|
-
self.assertTrue(
|
|
407
|
+
self.assertTrue(Xsd_QName('test:animals') in iris)
|
|
408
|
+
self.assertTrue(Xsd_QName('test:plants') in iris)
|
|
409
409
|
|
|
410
410
|
|
|
411
411
|
|
|
@@ -1553,7 +1553,7 @@ class TestOldapListNode(unittest.TestCase):
|
|
|
1553
1553
|
|
|
1554
1554
|
selection = PropertyClass(con=self._connection,
|
|
1555
1555
|
project=self._dmproject,
|
|
1556
|
-
property_class_iri=
|
|
1556
|
+
property_class_iri=Xsd_QName(f'{dm_name}:selection'),
|
|
1557
1557
|
toClass=node_classIri,
|
|
1558
1558
|
name=LangString(["Selection@en", "Selektion@de"]))
|
|
1559
1559
|
|
|
@@ -1562,12 +1562,12 @@ class TestOldapListNode(unittest.TestCase):
|
|
|
1562
1562
|
#
|
|
1563
1563
|
resobj = ResourceClass(con=self._connection,
|
|
1564
1564
|
project=self._dmproject,
|
|
1565
|
-
owlclass_iri=
|
|
1565
|
+
owlclass_iri=Xsd_QName(f'{dm_name}:Resobj'),
|
|
1566
1566
|
label=LangString(["Resobj@en", "Resobj@de"]),
|
|
1567
1567
|
hasproperties=[
|
|
1568
1568
|
HasProperty(con=self._connection, project=self._dmproject, prop=selection, maxCount=Xsd_integer(1),
|
|
1569
1569
|
minCount=Xsd_integer(1), order=1)])
|
|
1570
|
-
dm[
|
|
1570
|
+
dm[Xsd_QName(f'{dm_name}:resobj')] = resobj
|
|
1571
1571
|
dm.update()
|
|
1572
1572
|
dm = DataModel.read(self._connection, self._dmproject, ignore_cache=True)
|
|
1573
1573
|
|
|
@@ -1669,18 +1669,18 @@ class TestOldapListNode(unittest.TestCase):
|
|
|
1669
1669
|
#
|
|
1670
1670
|
selection = PropertyClass(con=self._connection,
|
|
1671
1671
|
project=self._project,
|
|
1672
|
-
property_class_iri=
|
|
1672
|
+
property_class_iri=Xsd_QName(f'{dm_name}:selection2'),
|
|
1673
1673
|
toClass=node_classIri,
|
|
1674
1674
|
name=LangString(["Selection2@en", "Selektion2@de"]))
|
|
1675
1675
|
|
|
1676
1676
|
resobj = ResourceClass(con=self._connection,
|
|
1677
1677
|
project=self._project,
|
|
1678
|
-
owlclass_iri=
|
|
1678
|
+
owlclass_iri=Xsd_QName(f'{dm_name}:Resobj2'),
|
|
1679
1679
|
label=LangString(["Resobj2@en", "Resobj2@de"]),
|
|
1680
1680
|
hasproperties=[
|
|
1681
1681
|
HasProperty(con=self._connection, project=self._project, prop=selection, maxCount=Xsd_integer(1),
|
|
1682
1682
|
minCount=Xsd_integer(1), order=1)])
|
|
1683
|
-
dm[
|
|
1683
|
+
dm[Xsd_QName(f'{dm_name}:Resobj2')] = resobj
|
|
1684
1684
|
dm.update()
|
|
1685
1685
|
dm = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
1686
1686
|
|
|
@@ -2750,61 +2750,61 @@ class TestOldapListNode(unittest.TestCase):
|
|
|
2750
2750
|
self.assertEqual(Xsd_integer(8), olBAB.rightIndex)
|
|
2751
2751
|
|
|
2752
2752
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, id="Node_BA", exactMatch=True)
|
|
2753
|
-
self.assertEqual([
|
|
2753
|
+
self.assertEqual([Xsd_QName("L-TestListY:Node_BA")], irilist)
|
|
2754
2754
|
|
|
2755
2755
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, id="Node_XX", exactMatch=True)
|
|
2756
2756
|
self.assertEqual([], irilist)
|
|
2757
2757
|
|
|
2758
2758
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, id="BA")
|
|
2759
|
-
self.assertTrue(
|
|
2760
|
-
self.assertTrue(
|
|
2761
|
-
self.assertTrue(
|
|
2759
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BA") in irilist)
|
|
2760
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAA") in irilist)
|
|
2761
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAB") in irilist)
|
|
2762
2762
|
|
|
2763
2763
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, prefLabel="BA@en")
|
|
2764
|
-
self.assertTrue(
|
|
2765
|
-
self.assertTrue(
|
|
2766
|
-
self.assertTrue(
|
|
2764
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BA") in irilist)
|
|
2765
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAA") in irilist)
|
|
2766
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAB") in irilist)
|
|
2767
2767
|
|
|
2768
2768
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, prefLabel="BA@zu")
|
|
2769
2769
|
self.assertEqual([], irilist)
|
|
2770
2770
|
|
|
2771
2771
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, prefLabel="Neud_BA@fr", exactMatch=True)
|
|
2772
|
-
self.assertEqual([
|
|
2772
|
+
self.assertEqual([Xsd_QName("L-TestListY:Node_BA")], irilist)
|
|
2773
2773
|
|
|
2774
2774
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, prefLabel="BA@en")
|
|
2775
|
-
self.assertTrue(
|
|
2776
|
-
self.assertTrue(
|
|
2777
|
-
self.assertTrue(
|
|
2775
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BA") in irilist)
|
|
2776
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAA") in irilist)
|
|
2777
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAB") in irilist)
|
|
2778
2778
|
|
|
2779
2779
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, prefLabel="XX")
|
|
2780
2780
|
self.assertEqual([], irilist)
|
|
2781
2781
|
|
|
2782
2782
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, prefLabel="Neud_BA", exactMatch=True)
|
|
2783
|
-
self.assertEqual([
|
|
2783
|
+
self.assertEqual([Xsd_QName("L-TestListY:Node_BA")], irilist)
|
|
2784
2784
|
|
|
2785
2785
|
##
|
|
2786
2786
|
|
|
2787
2787
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, definition="BA@en")
|
|
2788
|
-
self.assertTrue(
|
|
2789
|
-
self.assertTrue(
|
|
2790
|
-
self.assertTrue(
|
|
2788
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BA") in irilist)
|
|
2789
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAA") in irilist)
|
|
2790
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAB") in irilist)
|
|
2791
2791
|
|
|
2792
2792
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, definition="BA@zu")
|
|
2793
2793
|
self.assertEqual([], irilist)
|
|
2794
2794
|
|
|
2795
2795
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, definition="Eine Liste zum Testen BA@de", exactMatch=True)
|
|
2796
|
-
self.assertEqual([
|
|
2796
|
+
self.assertEqual([Xsd_QName("L-TestListY:Node_BA")], irilist)
|
|
2797
2797
|
|
|
2798
2798
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, definition="BA@en")
|
|
2799
|
-
self.assertTrue(
|
|
2800
|
-
self.assertTrue(
|
|
2801
|
-
self.assertTrue(
|
|
2799
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BA") in irilist)
|
|
2800
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAA") in irilist)
|
|
2801
|
+
self.assertTrue(Xsd_QName("L-TestListY:Node_BAB") in irilist)
|
|
2802
2802
|
|
|
2803
2803
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, definition="XX")
|
|
2804
2804
|
self.assertEqual([], irilist)
|
|
2805
2805
|
|
|
2806
2806
|
irilist = OldapListNode.search(con=self._connection, **oldaplist.info, definition="Eine Liste zum Testen BA", exactMatch=True)
|
|
2807
|
-
self.assertEqual([
|
|
2807
|
+
self.assertEqual([Xsd_QName("L-TestListY:Node_BA")], irilist)
|
|
2808
2808
|
|
|
2809
2809
|
def test_invalid_move_A(self):
|
|
2810
2810
|
oldaplist = OldapList(con=self._connection,
|
|
@@ -2996,7 +2996,7 @@ class TestOldapListNode(unittest.TestCase):
|
|
|
2996
2996
|
|
|
2997
2997
|
title = PropertyClass(con=self._connection,
|
|
2998
2998
|
project=project,
|
|
2999
|
-
property_class_iri=
|
|
2999
|
+
property_class_iri=Xsd_QName(f'{dm_name}:title'),
|
|
3000
3000
|
datatype=XsdDatatypes.langString,
|
|
3001
3001
|
name=LangString(["Title@en", "Titel@de"]),
|
|
3002
3002
|
description=LangString(["Title of book@en", "Titel des Buches@de"]),
|
|
@@ -3005,14 +3005,14 @@ class TestOldapListNode(unittest.TestCase):
|
|
|
3005
3005
|
|
|
3006
3006
|
category = PropertyClass(con=self._connection,
|
|
3007
3007
|
project=project,
|
|
3008
|
-
property_class_iri=
|
|
3008
|
+
property_class_iri=Xsd_QName(f'{dm_name}:category'),
|
|
3009
3009
|
toClass=oldaplist.node_classIri,
|
|
3010
3010
|
name=LangString(["Category@en", "Kategorie@de"]),
|
|
3011
3011
|
description=LangString(["Category@en", "Kategorie@de"]))
|
|
3012
3012
|
|
|
3013
3013
|
categoryitem = ResourceClass(con=self._connection,
|
|
3014
3014
|
project=project,
|
|
3015
|
-
owlclass_iri=
|
|
3015
|
+
owlclass_iri=Xsd_QName(f'{dm_name}:CategoryItem'),
|
|
3016
3016
|
label=LangString(["CategoryItem@en", "CategoryItem@de"]),
|
|
3017
3017
|
comment=LangString("Something with categories@en"),
|
|
3018
3018
|
closed=Xsd_boolean(True),
|
|
@@ -3025,7 +3025,7 @@ class TestOldapListNode(unittest.TestCase):
|
|
|
3025
3025
|
#dm.create()
|
|
3026
3026
|
|
|
3027
3027
|
dm = DataModel.read(con=self._connection, project=project)
|
|
3028
|
-
dm[
|
|
3028
|
+
dm[Xsd_QName(f'{dm_name}:CategoryItem')] = categoryitem
|
|
3029
3029
|
dm.update()
|
|
3030
3030
|
|
|
3031
3031
|
factory = ResourceInstanceFactory(con=self._connection, project=project)
|
|
@@ -202,7 +202,7 @@ class TestPermissionSet(unittest.TestCase):
|
|
|
202
202
|
self.assertFalse(ps.definedByProject is ps2.definedByProject)
|
|
203
203
|
|
|
204
204
|
def test_read_permission_with_iri(self):
|
|
205
|
-
ps = PermissionSet.read(con=self._connection,
|
|
205
|
+
ps = PermissionSet.read(con=self._connection, qname=Xsd_QName('hyha:HyperHamletMember'), ignore_cache=True)
|
|
206
206
|
self.assertEqual(ps.givesPermission, DataPermission.DATA_UPDATE) # add assertion here
|
|
207
207
|
self.assertEqual(ps.label, LangString("HyHaUpdate@en", "HyHaUpdate@de", "HyHaUpdate@fr", "HyHaUpdate@it"))
|
|
208
208
|
self.assertEqual(ps.definedByProject, Iri('oldap:HyperHamlet'))
|
|
@@ -309,26 +309,26 @@ class TestPermissionSet(unittest.TestCase):
|
|
|
309
309
|
def test_search_permission_sets(self):
|
|
310
310
|
iris = PermissionSet.search(self._connection, label="GenericView")
|
|
311
311
|
self.assertEqual(len(iris), 1)
|
|
312
|
-
self.assertTrue(
|
|
312
|
+
self.assertTrue(Xsd_QName('oldap:GenericView') in iris)
|
|
313
313
|
|
|
314
314
|
iris = PermissionSet.search(self._connection, label=Xsd_string("GenericView@de"))
|
|
315
315
|
self.assertEqual(len(iris), 1)
|
|
316
|
-
self.assertTrue(
|
|
316
|
+
self.assertTrue(Xsd_QName('oldap:GenericView') in iris)
|
|
317
317
|
|
|
318
318
|
iris = PermissionSet.search(self._connection, definedByProject=Iri("oldap:HyperHamlet"))
|
|
319
319
|
self.assertEqual(len(iris), 1)
|
|
320
|
-
self.assertEqual(
|
|
320
|
+
self.assertEqual(Xsd_QName('hyha:HyperHamletMember'), iris[0])
|
|
321
321
|
|
|
322
322
|
iris = PermissionSet.search(self._connection, givesPermission=DataPermission.DATA_RESTRICTED)
|
|
323
323
|
#self.assertEqual(len(iris), 1)
|
|
324
|
-
self.assertEqual([
|
|
324
|
+
self.assertEqual([Xsd_QName('oldap:GenericRestricted')], iris)
|
|
325
325
|
|
|
326
326
|
iris = PermissionSet.search(self._connection)
|
|
327
|
-
self.assertEqual({
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
327
|
+
self.assertEqual({Xsd_QName("oldap:GenericRestricted"),
|
|
328
|
+
Xsd_QName("oldap:GenericView"),
|
|
329
|
+
Xsd_QName("hyha:HyperHamletMember"),
|
|
330
|
+
Xsd_QName("oldap:GenericExtend"),
|
|
331
|
+
Xsd_QName("oldap:GenericUpdate")}, set(iris))
|
|
332
332
|
|
|
333
333
|
def test_update_permission_set(self):
|
|
334
334
|
ps = PermissionSet(con=self._connection,
|
|
@@ -409,7 +409,7 @@ class TestPermissionSet(unittest.TestCase):
|
|
|
409
409
|
|
|
410
410
|
irgendwas = PropertyClass(con=self._connection,
|
|
411
411
|
project=self._project,
|
|
412
|
-
property_class_iri=
|
|
412
|
+
property_class_iri=Xsd_QName(f'{dm_name}:irgendwas'),
|
|
413
413
|
datatype=XsdDatatypes.string,
|
|
414
414
|
name=LangString(["AnyString@en", "Irgendwas@de"]))
|
|
415
415
|
|
|
@@ -418,18 +418,18 @@ class TestPermissionSet(unittest.TestCase):
|
|
|
418
418
|
#
|
|
419
419
|
resobj = ResourceClass(con=self._connection,
|
|
420
420
|
project=self._project,
|
|
421
|
-
owlclass_iri=
|
|
421
|
+
owlclass_iri=Xsd_QName(f'{dm_name}:DummyClass'),
|
|
422
422
|
label=LangString(["Dummy@en", "Dummy@de"]),
|
|
423
423
|
hasproperties=[
|
|
424
424
|
HasProperty(con=self._connection, project=self._project, prop=irgendwas, maxCount=Xsd_integer(1),
|
|
425
425
|
minCount=Xsd_integer(1), order=1)])
|
|
426
|
-
dm[
|
|
426
|
+
dm[Xsd_QName(f'{dm_name}:resobj')] = resobj
|
|
427
427
|
dm.update()
|
|
428
428
|
dm = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
429
429
|
|
|
430
430
|
factory = ResourceInstanceFactory(con=self._connection, project=self._project)
|
|
431
431
|
DummyClass = factory.createObjectInstance('DummyClass')
|
|
432
|
-
r = DummyClass(irgendwas="Dies ist irgend ein String", grantsPermission=
|
|
432
|
+
r = DummyClass(irgendwas="Dies ist irgend ein String", grantsPermission=Xsd_QName('oldap:GenericUpdate'))
|
|
433
433
|
r.create()
|
|
434
434
|
|
|
435
435
|
ps = PermissionSet.read(con=self._connection, permissionSetId="GenericUpdate", definedByProject=Iri('oldap:SystemProject'), ignore_cache=True)
|
oldaplib/test/test_project.py
CHANGED
|
@@ -124,7 +124,7 @@ class Testproject(unittest.TestCase):
|
|
|
124
124
|
# @unittest.skip('Work in progress')
|
|
125
125
|
def test_project_search(self):
|
|
126
126
|
projects = Project.search(con=self._connection, label="HyperHamlet")
|
|
127
|
-
self.assertEqual({ProjectSearchResult(
|
|
127
|
+
self.assertEqual({ProjectSearchResult(Xsd_QName("oldap:HyperHamlet"), Xsd_NCName("hyha"))}, set(projects))
|
|
128
128
|
|
|
129
129
|
# @unittest.skip('Work in progress')
|
|
130
130
|
def test_project_search_fail(self):
|
|
@@ -133,9 +133,9 @@ class Testproject(unittest.TestCase):
|
|
|
133
133
|
|
|
134
134
|
def test_project_search_all(self):
|
|
135
135
|
projects = Project.search(con=self._connection)
|
|
136
|
-
self.assertTrue(set(projects) >= {ProjectSearchResult(
|
|
137
|
-
ProjectSearchResult(
|
|
138
|
-
ProjectSearchResult(
|
|
136
|
+
self.assertTrue(set(projects) >= {ProjectSearchResult(Xsd_QName("oldap:SystemProject"), Xsd_NCName("oldap")),
|
|
137
|
+
ProjectSearchResult(Xsd_QName("oldap:SharedProject"), Xsd_NCName("shared")),
|
|
138
|
+
ProjectSearchResult(Xsd_QName("oldap:HyperHamlet"), Xsd_NCName("hyha")),
|
|
139
139
|
ProjectSearchResult(Iri("http://www.salsah.org/version/2.0/SwissBritNet"), Xsd_NCName("britnet"))})
|
|
140
140
|
|
|
141
141
|
def test_project_create_simplest(self):
|