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,84 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.progressinfo
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for progressinfo.
|
|
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
|
+
from typing import Optional
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
from dataclasses import dataclass
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
from ccai.testbase.results.model.progresscode import ProgressCode
|
|
24
|
+
from ccai.testbase.results.model.progresstype import ProgressType
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass
|
|
28
|
+
class ProgressInfo:
|
|
29
|
+
"""
|
|
30
|
+
Representation of a single progress update event.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
id: str
|
|
34
|
+
category: str
|
|
35
|
+
moniker: str
|
|
36
|
+
ptype: ProgressType
|
|
37
|
+
range_min: str
|
|
38
|
+
range_max: str
|
|
39
|
+
position: str
|
|
40
|
+
status: ProgressCode
|
|
41
|
+
when: datetime
|
|
42
|
+
data: Optional[dict] = None
|
|
43
|
+
|
|
44
|
+
def as_dict(self) -> dict:
|
|
45
|
+
|
|
46
|
+
rtnval = {
|
|
47
|
+
"id": self.id,
|
|
48
|
+
"category": self.category,
|
|
49
|
+
"moniker": self.moniker,
|
|
50
|
+
"ptype": self.ptype.name,
|
|
51
|
+
"range_min": self.range_min,
|
|
52
|
+
"range_max": self.range_max,
|
|
53
|
+
"position": self.position,
|
|
54
|
+
"status": self.status.name,
|
|
55
|
+
"when": self.when.isoformat()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if self.data is not None:
|
|
59
|
+
rtnval["data"] = self.data
|
|
60
|
+
else:
|
|
61
|
+
rtnval["data"] = {}
|
|
62
|
+
|
|
63
|
+
return rtnval
|
|
64
|
+
|
|
65
|
+
@classmethod
|
|
66
|
+
def from_dict(cls, data: dict) -> "ProgressInfo":
|
|
67
|
+
when = datetime.fromisoformat(data["when"])
|
|
68
|
+
|
|
69
|
+
# Convert string values to enum types
|
|
70
|
+
ptype = data["ptype"]
|
|
71
|
+
if isinstance(ptype, str):
|
|
72
|
+
ptype = ProgressType(ptype)
|
|
73
|
+
|
|
74
|
+
status = data["status"]
|
|
75
|
+
if isinstance(status, str):
|
|
76
|
+
status = ProgressCode(status)
|
|
77
|
+
|
|
78
|
+
inst = cls(data["id"], data["category"], data["moniker"], ptype, data["range_min"],
|
|
79
|
+
data["range_max"], data["position"], status, when, data.get("data"))
|
|
80
|
+
return inst
|
|
81
|
+
|
|
82
|
+
def __repr__(self):
|
|
83
|
+
reprval = repr(self.as_dict())
|
|
84
|
+
return reprval
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.progresstype
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for progresstype.
|
|
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
|
+
from enum import Enum
|
|
16
|
+
|
|
17
|
+
class ProgressType(str, Enum):
|
|
18
|
+
"""
|
|
19
|
+
Enumeration of progress tracking modes.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
NumericRange = "NumericRange"
|
|
23
|
+
Sequential = "Sequential"
|
|
24
|
+
TimeSpan = "TimeSpan"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.renderinfo
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for renderinfo.
|
|
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
|
+
from dataclasses import dataclass
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class RenderInfo:
|
|
20
|
+
"""
|
|
21
|
+
Parameters that control how result rendering is performed.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
title: str # A title to associated with the summary for the test results.
|
|
25
|
+
summary_filename: str # The full path to the summary file where the test run summary should be written to.
|
|
26
|
+
summary_template: str # The full path to the summary file source template
|
|
27
|
+
stream_results_filename: str # The full path to the results stream file where the test run results are written as a stream.
|
|
28
|
+
consolidated_results_filename: str # The full path to the consolidated results file, where the results stream is consolidated to a postable document.
|
|
29
|
+
static_resource_source: str # The source folder for the static render resources
|
|
30
|
+
static_resource_destination: str # The destination folder for static render resources
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.resultcode
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for resultcode.
|
|
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
|
+
from enum import IntEnum
|
|
17
|
+
|
|
18
|
+
class ResultCode(IntEnum):
|
|
19
|
+
"""
|
|
20
|
+
Enumeration that summarizes a result.
|
|
21
|
+
"""
|
|
22
|
+
UNSET = 0
|
|
23
|
+
PASSED = 1
|
|
24
|
+
SKIPPED = 2
|
|
25
|
+
ERRORED = 3
|
|
26
|
+
FAILED = 4
|
|
27
|
+
CANCELLED = 5
|
|
28
|
+
UNKOWN = 6
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.resultcontainer
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for resultcontainer.
|
|
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
|
+
from typing import Optional
|
|
17
|
+
|
|
18
|
+
import collections
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from ccai.testbase.results.model.resulttype import ResultType
|
|
22
|
+
|
|
23
|
+
class ResultContainer:
|
|
24
|
+
"""
|
|
25
|
+
The :class:`ResultContainer` instances are container nodes that are used to link result nodes in the
|
|
26
|
+
result tree. The :class:`ResultContainer` nodes do not contain result data but link data so the data can
|
|
27
|
+
be computed on demand.
|
|
28
|
+
"""
|
|
29
|
+
def __init__(self, inst_id: str, name: str, result_type: ResultType, parent_inst: Optional[str] = None):
|
|
30
|
+
"""
|
|
31
|
+
Creates an instance of a result container.
|
|
32
|
+
|
|
33
|
+
:param inst_id: The unique identifier to link this result container with its children.
|
|
34
|
+
:param name: The name of the result container.
|
|
35
|
+
:param result_type: The type :class:`ResultType` type code of result container.
|
|
36
|
+
:param parent_inst: The unique identifier fo this result nodes parent.
|
|
37
|
+
"""
|
|
38
|
+
super().__init__()
|
|
39
|
+
|
|
40
|
+
self._inst_id = inst_id
|
|
41
|
+
self._name = name
|
|
42
|
+
self._result_type = result_type
|
|
43
|
+
self._parent_inst = parent_inst
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def inst_id(self) -> str:
|
|
48
|
+
"""
|
|
49
|
+
The unique identifier to link this result container with its children.
|
|
50
|
+
"""
|
|
51
|
+
return self._inst_id
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def name(self) -> str:
|
|
55
|
+
"""
|
|
56
|
+
The name of the result container.
|
|
57
|
+
"""
|
|
58
|
+
return self._name
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def parent_inst(self) -> str:
|
|
62
|
+
"""
|
|
63
|
+
The unique identifier fo this result nodes parent.
|
|
64
|
+
"""
|
|
65
|
+
return self._parent_inst
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def result_type(self) -> ResultType:
|
|
69
|
+
"""
|
|
70
|
+
The type :class:`ResultType` type code of result container.
|
|
71
|
+
"""
|
|
72
|
+
return self._result_type
|
|
73
|
+
|
|
74
|
+
def as_dict(self, is_preview: bool = False) -> collections.OrderedDict:
|
|
75
|
+
"""
|
|
76
|
+
Converts the result container instance to an :class:`collections.OrderedDict` object.
|
|
77
|
+
"""
|
|
78
|
+
rcinfo = collections.OrderedDict([
|
|
79
|
+
("name", self._name),
|
|
80
|
+
("instance", self._inst_id),
|
|
81
|
+
("parent", self._parent_inst),
|
|
82
|
+
("rtype", self._result_type.name)
|
|
83
|
+
])
|
|
84
|
+
|
|
85
|
+
return rcinfo
|
|
86
|
+
|
|
87
|
+
def to_json(self, is_preview: bool = False) -> str:
|
|
88
|
+
"""
|
|
89
|
+
Converts the result container instance to JSON format.
|
|
90
|
+
"""
|
|
91
|
+
rcinfo = self.as_dict(is_preview=is_preview)
|
|
92
|
+
|
|
93
|
+
rcstr = json.dumps(rcinfo, indent=4)
|
|
94
|
+
|
|
95
|
+
return rcstr
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.resultnode
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for resultnode.
|
|
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 List
|
|
18
|
+
|
|
19
|
+
import collections
|
|
20
|
+
import json
|
|
21
|
+
|
|
22
|
+
from datetime import datetime
|
|
23
|
+
|
|
24
|
+
from dataclasses import asdict as dataclass_as_dict
|
|
25
|
+
|
|
26
|
+
from ccai.errors.xtraceback import TracebackDetail
|
|
27
|
+
|
|
28
|
+
from ccai.testbase.results.model.resultcode import ResultCode
|
|
29
|
+
from ccai.testbase.results.model.resulttype import ResultType
|
|
30
|
+
|
|
31
|
+
from ccai.xmodules.xdatetime import format_datetime_with_fractional
|
|
32
|
+
|
|
33
|
+
class ResultNode:
|
|
34
|
+
"""
|
|
35
|
+
The :class:`ResultNode` object marks a result node that contains results from a task, test or step in a result tree. The
|
|
36
|
+
result trees only store results that contain result data not associated with the hierarchy of the results. The result tree
|
|
37
|
+
does not contain results that can be computed by analyzing the relationship of the nodes in the tree. The nodes that are
|
|
38
|
+
computed are :class:`ResultContainer` instances and do not contain instance result data.
|
|
39
|
+
"""
|
|
40
|
+
def __init__(self, inst_id: str, name: str, parent_inst: str, result_type: ResultType, result_code: ResultCode = ResultCode.UNSET):
|
|
41
|
+
"""
|
|
42
|
+
Initializes an instance of a :class:`ResultNode` object that represent the information associated with
|
|
43
|
+
a specific result in a result tree.
|
|
44
|
+
|
|
45
|
+
:param inst_id: The unique identifier to link this result container with its children.
|
|
46
|
+
:param name: The name of the result container.
|
|
47
|
+
:param parent_inst: The unique identifier fo this result nodes parent.
|
|
48
|
+
:param result_type: The type :class:`ResultType` type code of result container.
|
|
49
|
+
:param result_code: The result code to initialize the result node to.
|
|
50
|
+
"""
|
|
51
|
+
super().__init__()
|
|
52
|
+
|
|
53
|
+
self._inst_id = inst_id
|
|
54
|
+
self._name = name
|
|
55
|
+
self._parent_inst = parent_inst
|
|
56
|
+
self._result_type = result_type
|
|
57
|
+
self._result_code = result_code
|
|
58
|
+
|
|
59
|
+
self._start = datetime.now()
|
|
60
|
+
self._stop = None
|
|
61
|
+
|
|
62
|
+
self._errors = []
|
|
63
|
+
self._failures = []
|
|
64
|
+
self._warnings = []
|
|
65
|
+
|
|
66
|
+
self._docstr = None
|
|
67
|
+
return
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def docstr(self):
|
|
71
|
+
"""
|
|
72
|
+
Returns the documentation string associated with the tasking.
|
|
73
|
+
"""
|
|
74
|
+
return self._docstr
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def errors(self) -> List[str]:
|
|
78
|
+
"""
|
|
79
|
+
Returns the list of errors assocated with this result
|
|
80
|
+
"""
|
|
81
|
+
return self._errors
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def failures(self) -> List[str]:
|
|
85
|
+
"""
|
|
86
|
+
Returns the list of failures assocated with this result
|
|
87
|
+
"""
|
|
88
|
+
return self._failures
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def inst_id(self) -> str:
|
|
92
|
+
"""
|
|
93
|
+
The unique identifier to link this result container with its children.
|
|
94
|
+
"""
|
|
95
|
+
return self._inst_id
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def name(self) -> str:
|
|
99
|
+
"""
|
|
100
|
+
The name of the result item.
|
|
101
|
+
"""
|
|
102
|
+
return self._name
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def parent_inst(self) -> str:
|
|
106
|
+
"""
|
|
107
|
+
The unique identifier fo this result nodes parent.
|
|
108
|
+
"""
|
|
109
|
+
return self._parent_inst
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def result_code(self) -> ResultCode:
|
|
113
|
+
"""
|
|
114
|
+
The type :class:`ResultType` type code of result container.
|
|
115
|
+
"""
|
|
116
|
+
return self._result_code
|
|
117
|
+
|
|
118
|
+
@property
|
|
119
|
+
def result_type(self) -> ResultType:
|
|
120
|
+
"""
|
|
121
|
+
The :class:`ResultType` code associated with this result node.
|
|
122
|
+
"""
|
|
123
|
+
return self._result_type
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def start(self) -> datetime:
|
|
127
|
+
return self._start
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def stop(self) -> datetime:
|
|
131
|
+
return self._stop
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def warnings(self) -> List[str]:
|
|
135
|
+
"""
|
|
136
|
+
Returns the list of warnings assocated with this result
|
|
137
|
+
"""
|
|
138
|
+
return self._warnings
|
|
139
|
+
|
|
140
|
+
def add_error(self, trace_detail: TracebackDetail):
|
|
141
|
+
"""
|
|
142
|
+
Adds error trace lines for a single error to this result node.
|
|
143
|
+
"""
|
|
144
|
+
self._errors.append(trace_detail)
|
|
145
|
+
return
|
|
146
|
+
|
|
147
|
+
def add_failure(self, trace_detail: TracebackDetail):
|
|
148
|
+
"""
|
|
149
|
+
Adds failure trace lines for a single failure to this result node.
|
|
150
|
+
"""
|
|
151
|
+
self._failures.append(trace_detail)
|
|
152
|
+
return
|
|
153
|
+
|
|
154
|
+
def add_warning(self, warn_lines: List[str]):
|
|
155
|
+
"""
|
|
156
|
+
Adds warning trace lines for a single warning to this result node.
|
|
157
|
+
"""
|
|
158
|
+
trim_lines = []
|
|
159
|
+
for nline in warn_lines:
|
|
160
|
+
nline = nline.rstrip().replace("\r\n", "\n")
|
|
161
|
+
if nline.find("\n") > -1:
|
|
162
|
+
split_lines = nline.split("\n")
|
|
163
|
+
trim_lines.extend(split_lines)
|
|
164
|
+
else:
|
|
165
|
+
trim_lines.append(nline)
|
|
166
|
+
self._warnings.append(trim_lines)
|
|
167
|
+
return
|
|
168
|
+
|
|
169
|
+
def finalize(self):
|
|
170
|
+
"""
|
|
171
|
+
Finalizes the :class:`ResultCode` code for this result node based on whether
|
|
172
|
+
there were any errors or failures added to the node.
|
|
173
|
+
"""
|
|
174
|
+
self._stop = datetime.now()
|
|
175
|
+
|
|
176
|
+
if len(self._failures) > 0:
|
|
177
|
+
self._result_code = ResultCode.FAILED
|
|
178
|
+
elif len(self._errors) > 0:
|
|
179
|
+
self._result_code = ResultCode.ERRORED
|
|
180
|
+
elif self._result_code == ResultCode.SKIPPED:
|
|
181
|
+
# A skip is set by mark_skip before finalize runs. Overwriting it
|
|
182
|
+
# here dropped the result out of every tally: not passed, not
|
|
183
|
+
# skipped, just absent from a total that still counted it.
|
|
184
|
+
#
|
|
185
|
+
# CANCELLED is deliberately NOT preserved here. It finalizes to
|
|
186
|
+
# UNKOWN, which ResultNodeFinalizeTests asserts; whether that is
|
|
187
|
+
# intended is a separate question from this one.
|
|
188
|
+
pass
|
|
189
|
+
elif self._result_code == ResultCode.UNSET or self._result_code == ResultCode.PASSED:
|
|
190
|
+
self._result_code = ResultCode.PASSED
|
|
191
|
+
else:
|
|
192
|
+
self._result_code = ResultCode.UNKOWN
|
|
193
|
+
|
|
194
|
+
return
|
|
195
|
+
|
|
196
|
+
def mark_passed(self):
|
|
197
|
+
"""
|
|
198
|
+
Marks this result with a :class:`ResultCode` of ResultCode.PASSED
|
|
199
|
+
"""
|
|
200
|
+
self._result_code = ResultCode.PASSED
|
|
201
|
+
return
|
|
202
|
+
|
|
203
|
+
def set_documentation(self, docstr):
|
|
204
|
+
"""
|
|
205
|
+
Sets the documentation string associated with this result node.
|
|
206
|
+
"""
|
|
207
|
+
self._docstr = docstr
|
|
208
|
+
return
|
|
209
|
+
|
|
210
|
+
def as_dict(self, is_preview: bool = False) -> collections.OrderedDict:
|
|
211
|
+
"""
|
|
212
|
+
Converts the result node instance to an :class:`collections.OrderedDict` object.
|
|
213
|
+
"""
|
|
214
|
+
|
|
215
|
+
start_datetime = format_datetime_with_fractional(self._start)
|
|
216
|
+
|
|
217
|
+
stop_datetime = ""
|
|
218
|
+
if self._stop is not None:
|
|
219
|
+
stop_datetime = format_datetime_with_fractional(self._stop)
|
|
220
|
+
|
|
221
|
+
rninfo = collections.OrderedDict([
|
|
222
|
+
("name", self._name),
|
|
223
|
+
("instance", self._inst_id),
|
|
224
|
+
("parent", self._parent_inst),
|
|
225
|
+
("rtype", self._result_type.name),
|
|
226
|
+
("result", self._result_code.name),
|
|
227
|
+
("start", start_datetime),
|
|
228
|
+
("stop", stop_datetime)
|
|
229
|
+
])
|
|
230
|
+
|
|
231
|
+
if not is_preview:
|
|
232
|
+
errors = [dataclass_as_dict(e) for e in self._errors]
|
|
233
|
+
failures = [dataclass_as_dict(f) for f in self._failures]
|
|
234
|
+
|
|
235
|
+
detail_items = [
|
|
236
|
+
("errors", errors),
|
|
237
|
+
("failures", failures),
|
|
238
|
+
("warnings", self._warnings)
|
|
239
|
+
]
|
|
240
|
+
|
|
241
|
+
detail = collections.OrderedDict(detail_items)
|
|
242
|
+
|
|
243
|
+
if self._docstr is not None:
|
|
244
|
+
detail["documentation"] = self._docstr
|
|
245
|
+
|
|
246
|
+
rninfo["detail"] = detail
|
|
247
|
+
|
|
248
|
+
return rninfo
|
|
249
|
+
|
|
250
|
+
def to_json(self, is_preview: bool = False) -> str:
|
|
251
|
+
"""
|
|
252
|
+
Converts the result node instance to JSON format.
|
|
253
|
+
"""
|
|
254
|
+
rninfo = self.as_dict(is_preview=is_preview)
|
|
255
|
+
|
|
256
|
+
rnstr = json.dumps(rninfo, indent=4)
|
|
257
|
+
|
|
258
|
+
return rnstr
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.resulttype
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for resulttype.
|
|
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 enum import IntEnum
|
|
18
|
+
|
|
19
|
+
class ResultType(IntEnum):
|
|
20
|
+
"""
|
|
21
|
+
Enumeration to mark the type of result.
|
|
22
|
+
"""
|
|
23
|
+
JOB = 0
|
|
24
|
+
PACKAGE = 1
|
|
25
|
+
SCOPE = 2
|
|
26
|
+
TASK_CONTAINER = 3
|
|
27
|
+
TASK = 4
|
|
28
|
+
TEST_CONTAINER = 5
|
|
29
|
+
TEST = 6
|
|
30
|
+
STEP_CONATINER = 7
|
|
31
|
+
STEP = 8
|
|
32
|
+
TASKING_GROUP = 9
|
|
33
|
+
TASKING = 10
|
|
34
|
+
CHECK = 11
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.model.streaminginfo
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for streaming configuration information.
|
|
5
|
+
|
|
6
|
+
This module provides configuration dataclasses for result streaming to external
|
|
7
|
+
services. It supports both REST endpoint streaming and WebSocket-based streaming.
|
|
8
|
+
|
|
9
|
+
.. moduleauthor:: CodeCraftX
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
__author__ = "CodeCraftX"
|
|
15
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
16
|
+
__credits__ = []
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
from typing import Optional, Callable
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from enum import Enum
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class StreamingProtocol(Enum):
|
|
25
|
+
"""
|
|
26
|
+
Enumeration of supported streaming protocols for result delivery.
|
|
27
|
+
|
|
28
|
+
This enum defines the available protocols for streaming test results
|
|
29
|
+
to external services in real-time.
|
|
30
|
+
"""
|
|
31
|
+
REST = "REST" # HTTP REST endpoint streaming
|
|
32
|
+
WEBSOCKET = "WebSocket" # WebSocket-based streaming
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass
|
|
36
|
+
class StreamingInfo:
|
|
37
|
+
"""
|
|
38
|
+
Configuration for streaming test results to external services.
|
|
39
|
+
|
|
40
|
+
This dataclass contains all configuration needed to stream test results
|
|
41
|
+
in real-time to external monitoring services. It supports both REST
|
|
42
|
+
endpoint streaming and WebSocket-based streaming.
|
|
43
|
+
|
|
44
|
+
REST Streaming:
|
|
45
|
+
Results are POSTed to the configured URL as JSON payloads.
|
|
46
|
+
Each result (preview or final) triggers an HTTP POST request.
|
|
47
|
+
|
|
48
|
+
WebSocket Streaming:
|
|
49
|
+
Results are sent over a persistent WebSocket connection.
|
|
50
|
+
The connection is established when recording begins and
|
|
51
|
+
maintained throughout the test run.
|
|
52
|
+
|
|
53
|
+
Example Usage::
|
|
54
|
+
|
|
55
|
+
# REST streaming configuration
|
|
56
|
+
streaming_info = StreamingInfo(
|
|
57
|
+
protocol=StreamingProtocol.REST,
|
|
58
|
+
streaming_url="https://monitoring.example.com/api/results",
|
|
59
|
+
streaming_headers={"Authorization": "Bearer token123"},
|
|
60
|
+
stream_previews=True,
|
|
61
|
+
stream_results=True
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# WebSocket streaming configuration
|
|
65
|
+
streaming_info = StreamingInfo(
|
|
66
|
+
protocol=StreamingProtocol.WEBSOCKET,
|
|
67
|
+
streaming_url="wss://monitoring.example.com/ws/results",
|
|
68
|
+
stream_previews=True,
|
|
69
|
+
stream_results=True,
|
|
70
|
+
reconnect_on_failure=True,
|
|
71
|
+
reconnect_interval=5.0
|
|
72
|
+
)
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
protocol: StreamingProtocol # The streaming protocol to use (REST or WebSocket)
|
|
76
|
+
streaming_url: str # The URL to stream results to
|
|
77
|
+
streaming_headers: Optional[dict] = None # Optional headers for REST requests or WebSocket handshake
|
|
78
|
+
stream_previews: bool = True # Whether to stream preview records
|
|
79
|
+
stream_results: bool = True # Whether to stream final result records
|
|
80
|
+
reconnect_on_failure: bool = True # Whether to reconnect on connection failure (WebSocket)
|
|
81
|
+
reconnect_interval: float = 5.0 # Interval in seconds between reconnection attempts
|
|
82
|
+
batch_size: int = 1 # Number of results to batch before sending (1 = immediate)
|
|
83
|
+
batch_timeout: float = 1.0 # Maximum time to wait before sending a partial batch
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass
|
|
87
|
+
class StreamingCallback:
|
|
88
|
+
"""
|
|
89
|
+
Protocol for custom streaming callbacks.
|
|
90
|
+
|
|
91
|
+
This dataclass allows users to provide custom callbacks for handling
|
|
92
|
+
streamed results. The callback is invoked for each result that would
|
|
93
|
+
be streamed, allowing custom processing or routing.
|
|
94
|
+
|
|
95
|
+
Example Usage::
|
|
96
|
+
|
|
97
|
+
def my_result_handler(result_dict: dict, is_preview: bool) -> bool:
|
|
98
|
+
# Custom handling logic
|
|
99
|
+
print(f"Result: {result_dict['name']}, Preview: {is_preview}")
|
|
100
|
+
return True # Return True to indicate success
|
|
101
|
+
|
|
102
|
+
callback = StreamingCallback(
|
|
103
|
+
on_result=my_result_handler,
|
|
104
|
+
on_error=lambda e: print(f"Error: {e}")
|
|
105
|
+
)
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
on_result: Callable[[dict, bool], bool] # Callback for each result (result_dict, is_preview) -> success
|
|
109
|
+
on_error: Optional[Callable[[Exception], None]] = None # Optional error callback
|
|
110
|
+
on_connect: Optional[Callable[[], None]] = None # Optional connection established callback
|
|
111
|
+
on_disconnect: Optional[Callable[[], None]] = None # Optional disconnection callback
|