codecraftai-testbase 1.3.0__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.
- ccai/factories/py.typed +0 -0
- ccai/factories/testbasedefaulttypefactory.py +25 -0
- ccai/testbase/__init__.py +63 -0
- ccai/testbase/breakpoints.py +110 -0
- ccai/testbase/cli/__init__.py +13 -0
- ccai/testbase/cli/cmdtree/agents/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/agents/config/__init__.py +24 -0
- ccai/testbase/cli/cmdtree/agents/config/extract.py +94 -0
- ccai/testbase/cli/cmdtree/agents/formatting.py +71 -0
- ccai/testbase/cli/cmdtree/agents/jsosparser.py +119 -0
- ccai/testbase/cli/cmdtree/agents/pathresolver.py +34 -0
- ccai/testbase/cli/cmdtree/agents/summary/__init__.py +26 -0
- ccai/testbase/cli/cmdtree/agents/summary/compare.py +128 -0
- ccai/testbase/cli/cmdtree/agents/summary/extract.py +91 -0
- ccai/testbase/cli/cmdtree/agents/testresult/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/agents/testresult/extract.py +77 -0
- ccai/testbase/cli/cmdtree/agents/testresult/failures.py +73 -0
- ccai/testbase/cli/cmdtree/agents/testresult/list.py +63 -0
- ccai/testbase/cli/cmdtree/services/__init__.py +27 -0
- ccai/testbase/cli/cmdtree/services/results.py +66 -0
- ccai/testbase/cli/cmdtree/testing/__init__.py +30 -0
- ccai/testbase/cli/cmdtree/testing/jobs.py +175 -0
- ccai/testbase/cli/cmdtree/testing/query.py +131 -0
- ccai/testbase/cli/cmdtree/testing/run.py +263 -0
- ccai/testbase/cli/cmdtree/utilities/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/utilities/timestamp.py +33 -0
- ccai/testbase/cli/options.py +370 -0
- ccai/testbase/cli/testbase_command.py +64 -0
- ccai/testbase/cli/utilities.py +31 -0
- ccai/testbase/configuration.py +324 -0
- ccai/testbase/constraints.py +998 -0
- ccai/testbase/coupling/__init__.py +569 -0
- ccai/testbase/coupling/basecoupling.py +69 -0
- ccai/testbase/coupling/configurationcoupling.py +138 -0
- ccai/testbase/coupling/integrationcoupling.py +842 -0
- ccai/testbase/coupling/validatorcoupling.py +127 -0
- ccai/testbase/debuggingext.py +281 -0
- ccai/testbase/debuglogging.py +407 -0
- ccai/testbase/debugports.py +469 -0
- ccai/testbase/declaration/__init__.py +13 -0
- ccai/testbase/declaration/attachments.py +222 -0
- ccai/testbase/declaration/originations.py +217 -0
- ccai/testbase/declaration/parameterization.py +160 -0
- ccai/testbase/declaration/registrations.py +476 -0
- ccai/testbase/diagnostic_level.py +197 -0
- ccai/testbase/diagnostic_streaming.py +1534 -0
- ccai/testbase/diagnostics.py +1685 -0
- ccai/testbase/entrypoints.py +485 -0
- ccai/testbase/environment.py +162 -0
- ccai/testbase/errors/testruntimeouterror.py +50 -0
- ccai/testbase/expressions.py +355 -0
- ccai/testbase/factories.py +277 -0
- ccai/testbase/factoryprotocols.py +35 -0
- ccai/testbase/features.py +913 -0
- ccai/testbase/initialize.py +210 -0
- ccai/testbase/injection/__init__.py +25 -0
- ccai/testbase/injection/injectiongroup.py +493 -0
- ccai/testbase/injection/injectionmoment.py +155 -0
- ccai/testbase/injection/injectionregistry.py +823 -0
- ccai/testbase/injection/injectionscope.py +2589 -0
- ccai/testbase/injection/introspection.py +514 -0
- ccai/testbase/markers.py +665 -0
- ccai/testbase/mocking.py +4856 -0
- ccai/testbase/origins/__init__.py +13 -0
- ccai/testbase/origins/resourceorigin.py +110 -0
- ccai/testbase/origins/validatororigin.py +111 -0
- ccai/testbase/output/__init__.py +17 -0
- ccai/testbase/output/outputcontext.py +201 -0
- ccai/testbase/output/runmetadata.py +184 -0
- ccai/testbase/properties/__init__.py +40 -0
- ccai/testbase/properties/assumptions.py +56 -0
- ccai/testbase/properties/decorators.py +173 -0
- ccai/testbase/properties/propertyrunner.py +449 -0
- ccai/testbase/properties/strategies.py +1592 -0
- ccai/testbase/properties/unittestsupport.py +87 -0
- ccai/testbase/py.typed +0 -0
- ccai/testbase/queries.py +95 -0
- ccai/testbase/resourcelifespan.py +24 -0
- ccai/testbase/results/__init__.py +35 -0
- ccai/testbase/results/exceptions.py +60 -0
- ccai/testbase/results/filtering/__init__.py +26 -0
- ccai/testbase/results/filtering/resultfilter.py +570 -0
- ccai/testbase/results/model/__init__.py +32 -0
- ccai/testbase/results/model/buildinfo.py +54 -0
- ccai/testbase/results/model/checkresult.py +183 -0
- ccai/testbase/results/model/forwardinginfo.py +30 -0
- ccai/testbase/results/model/jobcontainer.py +32 -0
- ccai/testbase/results/model/jobinfo.py +91 -0
- ccai/testbase/results/model/nestedprogressinfo.py +211 -0
- ccai/testbase/results/model/pipelineinfo.py +51 -0
- ccai/testbase/results/model/progressaggregator.py +551 -0
- ccai/testbase/results/model/progresscode.py +29 -0
- ccai/testbase/results/model/progressdelivery.py +51 -0
- ccai/testbase/results/model/progressinfo.py +84 -0
- ccai/testbase/results/model/progresstype.py +24 -0
- ccai/testbase/results/model/renderinfo.py +30 -0
- ccai/testbase/results/model/resultcode.py +28 -0
- ccai/testbase/results/model/resultcontainer.py +95 -0
- ccai/testbase/results/model/resultnode.py +258 -0
- ccai/testbase/results/model/resulttype.py +34 -0
- ccai/testbase/results/model/streaminginfo.py +111 -0
- ccai/testbase/results/model/taskinggroup.py +85 -0
- ccai/testbase/results/model/taskingresult.py +297 -0
- ccai/testbase/results/model/testcontainer.py +35 -0
- ccai/testbase/results/model/testresult.py +170 -0
- ccai/testbase/results/recorders/__init__.py +31 -0
- ccai/testbase/results/recorders/csvresultrecorder.py +414 -0
- ccai/testbase/results/recorders/jsonresultrecorder.py +467 -0
- ccai/testbase/results/recorders/resultrecorder.py +1472 -0
- ccai/testbase/results/recorders/stdoutresultrecorder.py +70 -0
- ccai/testbase/results/recorders/xmlresultrecorder.py +305 -0
- ccai/testbase/results/utilities.py +141 -0
- ccai/testbase/sequencing/__init__.py +13 -0
- ccai/testbase/sequencing/sequencermodulescope.py +96 -0
- ccai/testbase/sequencing/sequencerscopebase.py +91 -0
- ccai/testbase/sequencing/sequencersessionscope.py +84 -0
- ccai/testbase/sequencing/sequencertestscope.py +249 -0
- ccai/testbase/sequencing/sequencertestsetupscope.py +86 -0
- ccai/testbase/sequencing/testactivity.py +111 -0
- ccai/testbase/sequencing/testsequencer.py +3072 -0
- ccai/testbase/server/__init__.py +13 -0
- ccai/testbase/server/resultserver.py +599 -0
- ccai/testbase/sources/__init__.py +13 -0
- ccai/testbase/sources/configurationsource.py +32 -0
- ccai/testbase/sources/integrationsource.py +29 -0
- ccai/testbase/sources/resourcesource.py +27 -0
- ccai/testbase/sources/sourcebase.py +71 -0
- ccai/testbase/sources/unknownsource.py +30 -0
- ccai/testbase/sources/validatorsource.py +28 -0
- ccai/testbase/tandem/__init__.py +13 -0
- ccai/testbase/tandem/validators.py +286 -0
- ccai/testbase/testcollector.py +230 -0
- ccai/testbase/testgroup.py +54 -0
- ccai/testbase/testjob.py +600 -0
- ccai/testbase/testref.py +64 -0
- ccai/testbase/utilities.py +472 -0
- ccai/testbase/verification.py +768 -0
- codecraftai_testbase-1.3.0.dist-info/METADATA +99 -0
- codecraftai_testbase-1.3.0.dist-info/RECORD +142 -0
- codecraftai_testbase-1.3.0.dist-info/WHEEL +4 -0
- codecraftai_testbase-1.3.0.dist-info/entry_points.txt +3 -0
- codecraftai_testbase-1.3.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.taskinggroup
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for taskinggroup.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__author__ = "Myron Walker"
|
|
12
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
13
|
+
__credits__ = []
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
import collections
|
|
18
|
+
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
|
|
21
|
+
from ccai.testbase.results.model.resulttype import ResultType
|
|
22
|
+
from ccai.testbase.results.model.resultcontainer import ResultContainer
|
|
23
|
+
|
|
24
|
+
from ccai.xmodules.xdatetime import format_datetime_with_fractional
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TaskingGroup(ResultContainer):
|
|
28
|
+
"""
|
|
29
|
+
The :class:`TaskingGroup` instances are group nodes that are used to link result nodes in the
|
|
30
|
+
result tree. The :class:`TaskingGroup` nodes do not contain result data but link data so the data can
|
|
31
|
+
be computed on demand.
|
|
32
|
+
"""
|
|
33
|
+
def __init__(self, inst_id: str, name: str, parent_inst: str):
|
|
34
|
+
"""
|
|
35
|
+
Creates an instance of a result group.
|
|
36
|
+
|
|
37
|
+
:param inst_id: The unique identifier to link this result group with its children.
|
|
38
|
+
:param name: The name of the result group.
|
|
39
|
+
:param parent_inst: The unique identifier fo this result nodes parent.
|
|
40
|
+
"""
|
|
41
|
+
super().__init__(inst_id, name, ResultType.TASKING_GROUP, parent_inst=parent_inst)
|
|
42
|
+
|
|
43
|
+
self._start = datetime.now()
|
|
44
|
+
self._stop = None
|
|
45
|
+
return
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def start(self):
|
|
49
|
+
"""
|
|
50
|
+
The start timestamp of the tasking group.
|
|
51
|
+
"""
|
|
52
|
+
return self._start
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def stop(self):
|
|
56
|
+
"""
|
|
57
|
+
The stop timestamp of the tasking group.
|
|
58
|
+
"""
|
|
59
|
+
return self._stop
|
|
60
|
+
|
|
61
|
+
def finalize(self):
|
|
62
|
+
self._stop = datetime.now()
|
|
63
|
+
return
|
|
64
|
+
|
|
65
|
+
def as_dict(self, is_preview: bool = False) -> collections.OrderedDict:
|
|
66
|
+
"""
|
|
67
|
+
Converts the result group instance to an :class:`collections.OrderedDict` object.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
start_datetime = format_datetime_with_fractional(self._start)
|
|
71
|
+
|
|
72
|
+
stop_datetime = ""
|
|
73
|
+
if self._stop is not None:
|
|
74
|
+
stop_datetime = format_datetime_with_fractional(self._stop)
|
|
75
|
+
|
|
76
|
+
rcinfo = collections.OrderedDict([
|
|
77
|
+
("name", self._name),
|
|
78
|
+
("instance", self._inst_id),
|
|
79
|
+
("parent", self._parent_inst),
|
|
80
|
+
("rtype", self._result_type.name),
|
|
81
|
+
("start", start_datetime),
|
|
82
|
+
('stop', stop_datetime)
|
|
83
|
+
])
|
|
84
|
+
|
|
85
|
+
return rcinfo
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.taskingresult
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for taskingresult.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__author__ = "Myron Walker"
|
|
12
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
13
|
+
__credits__ = []
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
from typing import Any, List, Optional, Protocol
|
|
18
|
+
|
|
19
|
+
import collections
|
|
20
|
+
import os
|
|
21
|
+
|
|
22
|
+
from dataclasses import asdict as dataclass_as_dict
|
|
23
|
+
|
|
24
|
+
from ccai.errors.exceptions import (
|
|
25
|
+
TaskingGroupAssertionError,
|
|
26
|
+
TaskingGroupRuntimeError
|
|
27
|
+
)
|
|
28
|
+
from ccai.errors.xtraceback import (
|
|
29
|
+
format_traceback_detail
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
from ccai.xmodules.xdatetime import format_datetime_with_fractional
|
|
34
|
+
from ccai.xmodules.xformatting import indent_lines_list
|
|
35
|
+
|
|
36
|
+
from ccai.testbase.results.model.resultcode import ResultCode
|
|
37
|
+
from ccai.testbase.results.model.resultnode import ResultNode
|
|
38
|
+
from ccai.testbase.results.model.resulttype import ResultType
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class TaskingResult(ResultNode):
|
|
42
|
+
"""
|
|
43
|
+
The :class:`TaskingResult` object marks a task node that contains results from a task, test or step in a result tree. The
|
|
44
|
+
result trees only store results that contain task data not associated with the hierarchy of the results. The result tree
|
|
45
|
+
does not contain results that can be computed by analyzing the relationship of the nodes in the tree. The nodes that are
|
|
46
|
+
computed are :class:`TaskingGroup` instances and do not contain instance task data.
|
|
47
|
+
"""
|
|
48
|
+
def __init__(self, inst_id: str, name: str, parent_inst: str, worker: str, rvalue: Optional[Any] = None,
|
|
49
|
+
result_code: ResultCode = ResultCode.UNSET, prefix: str="tasking"):
|
|
50
|
+
"""
|
|
51
|
+
Initializes an instance of a :class:`ResultNode` object that represent the information associated with
|
|
52
|
+
a specific result in a result tree.
|
|
53
|
+
|
|
54
|
+
:param inst_id: The unique identifier for this task node.
|
|
55
|
+
:param name: The name of the result container.
|
|
56
|
+
:param parent_inst: The unique identifier fo this result nodes parent.
|
|
57
|
+
:param worker: The name or host of the work machine that performed the tasking.
|
|
58
|
+
:param rvalue: An optional value to return for the tasking.
|
|
59
|
+
:param result_code: The result code to initialize the result node to.
|
|
60
|
+
:param prefix: A prefix for the tasking output folder.
|
|
61
|
+
"""
|
|
62
|
+
super().__init__(inst_id, name, parent_inst, ResultType.TASKING, result_code=result_code)
|
|
63
|
+
|
|
64
|
+
self._worker = worker
|
|
65
|
+
self._prefix = prefix
|
|
66
|
+
self._rvalue = None
|
|
67
|
+
return
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def prefix(self):
|
|
71
|
+
"""
|
|
72
|
+
The prefix that will be used for the tasking output folder.
|
|
73
|
+
"""
|
|
74
|
+
return self._prefix
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def rvalue(self):
|
|
78
|
+
"""
|
|
79
|
+
A value returned by the remote tasking.
|
|
80
|
+
"""
|
|
81
|
+
return self._rvalue
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def worker(self):
|
|
85
|
+
"""
|
|
86
|
+
The worker that will be used to execute the tasking.
|
|
87
|
+
"""
|
|
88
|
+
return self._worker
|
|
89
|
+
|
|
90
|
+
def add_return_value(self, rvalue: Any):
|
|
91
|
+
"""
|
|
92
|
+
Add a result to this tasking result.
|
|
93
|
+
"""
|
|
94
|
+
self._rvalue = rvalue
|
|
95
|
+
return
|
|
96
|
+
|
|
97
|
+
def as_dict(self, is_preview: bool = False) -> collections.OrderedDict:
|
|
98
|
+
"""
|
|
99
|
+
Converts the result node instance to an :class:`collections.OrderedDict` object.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
start_datetime = format_datetime_with_fractional(self._start)
|
|
103
|
+
|
|
104
|
+
stop_datetime = ""
|
|
105
|
+
if self._stop is not None:
|
|
106
|
+
stop_datetime = format_datetime_with_fractional(self._stop)
|
|
107
|
+
|
|
108
|
+
rninfo = collections.OrderedDict([
|
|
109
|
+
("name", self._name),
|
|
110
|
+
("instance", self._inst_id),
|
|
111
|
+
("parent", self._parent_inst),
|
|
112
|
+
("rtype", self._result_type.name),
|
|
113
|
+
("result", self._result_code.name),
|
|
114
|
+
("prefix", self._prefix),
|
|
115
|
+
("worker", self._worker),
|
|
116
|
+
("start", start_datetime),
|
|
117
|
+
("stop", stop_datetime)
|
|
118
|
+
])
|
|
119
|
+
|
|
120
|
+
if hasattr(self._rvalue, "as_dict"):
|
|
121
|
+
rninfo["rvalue"] = self._rvalue.as_dict()
|
|
122
|
+
else:
|
|
123
|
+
rninfo["rvalue"] = self._rvalue
|
|
124
|
+
|
|
125
|
+
if not is_preview:
|
|
126
|
+
|
|
127
|
+
errors = [dataclass_as_dict(e) for e in self._errors]
|
|
128
|
+
failures = [dataclass_as_dict(f) for f in self._failures]
|
|
129
|
+
|
|
130
|
+
detail_items = [
|
|
131
|
+
("errors", errors),
|
|
132
|
+
("failures", failures),
|
|
133
|
+
("warnings", self._warnings)
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
detail = collections.OrderedDict(detail_items)
|
|
137
|
+
|
|
138
|
+
if self._docstr is not None:
|
|
139
|
+
detail["documentation"] = self._docstr
|
|
140
|
+
|
|
141
|
+
rninfo["detail"] = detail
|
|
142
|
+
|
|
143
|
+
return rninfo
|
|
144
|
+
|
|
145
|
+
def format_result(self) -> List[str]:
|
|
146
|
+
|
|
147
|
+
fmt_lines = default_tasking_result_formatter(self)
|
|
148
|
+
|
|
149
|
+
return fmt_lines
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class TaskingResultFormatter(Protocol):
|
|
153
|
+
"""
|
|
154
|
+
Callable protocol for formatting :class:`TaskingResult` objects.
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
def __call__(self, result: TaskingResult) -> List[str]:
|
|
158
|
+
"""
|
|
159
|
+
Formats a tasking result into a list of output lines.
|
|
160
|
+
|
|
161
|
+
:param result: The tasking result to format.
|
|
162
|
+
|
|
163
|
+
:returns: The formatted lines.
|
|
164
|
+
"""
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def default_tasking_result_formatter(result: TaskingResult) -> List[str]:
|
|
168
|
+
|
|
169
|
+
start_datetime = format_datetime_with_fractional(result.start)
|
|
170
|
+
|
|
171
|
+
stop_datetime = ""
|
|
172
|
+
if result.stop is not None:
|
|
173
|
+
stop_datetime = format_datetime_with_fractional(result.stop)
|
|
174
|
+
|
|
175
|
+
task_lines = [
|
|
176
|
+
f"Task - {result.name} ({result.worker})",
|
|
177
|
+
f"instance: {result.inst_id}",
|
|
178
|
+
f"parent: {result.parent_inst}",
|
|
179
|
+
f"rtype: {result.result_type.name}",
|
|
180
|
+
f"result: {result.result_code.name}",
|
|
181
|
+
f"start: {start_datetime}",
|
|
182
|
+
f"stop: {stop_datetime}",
|
|
183
|
+
f"ERRORS:"
|
|
184
|
+
]
|
|
185
|
+
|
|
186
|
+
error_lines = []
|
|
187
|
+
for item in result.errors:
|
|
188
|
+
error_lines.extend(format_traceback_detail(item))
|
|
189
|
+
error_lines.append("")
|
|
190
|
+
|
|
191
|
+
error_lines = indent_lines_list(error_lines, level=1)
|
|
192
|
+
|
|
193
|
+
task_lines.extend(error_lines)
|
|
194
|
+
|
|
195
|
+
task_lines.append("FAILURES:")
|
|
196
|
+
|
|
197
|
+
failure_lines = []
|
|
198
|
+
for item in result.failures:
|
|
199
|
+
failure_lines.extend(format_traceback_detail(item))
|
|
200
|
+
failure_lines.append("")
|
|
201
|
+
|
|
202
|
+
failure_lines = indent_lines_list(failure_lines, level=1)
|
|
203
|
+
|
|
204
|
+
task_lines.extend(failure_lines)
|
|
205
|
+
|
|
206
|
+
return task_lines
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def verify_tasking_results(results: List[TaskingResult], context_message: str, group_name: Optional[str] = None,
|
|
210
|
+
result_formatter: TaskingResultFormatter = default_tasking_result_formatter):
|
|
211
|
+
|
|
212
|
+
unknown_taskings = []
|
|
213
|
+
cancelled_taskings = []
|
|
214
|
+
errored_taskings = []
|
|
215
|
+
failed_taskings = []
|
|
216
|
+
passed_taskings = []
|
|
217
|
+
|
|
218
|
+
res: TaskingResult
|
|
219
|
+
|
|
220
|
+
for res in results:
|
|
221
|
+
if res.result_code == ResultCode.PASSED:
|
|
222
|
+
if len(res.errors) > 0 or len(res.failures) > 0:
|
|
223
|
+
raise RuntimeError("We should never have an exception and a result code of 0.")
|
|
224
|
+
|
|
225
|
+
passed_taskings.append(res)
|
|
226
|
+
elif res.result_code == ResultCode.ERRORED:
|
|
227
|
+
errored_taskings.append(res)
|
|
228
|
+
elif res.result_code == ResultCode.FAILED:
|
|
229
|
+
failed_taskings.append(res)
|
|
230
|
+
elif res.result_code == ResultCode.CANCELLED:
|
|
231
|
+
cancelled_taskings.append(res)
|
|
232
|
+
else:
|
|
233
|
+
unknown_taskings.append(res)
|
|
234
|
+
|
|
235
|
+
if len(unknown_taskings) > 0:
|
|
236
|
+
# We had taskings results of an unknown type so this condition needs to have
|
|
237
|
+
# a runtime error as it should not happen
|
|
238
|
+
err_msg_lines = [
|
|
239
|
+
f"Tasking group='{group_name}' had unknown results."
|
|
240
|
+
"TASKINGS:"
|
|
241
|
+
]
|
|
242
|
+
|
|
243
|
+
for res in results:
|
|
244
|
+
err_msg_lines.append(f" TaskID: {res.inst_id}")
|
|
245
|
+
|
|
246
|
+
err_msg = os.linesep.join(err_msg_lines)
|
|
247
|
+
raise TaskingGroupRuntimeError(err_msg)
|
|
248
|
+
|
|
249
|
+
elif len(cancelled_taskings) > 0:
|
|
250
|
+
# All of the tasking result states were of known type, but we had some cancelled
|
|
251
|
+
# taskings, so raise the cancelled error.
|
|
252
|
+
err_msg_lines = [
|
|
253
|
+
f"Tasking group='{group_name}' had cancelled tasks."
|
|
254
|
+
"CANCELLED TASKINGS:"
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
for res in results:
|
|
258
|
+
err_msg_lines.append(f" TaskID: {res.inst_id}")
|
|
259
|
+
|
|
260
|
+
err_msg = os.linesep.join(err_msg_lines)
|
|
261
|
+
raise TaskingGroupRuntimeError(err_msg)
|
|
262
|
+
|
|
263
|
+
elif len(errored_taskings) > 0:
|
|
264
|
+
# If we had any error tasks, we need to raise a non AssertionError based
|
|
265
|
+
# exception
|
|
266
|
+
err_msg_lines = [
|
|
267
|
+
f"Tasking group='{group_name}' encountered Non asserted errors."
|
|
268
|
+
"ERRORED TASKINGS:"
|
|
269
|
+
]
|
|
270
|
+
|
|
271
|
+
for res in results:
|
|
272
|
+
fmt_res_lines = result_formatter(res)
|
|
273
|
+
fmt_res_lines = indent_lines_list(fmt_res_lines, 1)
|
|
274
|
+
err_msg_lines.extend(fmt_res_lines)
|
|
275
|
+
err_msg_lines.append("")
|
|
276
|
+
|
|
277
|
+
err_msg = os.linesep.join(err_msg_lines)
|
|
278
|
+
raise TaskingGroupRuntimeError(err_msg)
|
|
279
|
+
|
|
280
|
+
elif len(failed_taskings) > 0:
|
|
281
|
+
err_msg_lines = [
|
|
282
|
+
context_message,
|
|
283
|
+
"RESULTS:"
|
|
284
|
+
]
|
|
285
|
+
|
|
286
|
+
for res in results:
|
|
287
|
+
fmt_res_lines = result_formatter(res)
|
|
288
|
+
fmt_res_lines = indent_lines_list(fmt_res_lines, 1)
|
|
289
|
+
err_msg_lines.extend(fmt_res_lines)
|
|
290
|
+
err_msg_lines.append("")
|
|
291
|
+
|
|
292
|
+
err_msg = os.linesep.join(err_msg_lines)
|
|
293
|
+
|
|
294
|
+
raise TaskingGroupAssertionError(err_msg)
|
|
295
|
+
|
|
296
|
+
return
|
|
297
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.testcontainer
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for testcontainer.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__author__ = "Myron Walker"
|
|
12
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
13
|
+
__credits__ = []
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
from ccai.testbase.results.model.resulttype import ResultType
|
|
18
|
+
from ccai.testbase.results.model.resultcontainer import ResultContainer
|
|
19
|
+
|
|
20
|
+
class TestContainer(ResultContainer):
|
|
21
|
+
"""
|
|
22
|
+
The :class:`TestContainer` instances are container nodes that are used to link result nodes in the
|
|
23
|
+
result tree. The :class:`TestsContainer` nodes do not contain result data but link data so the data can
|
|
24
|
+
be computed on demand.
|
|
25
|
+
"""
|
|
26
|
+
def __init__(self, inst_id: str, name: str, parent_inst: str):
|
|
27
|
+
"""
|
|
28
|
+
Creates an instance of a result container.
|
|
29
|
+
|
|
30
|
+
:param inst_id: The unique identifier to link this result container with its children.
|
|
31
|
+
:param name: The name of the result container.
|
|
32
|
+
:param parent_inst: The unique identifier fo this result nodes parent.
|
|
33
|
+
"""
|
|
34
|
+
super().__init__(inst_id, name, ResultType.TEST_CONTAINER, parent_inst=parent_inst)
|
|
35
|
+
return
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.testresult
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for testresult.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__author__ = "Myron Walker"
|
|
12
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
13
|
+
__credits__ = []
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
from typing import Any, Dict, List, Optional
|
|
18
|
+
|
|
19
|
+
import collections
|
|
20
|
+
import os
|
|
21
|
+
|
|
22
|
+
from dataclasses import asdict as dataclass_as_dict
|
|
23
|
+
|
|
24
|
+
from ccai.testbase.results.model.resultcode import ResultCode
|
|
25
|
+
from ccai.testbase.results.model.resultnode import ResultNode
|
|
26
|
+
from ccai.testbase.results.model.resulttype import ResultType
|
|
27
|
+
|
|
28
|
+
from ccai.xmodules.xdatetime import format_datetime_with_fractional
|
|
29
|
+
|
|
30
|
+
class TestResult(ResultNode):
|
|
31
|
+
"""
|
|
32
|
+
The :class:`TestResult` object marks a result node that contains results from a task, test or step in a result tree. The
|
|
33
|
+
result trees only store results that contain result data not associated with the hierarchy of the results. The result tree
|
|
34
|
+
does not contain results that can be computed by analyzing the relationship of the nodes in the tree. The nodes that are
|
|
35
|
+
computed are :class:`ResultContainer` instances and do not contain instance result data.
|
|
36
|
+
"""
|
|
37
|
+
def __init__(self, inst_id: str, name: str, parent_inst: str, monikers: List[str], pivots: Dict[str, Any], result_code: ResultCode = ResultCode.UNSET):
|
|
38
|
+
"""
|
|
39
|
+
Initializes an instance of a :class:`ResultNode` object that represent the information associated with
|
|
40
|
+
a specific result in a result tree.
|
|
41
|
+
|
|
42
|
+
:param inst_id: The unique identifier to link this result container with its children.
|
|
43
|
+
:param name: The name of the result container.
|
|
44
|
+
:param parent_inst: The unique identifier fo this result nodes parent.
|
|
45
|
+
:param monikers: The names of parameters used to extend the result name.
|
|
46
|
+
:param pivots: A tuple of data pivots used for result comparisons.
|
|
47
|
+
:param result_code: The result code to initialize the result node to.
|
|
48
|
+
"""
|
|
49
|
+
super().__init__(inst_id, name, parent_inst, ResultType.TEST, result_code=result_code)
|
|
50
|
+
|
|
51
|
+
self._monikers = monikers
|
|
52
|
+
self._pivots = pivots
|
|
53
|
+
self._reason = None
|
|
54
|
+
self._bug = None
|
|
55
|
+
self._property_metadata = None
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def monikers(self):
|
|
61
|
+
"""
|
|
62
|
+
A list of monikers for this test.
|
|
63
|
+
"""
|
|
64
|
+
return self._monikers
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def pivots(self):
|
|
68
|
+
"""
|
|
69
|
+
The name of the result pivots.
|
|
70
|
+
"""
|
|
71
|
+
return self._pivots
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def property_metadata(self) -> Optional[Dict[str, Any]]:
|
|
75
|
+
"""
|
|
76
|
+
The property-test metadata attached to this result, or ``None`` when the test is
|
|
77
|
+
not a property test (or its :class:`PropertyRunner` has not attached any yet).
|
|
78
|
+
"""
|
|
79
|
+
return self._property_metadata
|
|
80
|
+
|
|
81
|
+
def set_property_metadata(self, metadata: Dict[str, Any]) -> None:
|
|
82
|
+
"""
|
|
83
|
+
Attaches property-test metadata to this result. The metadata is serialized by
|
|
84
|
+
:meth:`as_dict` under the ``property_metadata`` key.
|
|
85
|
+
|
|
86
|
+
The fields are the ones specified for property tests: ``is_property_test``,
|
|
87
|
+
``examples_run``, ``max_examples``, ``seed``, ``job_seed``,
|
|
88
|
+
``strategy_descriptions``, ``assumptions_rejected`` and, when the property
|
|
89
|
+
was falsified, ``counterexample``.
|
|
90
|
+
|
|
91
|
+
:param metadata: The property-test metadata dictionary built by the
|
|
92
|
+
:class:`PropertyRunner`.
|
|
93
|
+
|
|
94
|
+
:raises TypeError: When ``metadata`` is not a dictionary.
|
|
95
|
+
"""
|
|
96
|
+
if not isinstance(metadata, dict):
|
|
97
|
+
errmsg_lines = [
|
|
98
|
+
"The 'metadata' parameter must be a dictionary.",
|
|
99
|
+
" RECEIVED TYPE: {}".format(type(metadata).__name__)
|
|
100
|
+
]
|
|
101
|
+
errmsg = os.linesep.join(errmsg_lines)
|
|
102
|
+
raise TypeError(errmsg)
|
|
103
|
+
|
|
104
|
+
self._property_metadata = metadata
|
|
105
|
+
return
|
|
106
|
+
|
|
107
|
+
def mark_skip(self, reason: str, bug: str):
|
|
108
|
+
"""
|
|
109
|
+
Marks this result with a :class:`ResultCode` of ResultCode.SKIPPED
|
|
110
|
+
|
|
111
|
+
:param reason: The reason the task or test this result is associated with was skipped.
|
|
112
|
+
"""
|
|
113
|
+
self._reason = reason
|
|
114
|
+
self._bug = bug
|
|
115
|
+
self._result_code = ResultCode.SKIPPED
|
|
116
|
+
return
|
|
117
|
+
|
|
118
|
+
def as_dict(self, is_preview: bool = False) -> collections.OrderedDict:
|
|
119
|
+
"""
|
|
120
|
+
Converts the result node instance to an :class:`collections.OrderedDict` object.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
start_datetime = format_datetime_with_fractional(self._start)
|
|
124
|
+
|
|
125
|
+
stop_datetime = ""
|
|
126
|
+
if self._stop is not None:
|
|
127
|
+
stop_datetime = format_datetime_with_fractional(self._stop)
|
|
128
|
+
|
|
129
|
+
rninfo = collections.OrderedDict([
|
|
130
|
+
("name", self._name),
|
|
131
|
+
("monikers", self._monikers),
|
|
132
|
+
("pivots", self._pivots),
|
|
133
|
+
("instance", self._inst_id),
|
|
134
|
+
("parent", self._parent_inst),
|
|
135
|
+
("rtype", self._result_type.name),
|
|
136
|
+
("result", self._result_code.name),
|
|
137
|
+
("start", start_datetime),
|
|
138
|
+
("stop", stop_datetime)
|
|
139
|
+
])
|
|
140
|
+
|
|
141
|
+
if self._property_metadata is not None:
|
|
142
|
+
rninfo["property_metadata"] = self._property_metadata
|
|
143
|
+
|
|
144
|
+
if not is_preview:
|
|
145
|
+
|
|
146
|
+
errors = [dataclass_as_dict(e) for e in self._errors]
|
|
147
|
+
failures = [dataclass_as_dict(f) for f in self._failures]
|
|
148
|
+
|
|
149
|
+
detail_items = [
|
|
150
|
+
("errors", errors),
|
|
151
|
+
("failures", failures),
|
|
152
|
+
("warnings", self._warnings)
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
if self._reason is not None:
|
|
156
|
+
detail_items.append(("reason", self._reason))
|
|
157
|
+
|
|
158
|
+
if self._bug is not None:
|
|
159
|
+
detail_items.append(("bug", self._bug))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
detail = collections.OrderedDict(detail_items)
|
|
163
|
+
|
|
164
|
+
if self._docstr is not None:
|
|
165
|
+
detail["documentation"] = self._docstr
|
|
166
|
+
|
|
167
|
+
rninfo["detail"] = detail
|
|
168
|
+
|
|
169
|
+
return rninfo
|
|
170
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.recorders
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for recorders.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__author__ = "Myron Walker"
|
|
10
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
11
|
+
__credits__ = []
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
from ccai.testbase.results.recorders.resultrecorder import ResultRecorder
|
|
15
|
+
from ccai.testbase.results.recorders.jsonresultrecorder import JsonResultRecorder, JsonResultEncoder
|
|
16
|
+
from ccai.testbase.results.recorders.xmlresultrecorder import XmlResultRecorder
|
|
17
|
+
from ccai.testbase.results.recorders.csvresultrecorder import CsvResultRecorder
|
|
18
|
+
|
|
19
|
+
# NOTE: StreamingResultRecorder relocated to codecraftai-integration-runtime (Phase 3 results split):
|
|
20
|
+
# ccai.integrationruntime.results.recorders.streamingresultrecorder. It depends on the streaming
|
|
21
|
+
# transport (also relocated), which the near-standalone testbase framework deliberately omits.
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"ResultRecorder",
|
|
25
|
+
"JsonResultRecorder",
|
|
26
|
+
"JsonResultEncoder",
|
|
27
|
+
"XmlResultRecorder",
|
|
28
|
+
"CsvResultRecorder"
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|