mustrd 0.1.6__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/mustrdTestPlugin.py +63 -3
- {mustrd-0.1.6.dist-info → mustrd-0.1.7.dist-info}/METADATA +1 -1
- {mustrd-0.1.6.dist-info → mustrd-0.1.7.dist-info}/RECORD +6 -7
- mustrd-0.1.7.dist-info/entry_points.txt +3 -0
- mustrd/plugin.py +0 -87
- mustrd-0.1.6.dist-info/entry_points.txt +0 -3
- {mustrd-0.1.6.dist-info → mustrd-0.1.7.dist-info}/LICENSE +0 -0
- {mustrd-0.1.6.dist-info → mustrd-0.1.7.dist-info}/WHEEL +0 -0
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
|
@@ -124,7 +183,8 @@ class MustrdTestPlugin:
|
|
124
183
|
def get_triple_stores_from_file(self, test_config):
|
125
184
|
if test_config.triplestore_spec_path:
|
126
185
|
try:
|
127
|
-
triple_stores = get_triple_stores(get_triple_store_graph(Path(test_config.triplestore_spec_path),
|
186
|
+
triple_stores = get_triple_stores(get_triple_store_graph(Path(test_config.triplestore_spec_path),
|
187
|
+
self.secrets))
|
128
188
|
except Exception as e:
|
129
189
|
print(f"""No triple store configuration found at {test_config.triplestore_spec_path}.
|
130
190
|
Fall back: only embedded rdflib will be executed""", e)
|
@@ -7,9 +7,8 @@ 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=jVeH-cnB2bZiNGiRXoZMR7fkqMRBEvOdmD1Q4tBkVOE,3785
|
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,87 +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="pathToMdSummary",
|
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="pathToTestConfig",
|
48
|
-
default=None,
|
49
|
-
required=True,
|
50
|
-
help="Ttl file containing the list of test to construct.",
|
51
|
-
)
|
52
|
-
group.addoption(
|
53
|
-
"--secrets",
|
54
|
-
action="store",
|
55
|
-
dest="secrets",
|
56
|
-
metavar="Secrets",
|
57
|
-
default=None,
|
58
|
-
required=False,
|
59
|
-
help="Give the secrets by command line in order to be able to store secrets safely in CI tools",
|
60
|
-
)
|
61
|
-
return
|
62
|
-
|
63
|
-
|
64
|
-
def pytest_configure(config) -> None:
|
65
|
-
|
66
|
-
# Read configuration file
|
67
|
-
test_configs: Dict[str, TestConfig] = defaultdict(lambda: defaultdict(list))
|
68
|
-
config_graph = Graph().parse(config.getoption("configpath"))
|
69
|
-
for test_config_subject in config_graph.subjects(predicate=RDF.type, object=MUST.TestConfig):
|
70
|
-
test_function = get_config_param(config_graph, test_config_subject, MUST.hasTestFunction, str)
|
71
|
-
spec_path = get_config_param(config_graph, test_config_subject, MUST.hasSpecPath, str)
|
72
|
-
data_path = get_config_param(config_graph, test_config_subject, MUST.hasDataPath, str)
|
73
|
-
triplestore_spec_path = get_config_param(config_graph, test_config_subject, MUST.triplestoreSpecPath, str)
|
74
|
-
filter_on_tripleStore = list(config_graph.objects(subject=test_config_subject,
|
75
|
-
predicate=MUST.filterOnTripleStore))
|
76
|
-
|
77
|
-
test_configs[test_function] = TestConfig(test_function=test_function,
|
78
|
-
spec_path=spec_path, data_path=data_path,
|
79
|
-
triplestore_spec_path=triplestore_spec_path,
|
80
|
-
filter_on_tripleStore=filter_on_tripleStore)
|
81
|
-
|
82
|
-
config.pluginmanager.register(MustrdTestPlugin(config.getoption("mdpath"), test_configs, config.getoption("secrets")))
|
83
|
-
|
84
|
-
|
85
|
-
def get_config_param(config_graph, config_subject, config_param, convert_function):
|
86
|
-
raw_value = config_graph.value(subject=config_subject, predicate=config_param, any=True)
|
87
|
-
return convert_function(raw_value) if raw_value else None
|
File without changes
|
File without changes
|