mustrd 0.1.5__py3-none-any.whl → 0.1.7__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/mustrd.py +7 -5
- mustrd/mustrdTestPlugin.py +68 -6
- {mustrd-0.1.5.dist-info → mustrd-0.1.7.dist-info}/METADATA +1 -1
- {mustrd-0.1.5.dist-info → mustrd-0.1.7.dist-info}/RECORD +7 -8
- mustrd-0.1.7.dist-info/entry_points.txt +3 -0
- mustrd/plugin.py +0 -78
- mustrd-0.1.5.dist-info/entry_points.txt +0 -3
- {mustrd-0.1.5.dist-info → mustrd-0.1.7.dist-info}/LICENSE +0 -0
- {mustrd-0.1.5.dist-info → mustrd-0.1.7.dist-info}/WHEEL +0 -0
mustrd/mustrd.py
CHANGED
@@ -381,11 +381,13 @@ def run_spec(spec: Specification) -> SpecResult:
|
|
381
381
|
# if type(mustrd_triple_store) == MustrdAnzo and close_connection:
|
382
382
|
# mustrd_triple_store.clear_graph()
|
383
383
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
384
|
+
def get_triple_store_graph(triple_store_graph_path: Path, secrets: str):
|
385
|
+
if secrets:
|
386
|
+
return Graph().parse(triple_store_graph_path).parse(data = secrets)
|
387
|
+
else:
|
388
|
+
secret_path = triple_store_graph_path.parent / Path(triple_store_graph_path.stem + "_secrets" + triple_store_graph_path.suffix)
|
389
|
+
return Graph().parse(triple_store_graph_path).parse(source = secret_path)
|
390
|
+
|
389
391
|
|
390
392
|
def get_triple_stores(triple_store_graph: Graph) -> list[dict]:
|
391
393
|
triple_stores = []
|
mustrd/mustrdTestPlugin.py
CHANGED
@@ -27,20 +27,79 @@ import pytest
|
|
27
27
|
import os
|
28
28
|
from pathlib import Path
|
29
29
|
from rdflib.namespace import Namespace
|
30
|
-
from rdflib import Graph
|
30
|
+
from rdflib import Graph, RDF
|
31
31
|
from pytest import Session
|
32
32
|
from typing import Dict
|
33
33
|
|
34
34
|
from mustrd.TestResult import ResultList, TestResult, get_result_list
|
35
35
|
from mustrd.utils import get_mustrd_root
|
36
|
-
from mustrd.mustrd import get_triple_store_graph, get_triple_stores
|
36
|
+
from mustrd.mustrd import get_triple_store_graph, get_triple_stores
|
37
|
+
from mustrd.mustrd import SpecSkipped, validate_specs, get_specs, SpecPassed, run_spec
|
37
38
|
from mustrd.namespace import MUST
|
39
|
+
from collections import defaultdict
|
38
40
|
|
39
41
|
spnamespace = Namespace("https://semanticpartners.com/data/test/")
|
40
42
|
|
41
43
|
mustrd_root = get_mustrd_root()
|
42
44
|
|
43
45
|
|
46
|
+
def pytest_addoption(parser):
|
47
|
+
group = parser.getgroup("md summary")
|
48
|
+
group.addoption(
|
49
|
+
"--md",
|
50
|
+
action="store",
|
51
|
+
dest="mdpath",
|
52
|
+
metavar="pathToMdSummary",
|
53
|
+
default=None,
|
54
|
+
help="create md summary file at that path.",
|
55
|
+
)
|
56
|
+
group.addoption(
|
57
|
+
"--config",
|
58
|
+
action="store",
|
59
|
+
dest="configpath",
|
60
|
+
metavar="pathToTestConfig",
|
61
|
+
default=None,
|
62
|
+
required=True,
|
63
|
+
help="Ttl file containing the list of test to construct.",
|
64
|
+
)
|
65
|
+
group.addoption(
|
66
|
+
"--secrets",
|
67
|
+
action="store",
|
68
|
+
dest="secrets",
|
69
|
+
metavar="Secrets",
|
70
|
+
default=None,
|
71
|
+
required=False,
|
72
|
+
help="Give the secrets by command line in order to be able to store secrets safely in CI tools",
|
73
|
+
)
|
74
|
+
return
|
75
|
+
|
76
|
+
|
77
|
+
def pytest_configure(config) -> None:
|
78
|
+
# Read configuration file
|
79
|
+
test_configs: Dict[str, TestConfig] = defaultdict(lambda: defaultdict(list))
|
80
|
+
config_graph = Graph().parse(config.getoption("configpath"))
|
81
|
+
for test_config_subject in config_graph.subjects(predicate=RDF.type, object=MUST.TestConfig):
|
82
|
+
test_function = get_config_param(config_graph, test_config_subject, MUST.hasTestFunction, str)
|
83
|
+
spec_path = get_config_param(config_graph, test_config_subject, MUST.hasSpecPath, str)
|
84
|
+
data_path = get_config_param(config_graph, test_config_subject, MUST.hasDataPath, str)
|
85
|
+
triplestore_spec_path = get_config_param(config_graph, test_config_subject, MUST.triplestoreSpecPath, str)
|
86
|
+
filter_on_tripleStore = list(config_graph.objects(subject=test_config_subject,
|
87
|
+
predicate=MUST.filterOnTripleStore))
|
88
|
+
|
89
|
+
test_configs[test_function] = TestConfig(test_function=test_function,
|
90
|
+
spec_path=spec_path, data_path=data_path,
|
91
|
+
triplestore_spec_path=triplestore_spec_path,
|
92
|
+
filter_on_tripleStore=filter_on_tripleStore)
|
93
|
+
|
94
|
+
config.pluginmanager.register(MustrdTestPlugin(config.getoption("mdpath"),
|
95
|
+
test_configs, config.getoption("secrets")))
|
96
|
+
|
97
|
+
|
98
|
+
def get_config_param(config_graph, config_subject, config_param, convert_function):
|
99
|
+
raw_value = config_graph.value(subject=config_subject, predicate=config_param, any=True)
|
100
|
+
return convert_function(raw_value) if raw_value else None
|
101
|
+
|
102
|
+
|
44
103
|
@dataclass
|
45
104
|
class TestConfig:
|
46
105
|
test_function: str
|
@@ -61,10 +120,12 @@ class TestConfig:
|
|
61
120
|
class MustrdTestPlugin:
|
62
121
|
md_path: str
|
63
122
|
test_configs: Dict[str, TestConfig]
|
123
|
+
secrets: str
|
64
124
|
|
65
|
-
def __init__(self, md_path, test_configs):
|
125
|
+
def __init__(self, md_path, test_configs, secrets):
|
66
126
|
self.md_path = md_path
|
67
127
|
self.test_configs = test_configs
|
128
|
+
self.secrets = secrets
|
68
129
|
|
69
130
|
# Hook called at collection time: reads the configuration of the tests, and generate pytests from it
|
70
131
|
def pytest_generate_tests(self, metafunc):
|
@@ -122,10 +183,11 @@ class MustrdTestPlugin:
|
|
122
183
|
def get_triple_stores_from_file(self, test_config):
|
123
184
|
if test_config.triplestore_spec_path:
|
124
185
|
try:
|
125
|
-
triple_stores = get_triple_stores(get_triple_store_graph(Path(test_config.triplestore_spec_path)
|
126
|
-
|
186
|
+
triple_stores = get_triple_stores(get_triple_store_graph(Path(test_config.triplestore_spec_path),
|
187
|
+
self.secrets))
|
188
|
+
except Exception as e:
|
127
189
|
print(f"""No triple store configuration found at {test_config.triplestore_spec_path}.
|
128
|
-
Fall back: only embedded rdflib will be executed""")
|
190
|
+
Fall back: only embedded rdflib will be executed""", e)
|
129
191
|
triple_stores = [{'type': MUST.RdfLib}]
|
130
192
|
else:
|
131
193
|
print("No triple store configuration required: using embedded rdflib")
|
@@ -3,13 +3,12 @@ mustrd/logger_setup.py,sha256=AXTXiiyQ4E_SyqNaKlLsZlkkKr_YJfJZ0N4PEoN7d7E,1630
|
|
3
3
|
mustrd/model/mustrdShapes.ttl,sha256=BR-9fAwGpQt6glfPpDB0Xx3vFXMt_UTQwi469o6aWUo,9709
|
4
4
|
mustrd/model/ontology.ttl,sha256=6xhmOF02gjP4nlOh6rnF5EWCaxWOdexQFn8YndGebck,17226
|
5
5
|
mustrd/model/test-resources/resources.ttl,sha256=7z1P4qJwuqRdmHzKd_mhnUIs-aQoSQxas7yDCwKYarc,1558
|
6
|
-
mustrd/mustrd.py,sha256=
|
6
|
+
mustrd/mustrd.py,sha256=kAudCpk7NLoS2Y555l5Q2jhKbxR-D_sSPLa0Z3yP42w,34109
|
7
7
|
mustrd/mustrdAnzo.py,sha256=bQ-IHCnsEK7paJ31GgS9IH3hGd4o_5zeNrpn0Sb8WIk,11822
|
8
8
|
mustrd/mustrdGraphDb.py,sha256=KNXXYyZjYm_IZaeuuxlPBP-XyX9hZ5UvrdxshKnZhwo,5599
|
9
9
|
mustrd/mustrdRdfLib.py,sha256=LeS-uArlxQwsM-7lrJyp8O8m-6VgxsR1BlpxsOCNePs,2129
|
10
|
-
mustrd/mustrdTestPlugin.py,sha256=
|
10
|
+
mustrd/mustrdTestPlugin.py,sha256=k7osmdgMIoHbVryrKxBqeDXYsE84Q_D5E2HEGhcOaSs,11784
|
11
11
|
mustrd/namespace.py,sha256=pCvLXkD_n_tS23oIizO52ylVwXGC1xFP8cHx4Mml0Ro,3326
|
12
|
-
mustrd/plugin.py,sha256=cERUX7KFCoq9dF1AgWuVpnTCoBlpRcKMN5D5M-W3fME,3450
|
13
12
|
mustrd/README.adoc,sha256=DwXeoMy2yMgAoLvyjZHp3HQW8NBIn8wCSaNo1ixHvFo,11803
|
14
13
|
mustrd/run.py,sha256=Ez00qZrl0Qb7P374miD8hEVucRKt_PYWdr4aorigltg,4366
|
15
14
|
mustrd/spec_component.py,sha256=l2CP8dszFENDkUsMIC065KNMeU8tNPPMMfCyQ4a1gHc,32487
|
@@ -19,8 +18,8 @@ mustrd/templates/md_ResultList_template.jinja,sha256=RrTaPN1obsTEpG5BjQp7BV9iBFz
|
|
19
18
|
mustrd/templates/md_stats_template.jinja,sha256=DlNfH9eoEFVHQmvp6QNbQv36cqRLyBkqG1ITOHb_Yu8,157
|
20
19
|
mustrd/TestResult.py,sha256=q5BnvRxhfCEEY062rHasnA61AeKR4oXXs5z8lASvx1o,4986
|
21
20
|
mustrd/utils.py,sha256=fuvdLE20MdkJtY5atBiU8-u7sVcq1mzIYF0gTcw1UMk,1424
|
22
|
-
mustrd-0.1.
|
23
|
-
mustrd-0.1.
|
24
|
-
mustrd-0.1.
|
25
|
-
mustrd-0.1.
|
26
|
-
mustrd-0.1.
|
21
|
+
mustrd-0.1.7.dist-info/entry_points.txt,sha256=v7V7sN0_L1aB4Ug_9io5axlQSeJ1C0tNrQWwdXdV58s,50
|
22
|
+
mustrd-0.1.7.dist-info/LICENSE,sha256=OwjAcbL4HsENdMen1iYR23HH7OEn899oCt100xUo0Zo,1099
|
23
|
+
mustrd-0.1.7.dist-info/METADATA,sha256=wHFv9uJO64la0-lEtXel4KusPEvXTDPqLyQdHtLX5vk,4130
|
24
|
+
mustrd-0.1.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
25
|
+
mustrd-0.1.7.dist-info/RECORD,,
|
mustrd/plugin.py
DELETED
@@ -1,78 +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 Dict
|
26
|
-
from .mustrdTestPlugin import MustrdTestPlugin, TestConfig
|
27
|
-
from rdflib import RDF, Graph
|
28
|
-
from .namespace import MUST
|
29
|
-
from collections import defaultdict
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
def pytest_addoption(parser):
|
34
|
-
group = parser.getgroup("md summary")
|
35
|
-
group.addoption(
|
36
|
-
"--md",
|
37
|
-
action="store",
|
38
|
-
dest="mdpath",
|
39
|
-
metavar="path",
|
40
|
-
default=None,
|
41
|
-
help="create md summary file at that path.",
|
42
|
-
)
|
43
|
-
group.addoption(
|
44
|
-
"--config",
|
45
|
-
action="store",
|
46
|
-
dest="configpath",
|
47
|
-
metavar="path",
|
48
|
-
default=None,
|
49
|
-
required=True,
|
50
|
-
help="Ttl file containing the list of test to construct.",
|
51
|
-
)
|
52
|
-
return
|
53
|
-
|
54
|
-
|
55
|
-
def pytest_configure(config) -> None:
|
56
|
-
|
57
|
-
# Read configuration file
|
58
|
-
test_configs: Dict[str, TestConfig] = defaultdict(lambda: defaultdict(list))
|
59
|
-
config_graph = Graph().parse(config.getoption("configpath"))
|
60
|
-
for test_config_subject in config_graph.subjects(predicate=RDF.type, object=MUST.TestConfig):
|
61
|
-
test_function = get_config_param(config_graph, test_config_subject, MUST.hasTestFunction, str)
|
62
|
-
spec_path = get_config_param(config_graph, test_config_subject, MUST.hasSpecPath, str)
|
63
|
-
data_path = get_config_param(config_graph, test_config_subject, MUST.hasDataPath, str)
|
64
|
-
triplestore_spec_path = get_config_param(config_graph, test_config_subject, MUST.triplestoreSpecPath, str)
|
65
|
-
filter_on_tripleStore = list(config_graph.objects(subject=test_config_subject,
|
66
|
-
predicate=MUST.filterOnTripleStore))
|
67
|
-
|
68
|
-
test_configs[test_function] = TestConfig(test_function=test_function,
|
69
|
-
spec_path=spec_path, data_path=data_path,
|
70
|
-
triplestore_spec_path=triplestore_spec_path,
|
71
|
-
filter_on_tripleStore=filter_on_tripleStore)
|
72
|
-
|
73
|
-
config.pluginmanager.register(MustrdTestPlugin(config.getoption("mdpath"), test_configs))
|
74
|
-
|
75
|
-
|
76
|
-
def get_config_param(config_graph, config_subject, config_param, convert_function):
|
77
|
-
raw_value = config_graph.value(subject=config_subject, predicate=config_param, any=True)
|
78
|
-
return convert_function(raw_value) if raw_value else None
|
File without changes
|
File without changes
|