mustrd 0.2.0__py3-none-any.whl → 0.2.1__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 +210 -210
- mustrd/TestResult.py +136 -136
- mustrd/logger_setup.py +48 -48
- mustrd/model/catalog-v001.xml +5 -5
- mustrd/model/mustrdShapes.ttl +253 -253
- mustrd/model/mustrdTestShapes.ttl +24 -24
- mustrd/model/ontology.ttl +494 -494
- mustrd/model/test-resources/resources.ttl +60 -60
- mustrd/model/triplestoreOntology.ttl +174 -174
- mustrd/model/triplestoreshapes.ttl +41 -41
- mustrd/mustrd.py +787 -787
- mustrd/mustrdAnzo.py +236 -220
- mustrd/mustrdGraphDb.py +125 -125
- mustrd/mustrdRdfLib.py +56 -56
- mustrd/mustrdTestPlugin.py +327 -328
- mustrd/namespace.py +125 -125
- mustrd/run.py +106 -106
- mustrd/spec_component.py +690 -690
- mustrd/steprunner.py +166 -166
- mustrd/templates/md_ResultList_leaf_template.jinja +18 -18
- mustrd/templates/md_ResultList_template.jinja +8 -8
- mustrd/templates/md_stats_template.jinja +2 -2
- mustrd/test/test_mustrd.py +4 -4
- mustrd/utils.py +38 -38
- {mustrd-0.2.0.dist-info → mustrd-0.2.1.dist-info}/LICENSE +21 -21
- {mustrd-0.2.0.dist-info → mustrd-0.2.1.dist-info}/METADATA +4 -2
- mustrd-0.2.1.dist-info/RECORD +31 -0
- mustrd/mustrdQueryProcessor.py +0 -136
- mustrd-0.2.0.dist-info/RECORD +0 -32
- {mustrd-0.2.0.dist-info → mustrd-0.2.1.dist-info}/WHEEL +0 -0
- {mustrd-0.2.0.dist-info → mustrd-0.2.1.dist-info}/entry_points.txt +0 -0
mustrd/TestResult.py
CHANGED
@@ -1,136 +1,136 @@
|
|
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)
|
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/logger_setup.py
CHANGED
@@ -1,48 +1,48 @@
|
|
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 logging
|
26
|
-
import sys
|
27
|
-
from colorlog import ColoredFormatter
|
28
|
-
|
29
|
-
|
30
|
-
LOG_LEVEL = logging.INFO
|
31
|
-
LOG_FORMAT = '%(log_color)s%(levelname)s:%(name)s:%(white)s%(message)s'
|
32
|
-
|
33
|
-
|
34
|
-
def setup_logger(name: str) -> logging.Logger:
|
35
|
-
log = logging.getLogger(name)
|
36
|
-
log.setLevel(LOG_LEVEL)
|
37
|
-
|
38
|
-
ch = logging.StreamHandler(sys.stdout)
|
39
|
-
ch.setLevel(LOG_LEVEL)
|
40
|
-
ch.setFormatter(ColoredFormatter(LOG_FORMAT))
|
41
|
-
log.addHandler(ch)
|
42
|
-
|
43
|
-
return log
|
44
|
-
|
45
|
-
|
46
|
-
def flush():
|
47
|
-
logging.shutdown()
|
48
|
-
sys.stdout.flush()
|
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 logging
|
26
|
+
import sys
|
27
|
+
from colorlog import ColoredFormatter
|
28
|
+
|
29
|
+
|
30
|
+
LOG_LEVEL = logging.INFO
|
31
|
+
LOG_FORMAT = '%(log_color)s%(levelname)s:%(name)s:%(white)s%(message)s'
|
32
|
+
|
33
|
+
|
34
|
+
def setup_logger(name: str) -> logging.Logger:
|
35
|
+
log = logging.getLogger(name)
|
36
|
+
log.setLevel(LOG_LEVEL)
|
37
|
+
|
38
|
+
ch = logging.StreamHandler(sys.stdout)
|
39
|
+
ch.setLevel(LOG_LEVEL)
|
40
|
+
ch.setFormatter(ColoredFormatter(LOG_FORMAT))
|
41
|
+
log.addHandler(ch)
|
42
|
+
|
43
|
+
return log
|
44
|
+
|
45
|
+
|
46
|
+
def flush():
|
47
|
+
logging.shutdown()
|
48
|
+
sys.stdout.flush()
|
mustrd/model/catalog-v001.xml
CHANGED
@@ -1,5 +1,5 @@
|
|
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>
|
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>
|