mustrd 0.2.0__py3-none-any.whl → 0.2.0a1__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.
- mustrd/README.adoc +201 -210
- mustrd/execute_update_spec.py +18 -0
- mustrd/logger_setup.py +48 -48
- mustrd/mustrd.py +842 -787
- mustrd/mustrdAnzo.py +208 -220
- mustrd/mustrdGraphDb.py +128 -125
- mustrd/mustrdRdfLib.py +56 -56
- mustrd/namespace.py +104 -125
- mustrd/run.py +95 -106
- mustrd/spec_component.py +617 -690
- mustrd/triple_store_dispatch.py +115 -0
- mustrd/utils.py +30 -38
- {mustrd-0.2.0.dist-info → mustrd-0.2.0a1.dist-info}/LICENSE +21 -21
- mustrd-0.2.0a1.dist-info/METADATA +24 -0
- mustrd-0.2.0a1.dist-info/RECORD +17 -0
- {mustrd-0.2.0.dist-info → mustrd-0.2.0a1.dist-info}/WHEEL +1 -1
- mustrd/TestResult.py +0 -136
- mustrd/model/catalog-v001.xml +0 -5
- mustrd/model/mustrdShapes.ttl +0 -253
- mustrd/model/mustrdTestOntology.ttl +0 -51
- mustrd/model/mustrdTestShapes.ttl +0 -24
- mustrd/model/ontology.ttl +0 -494
- mustrd/model/test-resources/resources.ttl +0 -60
- mustrd/model/triplestoreOntology.ttl +0 -174
- mustrd/model/triplestoreshapes.ttl +0 -42
- mustrd/mustrdQueryProcessor.py +0 -136
- mustrd/mustrdTestPlugin.py +0 -328
- mustrd/steprunner.py +0 -166
- mustrd/templates/md_ResultList_leaf_template.jinja +0 -19
- mustrd/templates/md_ResultList_template.jinja +0 -9
- mustrd/templates/md_stats_template.jinja +0 -3
- mustrd/test/test_mustrd.py +0 -5
- mustrd-0.2.0.dist-info/METADATA +0 -97
- mustrd-0.2.0.dist-info/RECORD +0 -32
- mustrd-0.2.0.dist-info/entry_points.txt +0 -3
@@ -0,0 +1,115 @@
|
|
1
|
+
"""
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Copyright (c) 2023 Semantic Partners Ltd
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
"""
|
24
|
+
from execute_update_spec import execute_update_spec
|
25
|
+
from multimethods import MultiMethod, Default
|
26
|
+
from rdflib import Graph, URIRef
|
27
|
+
|
28
|
+
import logger_setup
|
29
|
+
from namespace import MUST
|
30
|
+
from mustrdGraphDb import execute_select as execute_graphdb_select
|
31
|
+
from mustrdGraphDb import execute_construct as execute_graphdb_construct
|
32
|
+
from mustrdGraphDb import execute_update as execute_graphdb_update
|
33
|
+
from mustrdAnzo import execute_select_mustrd_spec_stage as execute_anzo_select
|
34
|
+
from mustrdAnzo import execute_construct_mustrd_spec_stage as execute_anzo_construct
|
35
|
+
from mustrdRdfLib import execute_select as execute_rdflib_select
|
36
|
+
from mustrdRdfLib import execute_construct as execute_rdflib_construct
|
37
|
+
from mustrdRdfLib import execute_update as execute_rdflib_update
|
38
|
+
|
39
|
+
|
40
|
+
log = logger_setup.setup_logger(__name__)
|
41
|
+
|
42
|
+
|
43
|
+
def dispatch_construct(triple_store: dict, given: Graph, when: str, bindings: dict) -> URIRef:
|
44
|
+
to = triple_store["type"]
|
45
|
+
log.info(f"dispatch_construct to triple store {to}")
|
46
|
+
return to
|
47
|
+
|
48
|
+
|
49
|
+
execute_construct_spec = MultiMethod('execute_construct_spec', dispatch_construct)
|
50
|
+
|
51
|
+
|
52
|
+
@execute_construct_spec.method(MUST.RdfLib)
|
53
|
+
def execute_construct_rdflib(triple_store: dict, given: Graph, when: str, bindings: dict = None) -> Graph:
|
54
|
+
return execute_rdflib_construct(triple_store, given, when, bindings)
|
55
|
+
|
56
|
+
|
57
|
+
@execute_construct_spec.method(MUST.GraphDb)
|
58
|
+
def execute_construct_graphdb(triple_store: dict, given: Graph, when: str, bindings: dict = None) -> Graph:
|
59
|
+
return execute_graphdb_construct(triple_store, given, when, bindings)
|
60
|
+
|
61
|
+
|
62
|
+
@execute_construct_spec.method(MUST.Anzo)
|
63
|
+
def execute_construct_anzo(triple_store: dict, given: Graph, when: str, bindings: dict = None) -> Graph:
|
64
|
+
return execute_anzo_construct(triple_store, given, when, bindings)
|
65
|
+
|
66
|
+
|
67
|
+
@execute_construct_spec.method(Default)
|
68
|
+
def execute_construct_default(triple_store: dict, given: Graph, when: str, bindings: dict = None):
|
69
|
+
raise NotImplementedError(f"SPARQL CONSTRUCT not implemented for {triple_store['type']}")
|
70
|
+
|
71
|
+
|
72
|
+
def dispatch_select(triple_store: dict, given: Graph, when: str, bindings: dict) -> URIRef:
|
73
|
+
to = triple_store["type"]
|
74
|
+
log.info(f"dispatch_select to triple store {to}")
|
75
|
+
return to
|
76
|
+
|
77
|
+
|
78
|
+
execute_select_spec = MultiMethod('execute_select_spec', dispatch_select)
|
79
|
+
|
80
|
+
|
81
|
+
@execute_select_spec.method(MUST.RdfLib)
|
82
|
+
def execute_select_rdflib(triple_store: dict, given: Graph, when: str, bindings: dict = None) -> str:
|
83
|
+
return execute_rdflib_select(triple_store, given, when, bindings)
|
84
|
+
|
85
|
+
|
86
|
+
@execute_select_spec.method(MUST.GraphDb)
|
87
|
+
def execute_select_graphdb(triple_store: dict, given: Graph, when: str, bindings: dict = None) -> str:
|
88
|
+
return execute_graphdb_select(triple_store, given, when, bindings)
|
89
|
+
|
90
|
+
|
91
|
+
@execute_select_spec.method(MUST.Anzo)
|
92
|
+
def execute_select_anzo(triple_store: dict, given: Graph, when: str, bindings: dict = None) -> str:
|
93
|
+
return execute_anzo_select(triple_store, given, when, bindings)
|
94
|
+
|
95
|
+
|
96
|
+
@execute_select_spec.method(Default)
|
97
|
+
def execute_select_default(triple_store: dict, given: Graph, when: str, bindings: dict = None):
|
98
|
+
raise NotImplementedError(f"SPARQL SELECT not implemented for {triple_store['type']}")
|
99
|
+
|
100
|
+
|
101
|
+
@execute_update_spec.method(MUST.RdfLib)
|
102
|
+
def execute_update_rdflib(triple_store: dict, given: Graph, when: str, bindings: dict = None) -> Graph:
|
103
|
+
return execute_rdflib_update(triple_store, given, when, bindings)
|
104
|
+
|
105
|
+
|
106
|
+
@execute_update_spec.method(MUST.GraphDb)
|
107
|
+
def execute_update_graphdb(triple_store: dict, given: Graph, when: str, bindings: dict = None) -> Graph:
|
108
|
+
return execute_graphdb_update(triple_store, given, when, bindings)
|
109
|
+
|
110
|
+
|
111
|
+
@execute_update_spec.method(Default)
|
112
|
+
def execute_update_default(triple_store: dict, given: Graph, when: str, bindings: dict = None):
|
113
|
+
raise NotImplementedError(f"SPARQL UPDATE not implemented for {triple_store['type']}")
|
114
|
+
|
115
|
+
|
mustrd/utils.py
CHANGED
@@ -1,38 +1,30 @@
|
|
1
|
-
"""
|
2
|
-
MIT License
|
3
|
-
|
4
|
-
Copyright (c) 2023 Semantic Partners Ltd
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
8
|
-
in the Software without restriction, including without limitation the rights
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
11
|
-
furnished to do so, subject to the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
14
|
-
copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
SOFTWARE.
|
23
|
-
"""
|
24
|
-
|
25
|
-
import
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
return Path(__file__).parent
|
32
|
-
|
33
|
-
def is_json(myjson: str) -> bool:
|
34
|
-
try:
|
35
|
-
json.loads(myjson)
|
36
|
-
except ValueError:
|
37
|
-
return False
|
38
|
-
return True
|
1
|
+
"""
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Copyright (c) 2023 Semantic Partners Ltd
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
"""
|
24
|
+
|
25
|
+
from pathlib import Path
|
26
|
+
|
27
|
+
|
28
|
+
# Keep this function in a file directly under project root / src
|
29
|
+
def get_project_root() -> Path:
|
30
|
+
return Path(__file__).parent.parent
|
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2023 Semantic Partners Ltd
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Semantic Partners Ltd
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: mustrd
|
3
|
+
Version: 0.2.0a1
|
4
|
+
Summary: A Spec By Example framework for RDF and SPARQL, Inspired by Cucumber.
|
5
|
+
Author: John Placek
|
6
|
+
Author-email: john.placek@semanticpartners.com
|
7
|
+
Requires-Python: >=3.11,<4.0.0
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
12
|
+
Requires-Dist: beautifulsoup4 (>=4.11.1)
|
13
|
+
Requires-Dist: colorlog (>=6.7.0)
|
14
|
+
Requires-Dist: multimethods-py (>=0.5.3)
|
15
|
+
Requires-Dist: openpyxl (>=3.1.2)
|
16
|
+
Requires-Dist: pandas (>=1.5.2)
|
17
|
+
Requires-Dist: pyanzo (>=3.3.7)
|
18
|
+
Requires-Dist: pyshacl (>=0.23.0)
|
19
|
+
Requires-Dist: pytest (>=7.2.0)
|
20
|
+
Requires-Dist: rdflib (>=6.2.0)
|
21
|
+
Requires-Dist: requests (>=2.28.2)
|
22
|
+
Requires-Dist: tabulate (>=0.9.0)
|
23
|
+
Requires-Dist: toml (>=0.10.2)
|
24
|
+
Requires-Dist: tomli (>=2.0.1)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
mustrd/README.adoc,sha256=aKV_i6ygL4JH1s51FIcpu4Cqm-Q5LC_YD64h6wqk7Kw,11602
|
2
|
+
mustrd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
mustrd/execute_update_spec.py,sha256=hK2RdTwBtsr_ZGlegiG9Ydf8KqaMWu0dc1yKrXtEsjQ,605
|
4
|
+
mustrd/logger_setup.py,sha256=pNtG5egdd7OiFdn-Qx-tlf5JITka1yitbzYBpHzrP_4,1582
|
5
|
+
mustrd/mustrd.py,sha256=QXF6PxtyCPaSEWkPtUY50fxXG8eFUDDSQe5WJqBBl8o,35501
|
6
|
+
mustrd/mustrdAnzo.py,sha256=p7QLKpi9PsO5GP6PFd-18v6lJAbnhSrwC-xENgGjaBY,9947
|
7
|
+
mustrd/mustrdGraphDb.py,sha256=Uge9tiEONA1tqeoZMjBcfSM2JYj3KIQqYrtY4p-4zCY,5630
|
8
|
+
mustrd/mustrdRdfLib.py,sha256=CvrzEl1-lEPugYVe3y_Ip8JMzUxv6IeWauLOa_WA-XI,2073
|
9
|
+
mustrd/namespace.py,sha256=HykSyBJWjOxHcWFNmdcetkH1DofkEQJmW8qIPu76UPo,2798
|
10
|
+
mustrd/run.py,sha256=4Rq-_eClirJ3TIwLnKlsg2YevHuSgBj8NHc5KtXShaI,3637
|
11
|
+
mustrd/spec_component.py,sha256=OLrmXHmltTP0NgtSIPXS3ZbCWSmFTElwwIkoUPSXq5c,26552
|
12
|
+
mustrd/triple_store_dispatch.py,sha256=xXsPqtm_xuTEUCedtkMXX9gIp1tus_h2zLtYvpsDIRo,4875
|
13
|
+
mustrd/utils.py,sha256=kLu_rcY_9E60T3yLw2rdTeRB2F_qAN2rf5KhjgkAyl4,1251
|
14
|
+
mustrd-0.2.0a1.dist-info/LICENSE,sha256=r8nmh5fUct9h2w8_RDl13EIscvmwCLoarPr1kg35MnA,1078
|
15
|
+
mustrd-0.2.0a1.dist-info/METADATA,sha256=rRq6ENsRr5gY5pxyg0FcmLwjBodSB-Ul8mNg4B0om98,873
|
16
|
+
mustrd-0.2.0a1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
17
|
+
mustrd-0.2.0a1.dist-info/RECORD,,
|
mustrd/TestResult.py
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
MIT License
|
3
|
-
|
4
|
-
Copyright (c) 2023 Semantic Partners Ltd
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
8
|
-
in the Software without restriction, including without limitation the rights
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
11
|
-
furnished to do so, subject to the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
14
|
-
copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
SOFTWARE.
|
23
|
-
"""
|
24
|
-
|
25
|
-
from typing import Union
|
26
|
-
from itertools import groupby
|
27
|
-
from jinja2 import Environment, FileSystemLoader
|
28
|
-
from dataclasses import dataclass
|
29
|
-
from enum import Enum
|
30
|
-
from pathlib import Path
|
31
|
-
import os
|
32
|
-
from mustrd.utils import get_mustrd_root
|
33
|
-
|
34
|
-
|
35
|
-
class testType(Enum):
|
36
|
-
MUSTRD = "Mustrd"
|
37
|
-
PYTEST = "Pytest"
|
38
|
-
|
39
|
-
|
40
|
-
class testStatus(Enum):
|
41
|
-
PASSED = "passed"
|
42
|
-
FAILED = "failed"
|
43
|
-
SKIPPED = "skipped"
|
44
|
-
|
45
|
-
|
46
|
-
TEMPLATE_FOLDER = Path(os.path.join(get_mustrd_root(), "templates/"))
|
47
|
-
|
48
|
-
|
49
|
-
RESULT_LIST_MD_TEMPLATE = "md_ResultList_template.jinja"
|
50
|
-
RESULT_LIST_LEAF_MD_TEMPLATE = "md_ResultList_leaf_template.jinja"
|
51
|
-
|
52
|
-
|
53
|
-
@dataclass
|
54
|
-
class TestResult:
|
55
|
-
test_name: str
|
56
|
-
class_name: str
|
57
|
-
module_name: str
|
58
|
-
status: str
|
59
|
-
is_mustrd: bool
|
60
|
-
type: str
|
61
|
-
|
62
|
-
def __init__(self, test_name: str, class_name: str, module_name: str, status: str, is_mustrd: bool):
|
63
|
-
self.test_name = test_name
|
64
|
-
self.class_name = class_name
|
65
|
-
self.module_name = module_name
|
66
|
-
self.status = status
|
67
|
-
self.is_mustrd = is_mustrd
|
68
|
-
self.type = testType.MUSTRD.value if self.is_mustrd else testType.PYTEST.value
|
69
|
-
|
70
|
-
|
71
|
-
@dataclass
|
72
|
-
class Stats:
|
73
|
-
count: int
|
74
|
-
success_count: int
|
75
|
-
fail_count: int
|
76
|
-
skipped_count: int
|
77
|
-
|
78
|
-
def __init__(self, count: int, success_count: int, fail_count: int, skipped_count: int):
|
79
|
-
self.count = count
|
80
|
-
self.success_count = success_count
|
81
|
-
self.fail_count = fail_count
|
82
|
-
self.skipped_count = skipped_count
|
83
|
-
|
84
|
-
|
85
|
-
def get_result_list(test_results: list[TestResult], *group_functions):
|
86
|
-
if len(group_functions) > 0:
|
87
|
-
return list(map(lambda key_group:
|
88
|
-
ResultList(key_group[0],
|
89
|
-
get_result_list(key_group[1],
|
90
|
-
*group_functions[1:]),
|
91
|
-
len(group_functions) == 1),
|
92
|
-
groupby(sorted(test_results, key=group_functions[0]), group_functions[0])))
|
93
|
-
else:
|
94
|
-
return list(test_results)
|
95
|
-
|
96
|
-
|
97
|
-
@dataclass
|
98
|
-
class ResultList:
|
99
|
-
name: str
|
100
|
-
stats: Stats
|
101
|
-
is_leaf: bool
|
102
|
-
# string type to workaround recursive call
|
103
|
-
result_list: Union[list['ResultList'], list[TestResult]]
|
104
|
-
|
105
|
-
def __init__(self, name: str, result_list: Union[list['ResultList'], list[TestResult]], is_leaf: bool = False):
|
106
|
-
self.name = name
|
107
|
-
self.result_list = result_list
|
108
|
-
self.is_leaf = is_leaf
|
109
|
-
self.compute_stats()
|
110
|
-
|
111
|
-
def compute_stats(self):
|
112
|
-
count, success_count, fail_count, skipped_count = 0, 0, 0, 0
|
113
|
-
|
114
|
-
if self.is_leaf:
|
115
|
-
count = len(self.result_list)
|
116
|
-
success_count = len(
|
117
|
-
list(filter(lambda x: x.status == testStatus.PASSED.value, self.result_list)))
|
118
|
-
fail_count = len(
|
119
|
-
list(filter(lambda x: x.status == testStatus.FAILED.value, self.result_list)))
|
120
|
-
skipped_count = len(
|
121
|
-
list(filter(lambda x: x.status == testStatus.SKIPPED.value, self.result_list)))
|
122
|
-
else:
|
123
|
-
for test_results in self.result_list:
|
124
|
-
sub_count, sub_success_count, sub_fail_count, sub_skipped_count = test_results.compute_stats()
|
125
|
-
count += sub_count
|
126
|
-
success_count += sub_success_count
|
127
|
-
fail_count += sub_fail_count
|
128
|
-
skipped_count += sub_skipped_count
|
129
|
-
|
130
|
-
self.stats = Stats(count, success_count, fail_count, skipped_count)
|
131
|
-
return count, success_count, fail_count, skipped_count
|
132
|
-
|
133
|
-
def render(self):
|
134
|
-
environment = Environment(loader=FileSystemLoader(TEMPLATE_FOLDER))
|
135
|
-
template = RESULT_LIST_LEAF_MD_TEMPLATE if self.is_leaf else RESULT_LIST_MD_TEMPLATE
|
136
|
-
return environment.get_template(template).render(result_list=self.result_list, environment=environment)
|
mustrd/model/catalog-v001.xml
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
-
<catalog prefer="public" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
|
3
|
-
<uri id="User Entered Import Resolution" name="https://mustrd.com/triplestore/" uri="triplestoreOntology.ttl"/>
|
4
|
-
<group id="Folder Repository, directory=, recursive=true, Auto-Update=true, version=2" prefer="public" xml:base=""/>
|
5
|
-
</catalog>
|
mustrd/model/mustrdShapes.ttl
DELETED
@@ -1,253 +0,0 @@
|
|
1
|
-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
2
|
-
@prefix sh: <http://www.w3.org/ns/shacl#> .
|
3
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
4
|
-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
5
|
-
@prefix ex: <http://www.example.org/#> .
|
6
|
-
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
7
|
-
@prefix must: <https://mustrd.com/model/> .
|
8
|
-
|
9
|
-
must:
|
10
|
-
sh:declare [ sh:prefix "must" ;
|
11
|
-
sh:namespace "https://mustrd.com/model/"^^xsd:anyURI ; ] .
|
12
|
-
|
13
|
-
|
14
|
-
must:TestSpecShape
|
15
|
-
a sh:NodeShape ;
|
16
|
-
sh:targetClass must:TestSpec ;
|
17
|
-
sh:property [ sh:path must:given ;
|
18
|
-
sh:class must:Dataset ;
|
19
|
-
sh:minCount 1 ; ] ;
|
20
|
-
sh:property [ sh:path must:when ;
|
21
|
-
sh:class must:SparqlSource ;
|
22
|
-
sh:minCount 1 ; ] ;
|
23
|
-
sh:property [ sh:path must:then ;
|
24
|
-
sh:class must:Dataset ;
|
25
|
-
sh:minCount 1 ; ] .
|
26
|
-
|
27
|
-
must:TestSpecGivenShape
|
28
|
-
a sh:NodeShape ;
|
29
|
-
sh:targetClass must:TestSpec ;
|
30
|
-
sh:message "Invalid given clause: Table datasets for givens are not currently supported." ;
|
31
|
-
sh:not [ sh:path must:given ;
|
32
|
-
sh:class must:TableDataset ;
|
33
|
-
sh:minCount 1 ; ] .
|
34
|
-
|
35
|
-
must:TestSpecWithInheritedDatasetShape
|
36
|
-
a sh:NodeShape ;
|
37
|
-
sh:target [ a sh:SPARQLTarget ;
|
38
|
-
sh:prefixes must: ;
|
39
|
-
sh:select """
|
40
|
-
SELECT ?this
|
41
|
-
WHERE {
|
42
|
-
?this a must:TestSpec .
|
43
|
-
?this must:given/rdf:type must:InheritedDataset .
|
44
|
-
}
|
45
|
-
""" ; ] ;
|
46
|
-
sh:property [ sh:message "Invalid given clause: Tests using an inherited state can only have a single given clause.";
|
47
|
-
sh:path must:given ;
|
48
|
-
sh:minCount 1 ;
|
49
|
-
sh:maxCount 1 ; ] .
|
50
|
-
|
51
|
-
|
52
|
-
must:UpdateTestSpecThenValidationShape
|
53
|
-
a sh:NodeShape ;
|
54
|
-
sh:target [ a sh:SPARQLTarget ;
|
55
|
-
sh:prefixes must: ;
|
56
|
-
sh:select """
|
57
|
-
SELECT ?this
|
58
|
-
WHERE {
|
59
|
-
?this a must:TestSpec .
|
60
|
-
?this must:when/must:queryType must:UpdateSparql .
|
61
|
-
}
|
62
|
-
""" ; ] ;
|
63
|
-
sh:message "Invalid then clause: A tabular data format has been specified for a SPARQL update test." ;
|
64
|
-
sh:not [
|
65
|
-
sh:path must:then ;
|
66
|
-
sh:or ( [ sh:class must:TableDataset ]
|
67
|
-
[ sh:class must:EmptyTable ] ) ] .
|
68
|
-
|
69
|
-
must:ConstructTestSpecThenValidationShape
|
70
|
-
a sh:NodeShape ;
|
71
|
-
sh:target [ a sh:SPARQLTarget ;
|
72
|
-
sh:prefixes must: ;
|
73
|
-
sh:select """
|
74
|
-
SELECT ?this
|
75
|
-
WHERE {
|
76
|
-
?this a must:TestSpec .
|
77
|
-
?this must:when/must:queryType must:ConstructSparql .
|
78
|
-
}
|
79
|
-
""" ; ] ;
|
80
|
-
sh:message "Invalid then clause: A tabular data format has been specified for a SPARQL construct test." ;
|
81
|
-
sh:not [
|
82
|
-
sh:path must:then ;
|
83
|
-
sh:or ( [ sh:class must:TableDataset ]
|
84
|
-
[ sh:class must:EmptyTable ] ) ] .
|
85
|
-
|
86
|
-
must:UpdateTestSpecGivenValidationShape
|
87
|
-
a sh:NodeShape ;
|
88
|
-
sh:target [ a sh:SPARQLTarget ;
|
89
|
-
sh:prefixes must: ;
|
90
|
-
sh:select """
|
91
|
-
SELECT ?this
|
92
|
-
WHERE {
|
93
|
-
?this a must:TestSpec .
|
94
|
-
?this must:when/must:queryType must:UpdateSparql .
|
95
|
-
}
|
96
|
-
""" ; ] ; ;
|
97
|
-
sh:message "Invalid given clause: An inherited dataset cannot be specified for a SPARQL update test." ;
|
98
|
-
sh:not [ sh:path must:given ;
|
99
|
-
sh:class must:InheritedDataset ; ] .
|
100
|
-
|
101
|
-
must:SelectTestSpecValidationShape
|
102
|
-
a sh:NodeShape ;
|
103
|
-
sh:target [ a sh:SPARQLTarget ;
|
104
|
-
sh:prefixes must: ;
|
105
|
-
sh:select """
|
106
|
-
SELECT ?this
|
107
|
-
WHERE {
|
108
|
-
?this a must:TestSpec .
|
109
|
-
?this must:when/must:queryType must:SelectSparql .
|
110
|
-
}
|
111
|
-
""" ; ] ;
|
112
|
-
sh:property [ sh:message "Invalid then clause: The result format should be tabular for a SPARQL select test." ;
|
113
|
-
sh:path must:then ;
|
114
|
-
sh:or ( [ sh:class must:TableDataset ]
|
115
|
-
[ sh:class must:EmptyTable ]
|
116
|
-
[ sh:class must:FolderDataset ]
|
117
|
-
[ sh:class must:FileDataset ] ) ] .
|
118
|
-
|
119
|
-
must:StatementsDatasetShape
|
120
|
-
a sh:NodeShape ;
|
121
|
-
sh:targetClass must:StatementsDataset ;
|
122
|
-
sh:property [ sh:path must:hasStatement ;
|
123
|
-
sh:node must:StatementShape ;
|
124
|
-
sh:minCount 1 ; ] .
|
125
|
-
|
126
|
-
must:TableDatasetShape
|
127
|
-
a sh:NodeShape ;
|
128
|
-
sh:targetClass must:TableDataset ;
|
129
|
-
sh:property [ sh:path must:hasRow ;
|
130
|
-
sh:node must:RowShape ;
|
131
|
-
sh:minCount 1 ; ] .
|
132
|
-
|
133
|
-
must:OrderedTableDatasetShape
|
134
|
-
a sh:NodeShape ;
|
135
|
-
sh:targetClass must:OrderedTableDataset ;
|
136
|
-
sh:property [ sh:path must:hasRow ;
|
137
|
-
sh:node must:OrderedRowShape ;
|
138
|
-
sh:minCount 2 ; ] .
|
139
|
-
|
140
|
-
must:FileDatasetShape
|
141
|
-
a sh:NodeShape ;
|
142
|
-
sh:targetClass must:FileDataset ;
|
143
|
-
sh:property [ sh:path must:file ;
|
144
|
-
sh:datatype xsd:string ;
|
145
|
-
sh:minCount 1 ;
|
146
|
-
sh:maxCount 1 ; ] .
|
147
|
-
|
148
|
-
must:StatementShape
|
149
|
-
a sh:NodeShape ;
|
150
|
-
sh:targetClass rdf:Statement ;
|
151
|
-
sh:property [ sh:path rdf:subject ;
|
152
|
-
sh:minCount 1 ; ] ;
|
153
|
-
sh:property [ sh:path rdf:predicate ;
|
154
|
-
sh:minCount 1 ; ] ;
|
155
|
-
sh:property [ sh:path rdf:object ;
|
156
|
-
sh:minCount 1 ; ] .
|
157
|
-
|
158
|
-
must:SparqlSourceShape
|
159
|
-
a sh:NodeShape ;
|
160
|
-
sh:targetClass must:SparqlSource ;
|
161
|
-
sh:property [ sh:path must:queryType ;
|
162
|
-
sh:minCount 1 ;
|
163
|
-
sh:maxCount 1 ; ] .
|
164
|
-
|
165
|
-
must:UpdateSparqlShape
|
166
|
-
a sh:NodeShape ;
|
167
|
-
sh:targetClass must:SparqlSource ;
|
168
|
-
sh:property [ sh:path must:queryType ;
|
169
|
-
sh:targetClass must:UpdateSparql ;
|
170
|
-
sh:minCount 1 ;
|
171
|
-
sh:maxCount 1 ; ] .
|
172
|
-
|
173
|
-
must:SelectSparqlShape
|
174
|
-
a sh:NodeShape ;
|
175
|
-
sh:targetClass must:SparqlSource ;
|
176
|
-
sh:property [ sh:path must:queryType ;
|
177
|
-
sh:targetClass must:SelectSparql ;
|
178
|
-
sh:minCount 1 ;
|
179
|
-
sh:maxCount 1 ; ] .
|
180
|
-
|
181
|
-
must:ConstructSparqlShape
|
182
|
-
a sh:NodeShape ;
|
183
|
-
sh:targetClass must:SparqlSource ;
|
184
|
-
sh:property [ sh:path must:queryType ;
|
185
|
-
sh:targetClass must:ConstructSparql ;
|
186
|
-
sh:minCount 1 ;
|
187
|
-
sh:maxCount 1 ; ] .
|
188
|
-
|
189
|
-
must:TextSparqlSourceShape
|
190
|
-
a sh:NodeShape ;
|
191
|
-
sh:targetClass must:TextSparqlSource ;
|
192
|
-
sh:property [ sh:path must:queryText ;
|
193
|
-
sh:minCount 1 ;
|
194
|
-
sh:maxCount 1 ; ] .
|
195
|
-
|
196
|
-
|
197
|
-
must:VariableBindingShape
|
198
|
-
a sh:NodeShape ;
|
199
|
-
sh:targetClass must:Binding ;
|
200
|
-
sh:property [ sh:path must:variable ;
|
201
|
-
sh:minCount 1 ;
|
202
|
-
sh:maxCount 1 ; ] ;
|
203
|
-
sh:property [ sh:path must:boundValue ;
|
204
|
-
sh:minCount 1 ;
|
205
|
-
sh:maxCount 1 ; ] .
|
206
|
-
|
207
|
-
must:RowShape
|
208
|
-
a sh:NodeShape ;
|
209
|
-
sh:targetClass must:Row ;
|
210
|
-
sh:property [ sh:path must:hasBinding ;
|
211
|
-
sh:node must:VariableBindingShape ;
|
212
|
-
sh:minCount 1 ; ] .
|
213
|
-
|
214
|
-
must:OrderedRowShape
|
215
|
-
a sh:NodeShape ;
|
216
|
-
sh:targetClass must:Row ;
|
217
|
-
sh:property [ sh:path sh:order ;
|
218
|
-
sh:minCount 2 ; ] ;
|
219
|
-
sh:property [ sh:path must:hasBinding ;
|
220
|
-
sh:node must:VariableBindingShape ;
|
221
|
-
sh:minCount 2 ; ] .
|
222
|
-
|
223
|
-
must:AnzoGraphmartStepSparqlSourceShape
|
224
|
-
a sh:NodeShape ;
|
225
|
-
sh:targetClass must:AnzoGraphmartStepSparqlSource ;
|
226
|
-
sh:property [ sh:path must:anzoQueryStep ;
|
227
|
-
sh:message "An Anzo graphmart step sparql source must have one query step." ;
|
228
|
-
sh:minCount 1 ;
|
229
|
-
sh:maxCount 1 ; ] .
|
230
|
-
|
231
|
-
must:AnzoGraphmartLayerSparqlSourceShape
|
232
|
-
a sh:NodeShape ;
|
233
|
-
sh:targetClass must:AnzoGraphmartLayerSparqlSource ;
|
234
|
-
sh:property [ sh:path must:anzoGraphmartLayer ;
|
235
|
-
sh:message "An Anzo graphmart layer sparql source must have one graphmart layer." ;
|
236
|
-
sh:minCount 1 ;
|
237
|
-
sh:maxCount 1 ; ] .
|
238
|
-
|
239
|
-
must:AnzoGraphmartQueryDrivenTemplatedStepSparqlSourceShape
|
240
|
-
a sh:NodeShape ;
|
241
|
-
sh:targetClass must:AnzoGraphmartQueryDrivenTemplatedStepSparqlSource ;
|
242
|
-
sh:property
|
243
|
-
[ sh:path must:anzoQueryStep ;
|
244
|
-
sh:message "An Anzo query driven templated step sparql source must have one query step." ;
|
245
|
-
sh:minCount 1 ;
|
246
|
-
sh:maxCount 1 ; ] ,
|
247
|
-
[ sh:path must:queryType ;
|
248
|
-
sh:message "An Anzo query driven templated step sparql source must have a query type of AnzoQueryDrivenUpdateSparql ." ;
|
249
|
-
sh:minCount 1 ;
|
250
|
-
sh:maxCount 1 ; ] .
|
251
|
-
|
252
|
-
|
253
|
-
|