oldaplib 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oldaplib/ontologies/admin-testing.trig +2 -4
- oldaplib/ontologies/admin.trig +2 -4
- oldaplib/ontologies/oldap.trig +221 -131
- oldaplib/ontologies/shared.trig +0 -3
- oldaplib/src/datamodel.py +109 -17
- oldaplib/src/dtypes/namespaceiri.py +16 -1
- oldaplib/src/enums/attributeclass.py +31 -6
- oldaplib/src/enums/externalontologyattr.py +22 -0
- oldaplib/src/enums/owlpropertytype.py +10 -0
- oldaplib/src/enums/projectattr.py +0 -1
- oldaplib/src/enums/propertyclassattr.py +24 -19
- oldaplib/src/externalontology.py +554 -0
- oldaplib/src/hasproperty.py +5 -0
- oldaplib/src/helpers/context.py +4 -4
- oldaplib/src/helpers/langstring.py +11 -2
- oldaplib/src/helpers/observable_dict.py +4 -1
- oldaplib/src/helpers/observable_set.py +135 -80
- oldaplib/src/helpers/query_processor.py +3 -0
- oldaplib/src/model.py +1 -1
- oldaplib/src/oldaplist.py +2 -2
- oldaplib/src/oldaplistnode.py +2 -2
- oldaplib/src/permissionset.py +3 -3
- oldaplib/src/project.py +47 -113
- oldaplib/src/propertyclass.py +98 -36
- oldaplib/src/resourceclass.py +7 -5
- oldaplib/src/version.py +1 -1
- oldaplib/src/xsd/iri.py +3 -0
- oldaplib/src/xsd/xsd_anyuri.py +5 -5
- oldaplib/src/xsd/xsd_qname.py +6 -3
- oldaplib/test/test_context.py +0 -4
- oldaplib/test/test_datamodel.py +50 -1
- oldaplib/test/test_dtypes.py +3 -2
- oldaplib/test/test_externalontologies.py +175 -0
- oldaplib/test/test_project.py +31 -76
- oldaplib/test/test_propertyclass.py +168 -6
- oldaplib/test/test_resourceclass.py +10 -10
- oldaplib/testdata/connection_test.trig +29 -12
- oldaplib/testdata/datamodel_test.trig +1 -1
- oldaplib/testdata/objectfactory_test.trig +2 -1
- {oldaplib-0.3.3.dist-info → oldaplib-0.3.5.dist-info}/METADATA +3 -2
- {oldaplib-0.3.3.dist-info → oldaplib-0.3.5.dist-info}/RECORD +42 -39
- {oldaplib-0.3.3.dist-info → oldaplib-0.3.5.dist-info}/WHEEL +1 -1
oldaplib/test/test_context.py
CHANGED
|
@@ -78,9 +78,7 @@ PREFIX xml: <http://www.w3.org/XML/1998/namespace#>
|
|
|
78
78
|
PREFIX sh: <http://www.w3.org/ns/shacl#>
|
|
79
79
|
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
80
80
|
PREFIX schema: <http://schema.org/>
|
|
81
|
-
PREFIX dc: <http://purl.org/dc/elements/1.1/>
|
|
82
81
|
PREFIX dcterms: <http://purl.org/dc/terms/>
|
|
83
|
-
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
|
84
82
|
PREFIX oldap: <http://oldap.org/base#>
|
|
85
83
|
PREFIX shared: <http://oldap.org/shared#>
|
|
86
84
|
PREFIX test: <http://www.test.org/gaga#>
|
|
@@ -98,9 +96,7 @@ PREFIX test: <http://www.test.org/gaga#>
|
|
|
98
96
|
@prefix sh: <http://www.w3.org/ns/shacl#> .
|
|
99
97
|
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
|
|
100
98
|
@prefix schema: <http://schema.org/> .
|
|
101
|
-
@prefix dc: <http://purl.org/dc/elements/1.1/> .
|
|
102
99
|
@prefix dcterms: <http://purl.org/dc/terms/> .
|
|
103
|
-
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
|
104
100
|
@prefix oldap: <http://oldap.org/base#> .
|
|
105
101
|
@prefix shared: <http://oldap.org/shared#> .
|
|
106
102
|
@prefix test: <http://www.test.org/gaga#> .
|
oldaplib/test/test_datamodel.py
CHANGED
|
@@ -9,6 +9,7 @@ from oldaplib.src.cachesingleton import CacheSingletonRedis
|
|
|
9
9
|
from oldaplib.src.connection import Connection
|
|
10
10
|
from oldaplib.src.datamodel import DataModel, PropertyClassChange, ResourceClassChange
|
|
11
11
|
from oldaplib.src.dtypes.languagein import LanguageIn
|
|
12
|
+
from oldaplib.src.externalontology import ExternalOntology
|
|
12
13
|
from oldaplib.src.helpers.context import Context
|
|
13
14
|
from oldaplib.src.enums.action import Action
|
|
14
15
|
from oldaplib.src.dtypes.namespaceiri import NamespaceIRI
|
|
@@ -371,7 +372,8 @@ class TestDataModel(unittest.TestCase):
|
|
|
371
372
|
model = DataModel.read(self._connection, self._sysproject, ignore_cache=True)
|
|
372
373
|
self.assertEqual(set(model.get_propclasses()), {
|
|
373
374
|
Xsd_QName("oldap:hasAdminPermission"),
|
|
374
|
-
Xsd_QName("oldap:statementProperty")
|
|
375
|
+
Xsd_QName("oldap:statementProperty"),
|
|
376
|
+
Xsd_QName("oldap:namespaceIri")
|
|
375
377
|
})
|
|
376
378
|
self.assertEqual(set(model.get_resclasses()), {
|
|
377
379
|
Xsd_QName("oldap:Project"),
|
|
@@ -389,6 +391,19 @@ class TestDataModel(unittest.TestCase):
|
|
|
389
391
|
def test_datamodel_read_shared(self):
|
|
390
392
|
model = DataModel.read(self._connection, self._sharedproject, ignore_cache=True)
|
|
391
393
|
|
|
394
|
+
def test_datamodel_read_system(self):
|
|
395
|
+
model = DataModel.read(self._connection, self._sysproject, ignore_cache=True)
|
|
396
|
+
|
|
397
|
+
def test_datamodel_read_test(self):
|
|
398
|
+
model = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
399
|
+
ontos = model.get_extontos()
|
|
400
|
+
crm = model[Xsd_QName('test:crm')]
|
|
401
|
+
self.assertEqual(crm.prefix, 'crm')
|
|
402
|
+
self.assertEqual(crm.namespaceIri, 'http://www.cidoc-crm.org/cidoc-crm/')
|
|
403
|
+
context = model.context
|
|
404
|
+
self.assertEqual(context['crm'], 'http://www.cidoc-crm.org/cidoc-crm/')
|
|
405
|
+
|
|
406
|
+
|
|
392
407
|
def test_datamodel_cache(self):
|
|
393
408
|
start = time()
|
|
394
409
|
model = DataModel.read(self._connection, self._sysproject, ignore_cache=True)
|
|
@@ -488,6 +503,7 @@ class TestDataModel(unittest.TestCase):
|
|
|
488
503
|
#
|
|
489
504
|
dm[Xsd_QName(f'{dm_name}:Book')][Xsd_QName(f'{dm_name}:authors')].prop.name[Language.FR] = "Ecrivain(s)"
|
|
490
505
|
|
|
506
|
+
|
|
491
507
|
#
|
|
492
508
|
# Add a new property as internal property
|
|
493
509
|
#
|
|
@@ -584,6 +600,39 @@ class TestDataModel(unittest.TestCase):
|
|
|
584
600
|
tmp = set([key for key, val in dm[Xsd_QName(f'{dm_name}:Book')].superclass.items()])
|
|
585
601
|
assert tmp == {'oldap:Thing', 'dcterms:Event'}
|
|
586
602
|
|
|
603
|
+
def test_datamodel_extonto_motify(self):
|
|
604
|
+
model = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
605
|
+
model[Xsd_QName('test:crm')].label['it'] = 'CIDOC-CRM (it)'
|
|
606
|
+
model.update()
|
|
607
|
+
model = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
608
|
+
|
|
609
|
+
crm = model[Xsd_QName('test:crm')]
|
|
610
|
+
self.assertEqual(crm.prefix, 'crm')
|
|
611
|
+
self.assertEqual(crm.namespaceIri, 'http://www.cidoc-crm.org/cidoc-crm/')
|
|
612
|
+
self.assertEqual(crm.label, LangString("CIDOC-CRM@en", "CIDOC-CRM@de", "CIDOC-CRM@fr", "CIDOC-CRM (it)@it"))
|
|
613
|
+
|
|
614
|
+
def test_datamodel_extonto_delete(self):
|
|
615
|
+
model = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
616
|
+
self.assertIsInstance(model.get(Xsd_QName('test:edm')), ExternalOntology)
|
|
617
|
+
del model[Xsd_QName('test:edm')]
|
|
618
|
+
model.update()
|
|
619
|
+
model = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
620
|
+
self.assertIsNone(model.get(Xsd_QName('test:edm')))
|
|
621
|
+
|
|
622
|
+
def test_datamodel_extonto_add(self):
|
|
623
|
+
model = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
624
|
+
eo = ExternalOntology(con=self._connection,
|
|
625
|
+
projectShortName=self._project.projectShortName,
|
|
626
|
+
prefix='testonto',
|
|
627
|
+
namespaceIri='http://www.example.org/ns/testonto#',
|
|
628
|
+
label=LangString("Test ontology@en", "Test ontology@de"))
|
|
629
|
+
model[Xsd_QName('test:testonto')] = eo
|
|
630
|
+
model.update()
|
|
631
|
+
model = DataModel.read(self._connection, self._project, ignore_cache=True)
|
|
632
|
+
self.assertIsInstance(model.get(Xsd_QName('test:testonto')), ExternalOntology)
|
|
633
|
+
|
|
634
|
+
context = model.context
|
|
635
|
+
self.assertEqual(context['testonto'], 'http://www.example.org/ns/testonto#')
|
|
587
636
|
|
|
588
637
|
def test_incremental_generation(self):
|
|
589
638
|
dm = DataModel(con=self._connection,
|
oldaplib/test/test_dtypes.py
CHANGED
|
@@ -13,6 +13,7 @@ from oldaplib.src.helpers.numeric import Numeric
|
|
|
13
13
|
from oldaplib.src.helpers.oldaperror import OldapErrorValue, OldapErrorType
|
|
14
14
|
from oldaplib.src.helpers.query_processor import QueryProcessor
|
|
15
15
|
from oldaplib.src.helpers.serializer import serializer
|
|
16
|
+
from oldaplib.src.xsd.iri import Iri
|
|
16
17
|
from oldaplib.src.xsd.xsd import Xsd
|
|
17
18
|
from oldaplib.src.xsd.xsd_anyuri import Xsd_anyURI
|
|
18
19
|
from oldaplib.src.xsd.xsd_float import Xsd_float
|
|
@@ -93,7 +94,7 @@ class MyTestCase(unittest.TestCase):
|
|
|
93
94
|
ns1 = NamespaceIRI('http://www.org/test/')
|
|
94
95
|
self.assertEqual(str(ns1), 'http://www.org/test/')
|
|
95
96
|
self.assertEqual(repr(ns1), 'NamespaceIRI("http://www.org/test/")')
|
|
96
|
-
self.assertEqual(ns1.toRdf, '
|
|
97
|
+
self.assertEqual(ns1.toRdf, '<http://www.org/test/>')
|
|
97
98
|
self.assertEqual(ns1 + "gaga", Xsd_anyURI("http://www.org/test/gaga"))
|
|
98
99
|
|
|
99
100
|
ns2 = NamespaceIRI('http://www.org/test#')
|
|
@@ -106,7 +107,7 @@ class MyTestCase(unittest.TestCase):
|
|
|
106
107
|
|
|
107
108
|
self.create_triple("NamespaceIRI", ns1)
|
|
108
109
|
valx = self.get_triple("NamespaceIRI")
|
|
109
|
-
self.assertIsInstance(valx,
|
|
110
|
+
self.assertIsInstance(valx, Iri)
|
|
110
111
|
if isinstance(valx, Xsd_anyURI):
|
|
111
112
|
self.assertEqual(ns1, NamespaceIRI(valx))
|
|
112
113
|
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from time import sleep
|
|
4
|
+
from tkinter.font import names
|
|
5
|
+
|
|
6
|
+
from oldaplib.src.connection import Connection
|
|
7
|
+
from oldaplib.src.datamodel import DataModel
|
|
8
|
+
from oldaplib.src.dtypes.namespaceiri import NamespaceIRI
|
|
9
|
+
from oldaplib.src.enums.language import Language
|
|
10
|
+
from oldaplib.src.externalontology import ExternalOntology
|
|
11
|
+
from oldaplib.src.helpers.context import Context
|
|
12
|
+
from oldaplib.src.helpers.langstring import LangString
|
|
13
|
+
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapError, OldapErrorImmutable
|
|
14
|
+
from oldaplib.src.project import Project
|
|
15
|
+
from oldaplib.src.xsd.iri import Iri
|
|
16
|
+
from oldaplib.src.xsd.xsd_qname import Xsd_QName
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def find_project_root(current_path):
|
|
20
|
+
# Climb up the directory hierarchy and check for a marker file
|
|
21
|
+
path = Path(current_path).absolute()
|
|
22
|
+
while not (path / 'pyproject.toml').exists():
|
|
23
|
+
if path.parent == path:
|
|
24
|
+
# Root of the filesystem, file not found
|
|
25
|
+
raise RuntimeError('Project root not found')
|
|
26
|
+
path = path.parent
|
|
27
|
+
return path
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TestexternalOntologies(unittest.TestCase):
|
|
31
|
+
|
|
32
|
+
_connection: Connection
|
|
33
|
+
_unpriv: Connection
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def setUpClass(cls):
|
|
37
|
+
super().setUpClass()
|
|
38
|
+
project_root = find_project_root(__file__)
|
|
39
|
+
cls._context = Context(name="DEFAULT")
|
|
40
|
+
|
|
41
|
+
cls._connection = Connection(userId="rosenth",
|
|
42
|
+
credentials="RioGrande",
|
|
43
|
+
context_name="DEFAULT")
|
|
44
|
+
cls._unpriv = Connection(userId="fornaro",
|
|
45
|
+
credentials="RioGrande",
|
|
46
|
+
context_name="DEFAULT")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
cls._connection.clear_graph(Xsd_QName('oldap:admin'))
|
|
50
|
+
file = project_root / 'oldaplib' / 'ontologies' / 'admin.trig'
|
|
51
|
+
cls._connection.upload_turtle(file)
|
|
52
|
+
file = project_root / 'oldaplib' / 'ontologies' / 'admin-testing.trig'
|
|
53
|
+
cls._connection.upload_turtle(file)
|
|
54
|
+
sleep(1) # upload may take a while...
|
|
55
|
+
|
|
56
|
+
project = Project(con=cls._connection,
|
|
57
|
+
projectIri=Iri("http://extonto.test.org/test"),
|
|
58
|
+
projectShortName="testext",
|
|
59
|
+
namespaceIri=NamespaceIRI("http://extonto.test.org/test/ns/"))
|
|
60
|
+
project.create()
|
|
61
|
+
|
|
62
|
+
dm = DataModel(con=cls._connection, project=project)
|
|
63
|
+
dm.create()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def tearDownClass(cls):
|
|
68
|
+
cls._connection.clear_graph(Xsd_QName('testext:shacl'))
|
|
69
|
+
cls._connection.clear_graph(Xsd_QName('testext:onto'))
|
|
70
|
+
#cls._connection.upload_turtle("oldaplib/ontologies/admin.trig")
|
|
71
|
+
#sleep(1) # upload may take a while...
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
def test_create(self):
|
|
75
|
+
p = Project.read(con=self._connection, projectIri_SName="testext", ignore_cache=True)
|
|
76
|
+
dm = DataModel.read(con=self._connection, project="testext", ignore_cache=True)
|
|
77
|
+
|
|
78
|
+
eo1 = ExternalOntology(con=self._connection,
|
|
79
|
+
projectShortName="testext",
|
|
80
|
+
prefix="gagaA",
|
|
81
|
+
label=LangString("GAGA A ontology@en", "Gaga A Ontologie@de"),
|
|
82
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaA/"))
|
|
83
|
+
eo1.create()
|
|
84
|
+
del eo1
|
|
85
|
+
|
|
86
|
+
eo1 = ExternalOntology.read(con=self._connection, projectShortName="testext", prefix="gagaA", ignore_cache=True)
|
|
87
|
+
self.assertEqual(eo1.prefix, "gagaA")
|
|
88
|
+
self.assertEqual(eo1.label, LangString("GAGA A ontology@en", "Gaga A Ontologie@de"))
|
|
89
|
+
self.assertEqual(eo1.namespaceIri, NamespaceIRI("http://gaga.org/ns/gagaA/"))
|
|
90
|
+
|
|
91
|
+
ExternalOntology.delete_all(con=self._connection, projectShortName="testext")
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_update(self):
|
|
96
|
+
p = Project.read(con=self._connection, projectIri_SName="testext", ignore_cache=True)
|
|
97
|
+
dm = DataModel.read(con=self._connection, project="testext", ignore_cache=True)
|
|
98
|
+
|
|
99
|
+
eo1 = ExternalOntology(con=self._connection,
|
|
100
|
+
projectShortName="testext",
|
|
101
|
+
prefix="gagaB",
|
|
102
|
+
label=LangString("GAGA B ontology@en", "Gaga B Ontologie@de"),
|
|
103
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaB/"))
|
|
104
|
+
eo1.create()
|
|
105
|
+
|
|
106
|
+
del eo1
|
|
107
|
+
eo1 = ExternalOntology.read(con=self._connection, projectShortName="testext", prefix="gagaB", ignore_cache=True)
|
|
108
|
+
eo1.prefix = "gugus"
|
|
109
|
+
eo1.comment = LangString("Gugus comment@en", "Gugus Kommentar@de")
|
|
110
|
+
del eo1.label[Language.DE]
|
|
111
|
+
eo1.label[Language.FR] = "GAGA B ontologie"
|
|
112
|
+
eo1.update()
|
|
113
|
+
|
|
114
|
+
del eo1
|
|
115
|
+
eo1 = ExternalOntology.read(con=self._connection, projectShortName="testext", prefix="gagaB", ignore_cache=True)
|
|
116
|
+
self.assertEqual(eo1.prefix, "gugus")
|
|
117
|
+
self.assertEqual(eo1.label, LangString("GAGA B ontology@en", "GAGA B ontologie@fr"))
|
|
118
|
+
self.assertEqual(eo1.comment, LangString("Gugus comment@en", "Gugus Kommentar@de"))
|
|
119
|
+
self.assertEqual(eo1.namespaceIri, NamespaceIRI("http://gaga.org/ns/gagaB/"))
|
|
120
|
+
|
|
121
|
+
with self.assertRaises(OldapErrorImmutable):
|
|
122
|
+
eo1.namespaceIri = NamespaceIRI("http://gaga.org/ns/gaga2/new/")
|
|
123
|
+
|
|
124
|
+
ExternalOntology.delete_all(con=self._connection, projectShortName="testext")
|
|
125
|
+
|
|
126
|
+
def test_search(self):
|
|
127
|
+
p = Project.read(con=self._connection, projectIri_SName="testext", ignore_cache=True)
|
|
128
|
+
dm = DataModel.read(con=self._connection, project="testext", ignore_cache=True)
|
|
129
|
+
|
|
130
|
+
eo1 = ExternalOntology(con=self._connection,
|
|
131
|
+
projectShortName="testext",
|
|
132
|
+
prefix="gagaC",
|
|
133
|
+
label=LangString("GAGA C ontology@en", "Gaga C Ontologie@de"),
|
|
134
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaC/"))
|
|
135
|
+
eo1.create()
|
|
136
|
+
|
|
137
|
+
eo2 = ExternalOntology(con=self._connection,
|
|
138
|
+
projectShortName="testext",
|
|
139
|
+
prefix="gagaD",
|
|
140
|
+
label=LangString("GAGA D ontology@en", "Gaga D Ontologie@de"),
|
|
141
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaD/"))
|
|
142
|
+
eo2.create()
|
|
143
|
+
|
|
144
|
+
res = ExternalOntology.search(con=self._connection, projectShortName="testext")
|
|
145
|
+
qnames = [x.extonto_qname for x in res]
|
|
146
|
+
self.assertEqual(set(qnames), {Xsd_QName('testext:gagaC'), Xsd_QName('testext:gagaD')})
|
|
147
|
+
|
|
148
|
+
ExternalOntology.delete_all(con=self._connection, projectShortName="testext")
|
|
149
|
+
|
|
150
|
+
def test_delete(self):
|
|
151
|
+
p = Project.read(con=self._connection, projectIri_SName="testext", ignore_cache=True)
|
|
152
|
+
dm = DataModel.read(con=self._connection, project="testext", ignore_cache=True)
|
|
153
|
+
|
|
154
|
+
eo1 = ExternalOntology(con=self._connection,
|
|
155
|
+
projectShortName="testext",
|
|
156
|
+
prefix="gagaE",
|
|
157
|
+
label=LangString("GAGA E ontology@en", "Gaga E Ontologie@de"),
|
|
158
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaE/"))
|
|
159
|
+
eo1.create()
|
|
160
|
+
|
|
161
|
+
eo2 = ExternalOntology(con=self._connection,
|
|
162
|
+
projectShortName="testext",
|
|
163
|
+
prefix="gagaF",
|
|
164
|
+
label=LangString("GAGA F ontology@en", "Gaga F Ontologie@de"),
|
|
165
|
+
namespaceIri=NamespaceIRI("http://gaga.org/ns/gagaF/"))
|
|
166
|
+
eo2.create()
|
|
167
|
+
res = ExternalOntology.search(con=self._connection, projectShortName="testext", prefix="gagaF")
|
|
168
|
+
self.assertEqual(len(res), 1)
|
|
169
|
+
res[0].delete()
|
|
170
|
+
|
|
171
|
+
ExternalOntology.delete_all(con=self._connection, projectShortName="testext")
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
oldaplib/test/test_project.py
CHANGED
|
@@ -16,7 +16,8 @@ from oldaplib.src.xsd.xsd_qname import Xsd_QName
|
|
|
16
16
|
from oldaplib.src.xsd.xsd_ncname import Xsd_NCName
|
|
17
17
|
from oldaplib.src.xsd.xsd_date import Xsd_date
|
|
18
18
|
from oldaplib.src.helpers.langstring import LangString
|
|
19
|
-
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorInconsistency, OldapErrorNoPermission
|
|
19
|
+
from oldaplib.src.helpers.oldaperror import OldapErrorNotFound, OldapErrorInconsistency, OldapErrorNoPermission, \
|
|
20
|
+
OldapErrorAlreadyExists
|
|
20
21
|
from oldaplib.src.project import Project, ProjectSearchResult
|
|
21
22
|
from oldaplib.src.helpers.serializer import serializer
|
|
22
23
|
|
|
@@ -90,6 +91,9 @@ class Testproject(unittest.TestCase):
|
|
|
90
91
|
self.assertEqual(project.projectEnd, project2.projectEnd)
|
|
91
92
|
|
|
92
93
|
|
|
94
|
+
def test_project_read_with_uses_ontologies(self):
|
|
95
|
+
project = Project.read(con=self._connection, projectIri_SName="hyha", ignore_cache=True)
|
|
96
|
+
|
|
93
97
|
# @unittest.skip('Work in progress')
|
|
94
98
|
def test_project_read(self):
|
|
95
99
|
project = Project.read(con=self._connection, projectIri_SName=Iri("oldap:SystemProject"), ignore_cache=True)
|
|
@@ -260,83 +264,33 @@ class Testproject(unittest.TestCase):
|
|
|
260
264
|
project = Project.read(con=self._connection, projectIri_SName="unittest6", ignore_cache=True)
|
|
261
265
|
project.delete()
|
|
262
266
|
|
|
263
|
-
def
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
project.create()
|
|
276
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesA", ignore_cache=True)
|
|
277
|
-
self.assertEqual(project.usesExternalOntology, {
|
|
278
|
-
Xsd_NCName("prefix1"): NamespaceIRI("http://prefix1.org/"),
|
|
279
|
-
Xsd_NCName("prefix2"): NamespaceIRI("http://prefix2.org/")
|
|
280
|
-
})
|
|
267
|
+
def test_duplicate_project_create(self):
|
|
268
|
+
project1 = Project(con=self._connection,
|
|
269
|
+
projectShortName="unittestXX",
|
|
270
|
+
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestXX#"),
|
|
271
|
+
label=LangString(["unittestXX@en", "unittestXX@de"]))
|
|
272
|
+
project1.create()
|
|
273
|
+
project2 = Project(con=self._connection,
|
|
274
|
+
projectShortName="unittestXX",
|
|
275
|
+
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestYY#"),
|
|
276
|
+
label=LangString(["unittestXX@en", "unittestXX@de"]))
|
|
277
|
+
with self.assertRaises(OldapErrorAlreadyExists) as ex:
|
|
278
|
+
project2.create()
|
|
281
279
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
projectStart=Xsd_date(2024, 3, 3),
|
|
289
|
-
projectEnd=Xsd_date(2027, 3, 2),
|
|
290
|
-
usesExternalOntology={
|
|
291
|
-
Xsd_NCName("prefix1"): NamespaceIRI("http://prefix1.org/"),
|
|
292
|
-
Xsd_NCName("prefix2"): NamespaceIRI("http://prefix2.org/")
|
|
293
|
-
})
|
|
294
|
-
project.create()
|
|
295
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesB", ignore_cache=True)
|
|
296
|
-
del project.usesExternalOntology
|
|
297
|
-
project.update()
|
|
298
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesB", ignore_cache=True)
|
|
299
|
-
self.assertIsNone(project.usesExternalOntology)
|
|
300
|
-
|
|
301
|
-
def test_project_create_with_external_ontologies_C(self):
|
|
302
|
-
project = Project(con=self._connection,
|
|
303
|
-
projectShortName="WithExternalOntologiesC",
|
|
304
|
-
label=LangString("External Ontologies"),
|
|
305
|
-
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestXX#"),
|
|
306
|
-
comment=LangString(["For testingXX@en", "Für TestsXX@de"]),
|
|
307
|
-
projectStart=Xsd_date(2024, 3, 3),
|
|
308
|
-
projectEnd=Xsd_date(2027, 3, 2))
|
|
309
|
-
project.create()
|
|
310
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesC", ignore_cache=True)
|
|
311
|
-
project.usesExternalOntology = {Xsd_NCName('prefix') : NamespaceIRI('http://prefix.org/')}
|
|
312
|
-
project.update()
|
|
313
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesC", ignore_cache=True)
|
|
314
|
-
self.assertEqual(project.usesExternalOntology, {Xsd_NCName('prefix') : NamespaceIRI('http://prefix.org/')})
|
|
315
|
-
|
|
316
|
-
def test_project_create_with_external_ontologies_D(self):
|
|
317
|
-
project = Project(con=self._connection,
|
|
318
|
-
projectShortName="WithExternalOntologiesD",
|
|
319
|
-
label=LangString("External Ontologies"),
|
|
320
|
-
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestXX#"),
|
|
321
|
-
comment=LangString(["For testingXX@en", "Für TestsXX@de"]),
|
|
322
|
-
projectStart=Xsd_date(2024, 3, 3),
|
|
323
|
-
projectEnd=Xsd_date(2027, 3, 2),
|
|
324
|
-
usesExternalOntology={
|
|
325
|
-
Xsd_NCName("prefix1"): NamespaceIRI("http://prefix1.org/"),
|
|
326
|
-
Xsd_NCName("prefix2"): NamespaceIRI("http://prefix2.org/")
|
|
327
|
-
})
|
|
328
|
-
project.create()
|
|
329
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesD", ignore_cache=True)
|
|
330
|
-
del project.usesExternalOntology['prefix1']
|
|
331
|
-
project.usesExternalOntology[Xsd_NCName('prefix2')] = NamespaceIRI("http://prefix2.org/CHANGED/")
|
|
332
|
-
project.usesExternalOntology[Xsd_NCName('prefix3')] = NamespaceIRI("http://prefix3.org/")
|
|
333
|
-
project.update()
|
|
334
|
-
project = Project.read(con=self._connection, projectIri_SName="WithExternalOntologiesD", ignore_cache=True)
|
|
335
|
-
self.assertEqual(project.usesExternalOntology, {
|
|
336
|
-
Xsd_NCName("prefix2"): NamespaceIRI("http://prefix2.org/CHANGED/"),
|
|
337
|
-
Xsd_NCName("prefix3"): NamespaceIRI("http://prefix3.org/")
|
|
338
|
-
})
|
|
280
|
+
project3 = Project(con=self._connection,
|
|
281
|
+
projectShortName="unittestYY",
|
|
282
|
+
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestXX#"),
|
|
283
|
+
label=LangString(["unittestXX@en", "unittestXX@de"]))
|
|
284
|
+
with self.assertRaises(OldapErrorAlreadyExists) as ex:
|
|
285
|
+
project3.create()
|
|
339
286
|
|
|
287
|
+
project4 = Project(con=self._connection,
|
|
288
|
+
projectIri=project1.projectIri,
|
|
289
|
+
projectShortName="unittestZZ",
|
|
290
|
+
namespaceIri=NamespaceIRI("http://unitest.org/project/unittestZZ#"),
|
|
291
|
+
label=LangString(["unittestZZ@en", "unittestZZ@de"]))
|
|
292
|
+
with self.assertRaises(OldapErrorAlreadyExists) as ex:
|
|
293
|
+
project4.create()
|
|
340
294
|
|
|
341
295
|
def test_project_create_without_label_comment(self):
|
|
342
296
|
project = Project(con=self._connection,
|
|
@@ -352,6 +306,7 @@ class Testproject(unittest.TestCase):
|
|
|
352
306
|
project = Project.read(con=self._connection, projectIri_SName="emptyfieldsXX", ignore_cache=True)
|
|
353
307
|
project.delete()
|
|
354
308
|
|
|
309
|
+
|
|
355
310
|
def test_project_create_empty_fields(self):
|
|
356
311
|
project = Project(con=self._connection,
|
|
357
312
|
projectShortName="emptyfields1",
|