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.
Files changed (142) hide show
  1. ccai/factories/py.typed +0 -0
  2. ccai/factories/testbasedefaulttypefactory.py +25 -0
  3. ccai/testbase/__init__.py +63 -0
  4. ccai/testbase/breakpoints.py +110 -0
  5. ccai/testbase/cli/__init__.py +13 -0
  6. ccai/testbase/cli/cmdtree/agents/__init__.py +28 -0
  7. ccai/testbase/cli/cmdtree/agents/config/__init__.py +24 -0
  8. ccai/testbase/cli/cmdtree/agents/config/extract.py +94 -0
  9. ccai/testbase/cli/cmdtree/agents/formatting.py +71 -0
  10. ccai/testbase/cli/cmdtree/agents/jsosparser.py +119 -0
  11. ccai/testbase/cli/cmdtree/agents/pathresolver.py +34 -0
  12. ccai/testbase/cli/cmdtree/agents/summary/__init__.py +26 -0
  13. ccai/testbase/cli/cmdtree/agents/summary/compare.py +128 -0
  14. ccai/testbase/cli/cmdtree/agents/summary/extract.py +91 -0
  15. ccai/testbase/cli/cmdtree/agents/testresult/__init__.py +28 -0
  16. ccai/testbase/cli/cmdtree/agents/testresult/extract.py +77 -0
  17. ccai/testbase/cli/cmdtree/agents/testresult/failures.py +73 -0
  18. ccai/testbase/cli/cmdtree/agents/testresult/list.py +63 -0
  19. ccai/testbase/cli/cmdtree/services/__init__.py +27 -0
  20. ccai/testbase/cli/cmdtree/services/results.py +66 -0
  21. ccai/testbase/cli/cmdtree/testing/__init__.py +30 -0
  22. ccai/testbase/cli/cmdtree/testing/jobs.py +175 -0
  23. ccai/testbase/cli/cmdtree/testing/query.py +131 -0
  24. ccai/testbase/cli/cmdtree/testing/run.py +263 -0
  25. ccai/testbase/cli/cmdtree/utilities/__init__.py +28 -0
  26. ccai/testbase/cli/cmdtree/utilities/timestamp.py +33 -0
  27. ccai/testbase/cli/options.py +370 -0
  28. ccai/testbase/cli/testbase_command.py +64 -0
  29. ccai/testbase/cli/utilities.py +31 -0
  30. ccai/testbase/configuration.py +324 -0
  31. ccai/testbase/constraints.py +998 -0
  32. ccai/testbase/coupling/__init__.py +569 -0
  33. ccai/testbase/coupling/basecoupling.py +69 -0
  34. ccai/testbase/coupling/configurationcoupling.py +138 -0
  35. ccai/testbase/coupling/integrationcoupling.py +842 -0
  36. ccai/testbase/coupling/validatorcoupling.py +127 -0
  37. ccai/testbase/debuggingext.py +281 -0
  38. ccai/testbase/debuglogging.py +407 -0
  39. ccai/testbase/debugports.py +469 -0
  40. ccai/testbase/declaration/__init__.py +13 -0
  41. ccai/testbase/declaration/attachments.py +222 -0
  42. ccai/testbase/declaration/originations.py +217 -0
  43. ccai/testbase/declaration/parameterization.py +160 -0
  44. ccai/testbase/declaration/registrations.py +476 -0
  45. ccai/testbase/diagnostic_level.py +197 -0
  46. ccai/testbase/diagnostic_streaming.py +1534 -0
  47. ccai/testbase/diagnostics.py +1685 -0
  48. ccai/testbase/entrypoints.py +485 -0
  49. ccai/testbase/environment.py +162 -0
  50. ccai/testbase/errors/testruntimeouterror.py +50 -0
  51. ccai/testbase/expressions.py +355 -0
  52. ccai/testbase/factories.py +277 -0
  53. ccai/testbase/factoryprotocols.py +35 -0
  54. ccai/testbase/features.py +913 -0
  55. ccai/testbase/initialize.py +210 -0
  56. ccai/testbase/injection/__init__.py +25 -0
  57. ccai/testbase/injection/injectiongroup.py +493 -0
  58. ccai/testbase/injection/injectionmoment.py +155 -0
  59. ccai/testbase/injection/injectionregistry.py +823 -0
  60. ccai/testbase/injection/injectionscope.py +2589 -0
  61. ccai/testbase/injection/introspection.py +514 -0
  62. ccai/testbase/markers.py +665 -0
  63. ccai/testbase/mocking.py +4856 -0
  64. ccai/testbase/origins/__init__.py +13 -0
  65. ccai/testbase/origins/resourceorigin.py +110 -0
  66. ccai/testbase/origins/validatororigin.py +111 -0
  67. ccai/testbase/output/__init__.py +17 -0
  68. ccai/testbase/output/outputcontext.py +201 -0
  69. ccai/testbase/output/runmetadata.py +184 -0
  70. ccai/testbase/properties/__init__.py +40 -0
  71. ccai/testbase/properties/assumptions.py +56 -0
  72. ccai/testbase/properties/decorators.py +173 -0
  73. ccai/testbase/properties/propertyrunner.py +449 -0
  74. ccai/testbase/properties/strategies.py +1592 -0
  75. ccai/testbase/properties/unittestsupport.py +87 -0
  76. ccai/testbase/py.typed +0 -0
  77. ccai/testbase/queries.py +95 -0
  78. ccai/testbase/resourcelifespan.py +24 -0
  79. ccai/testbase/results/__init__.py +35 -0
  80. ccai/testbase/results/exceptions.py +60 -0
  81. ccai/testbase/results/filtering/__init__.py +26 -0
  82. ccai/testbase/results/filtering/resultfilter.py +570 -0
  83. ccai/testbase/results/model/__init__.py +32 -0
  84. ccai/testbase/results/model/buildinfo.py +54 -0
  85. ccai/testbase/results/model/checkresult.py +183 -0
  86. ccai/testbase/results/model/forwardinginfo.py +30 -0
  87. ccai/testbase/results/model/jobcontainer.py +32 -0
  88. ccai/testbase/results/model/jobinfo.py +91 -0
  89. ccai/testbase/results/model/nestedprogressinfo.py +211 -0
  90. ccai/testbase/results/model/pipelineinfo.py +51 -0
  91. ccai/testbase/results/model/progressaggregator.py +551 -0
  92. ccai/testbase/results/model/progresscode.py +29 -0
  93. ccai/testbase/results/model/progressdelivery.py +51 -0
  94. ccai/testbase/results/model/progressinfo.py +84 -0
  95. ccai/testbase/results/model/progresstype.py +24 -0
  96. ccai/testbase/results/model/renderinfo.py +30 -0
  97. ccai/testbase/results/model/resultcode.py +28 -0
  98. ccai/testbase/results/model/resultcontainer.py +95 -0
  99. ccai/testbase/results/model/resultnode.py +258 -0
  100. ccai/testbase/results/model/resulttype.py +34 -0
  101. ccai/testbase/results/model/streaminginfo.py +111 -0
  102. ccai/testbase/results/model/taskinggroup.py +85 -0
  103. ccai/testbase/results/model/taskingresult.py +297 -0
  104. ccai/testbase/results/model/testcontainer.py +35 -0
  105. ccai/testbase/results/model/testresult.py +170 -0
  106. ccai/testbase/results/recorders/__init__.py +31 -0
  107. ccai/testbase/results/recorders/csvresultrecorder.py +414 -0
  108. ccai/testbase/results/recorders/jsonresultrecorder.py +467 -0
  109. ccai/testbase/results/recorders/resultrecorder.py +1472 -0
  110. ccai/testbase/results/recorders/stdoutresultrecorder.py +70 -0
  111. ccai/testbase/results/recorders/xmlresultrecorder.py +305 -0
  112. ccai/testbase/results/utilities.py +141 -0
  113. ccai/testbase/sequencing/__init__.py +13 -0
  114. ccai/testbase/sequencing/sequencermodulescope.py +96 -0
  115. ccai/testbase/sequencing/sequencerscopebase.py +91 -0
  116. ccai/testbase/sequencing/sequencersessionscope.py +84 -0
  117. ccai/testbase/sequencing/sequencertestscope.py +249 -0
  118. ccai/testbase/sequencing/sequencertestsetupscope.py +86 -0
  119. ccai/testbase/sequencing/testactivity.py +111 -0
  120. ccai/testbase/sequencing/testsequencer.py +3072 -0
  121. ccai/testbase/server/__init__.py +13 -0
  122. ccai/testbase/server/resultserver.py +599 -0
  123. ccai/testbase/sources/__init__.py +13 -0
  124. ccai/testbase/sources/configurationsource.py +32 -0
  125. ccai/testbase/sources/integrationsource.py +29 -0
  126. ccai/testbase/sources/resourcesource.py +27 -0
  127. ccai/testbase/sources/sourcebase.py +71 -0
  128. ccai/testbase/sources/unknownsource.py +30 -0
  129. ccai/testbase/sources/validatorsource.py +28 -0
  130. ccai/testbase/tandem/__init__.py +13 -0
  131. ccai/testbase/tandem/validators.py +286 -0
  132. ccai/testbase/testcollector.py +230 -0
  133. ccai/testbase/testgroup.py +54 -0
  134. ccai/testbase/testjob.py +600 -0
  135. ccai/testbase/testref.py +64 -0
  136. ccai/testbase/utilities.py +472 -0
  137. ccai/testbase/verification.py +768 -0
  138. codecraftai_testbase-1.3.0.dist-info/METADATA +99 -0
  139. codecraftai_testbase-1.3.0.dist-info/RECORD +142 -0
  140. codecraftai_testbase-1.3.0.dist-info/WHEEL +4 -0
  141. codecraftai_testbase-1.3.0.dist-info/entry_points.txt +3 -0
  142. codecraftai_testbase-1.3.0.dist-info/licenses/LICENSE.md +204 -0
@@ -0,0 +1,183 @@
1
+ """
2
+ .. module:: ccai.testbase.results.model.checkresult
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for property test check results.
5
+
6
+ This module provides the :class:`CheckResult` class which represents
7
+ the outcome of a single generated example within a property test. Each
8
+ property test produces multiple ``CheckResult`` instances (one per example),
9
+ following the same structural pattern used by ``TaskingResult``.
10
+
11
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
12
+ """
13
+
14
+
15
+
16
+ __author__ = "Myron Walker"
17
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
18
+ __credits__ = []
19
+
20
+
21
+ from typing import Any, Dict, List
22
+
23
+ import collections
24
+
25
+ from dataclasses import asdict as dataclass_as_dict
26
+
27
+ from ccai.xmodules.xdatetime import format_datetime_with_fractional
28
+
29
+ from ccai.testbase.results.model.resultcode import ResultCode
30
+ from ccai.testbase.results.model.resultnode import ResultNode
31
+ from ccai.testbase.results.model.resulttype import ResultType
32
+
33
+
34
+ class CheckResult(ResultNode):
35
+ """
36
+ Represents the outcome of a single generated example within a property test.
37
+
38
+ The :class:`CheckResult` is a leaf node in the result tree that records
39
+ the generated input values, the example index, the seed used for
40
+ generation, and the pass/fail/error status for one example invocation.
41
+ Multiple ``CheckResult`` entries are attached to a single parent
42
+ ``TestResult``, following the same collection pattern used for
43
+ ``TaskingResult`` entries in tasking-based tests.
44
+
45
+ :param inst_id: The unique identifier for this check result node.
46
+ :param name: The name of this check (e.g., "check_0042").
47
+ :param parent_inst: The unique identifier of the parent test result.
48
+ :param generated_values: Dictionary mapping parameter names to
49
+ their generated values for this example.
50
+ :param example_index: The zero-based index of this example within
51
+ the property test run.
52
+ :param seed: The seed used to generate this specific example.
53
+ :param result_code: The initial result code for this check.
54
+ """
55
+
56
+ def __init__(self, inst_id: str, name: str, parent_inst: str,
57
+ generated_values: Dict[str, Any], example_index: int,
58
+ seed: int, result_code: ResultCode = ResultCode.UNSET):
59
+ """
60
+ Initializes an instance of a :class:`CheckResult` object.
61
+
62
+ :param inst_id: The unique identifier for this check result node.
63
+ :param name: The name of this check (e.g., "check_0042").
64
+ :param parent_inst: The unique identifier of the parent test result.
65
+ :param generated_values: Dictionary mapping parameter names to
66
+ their generated values for this example.
67
+ :param example_index: The zero-based index of this example within
68
+ the property test run.
69
+ :param seed: The seed used to generate this specific example.
70
+ :param result_code: The initial result code for this check.
71
+ """
72
+ super().__init__(inst_id, name, parent_inst, ResultType.CHECK, result_code=result_code)
73
+
74
+ self._generated_values = generated_values
75
+ self._example_index = example_index
76
+ self._seed = seed
77
+ return
78
+
79
+ @property
80
+ def generated_values(self) -> Dict[str, Any]:
81
+ """
82
+ The dictionary of generated input values for this example.
83
+ """
84
+ return self._generated_values
85
+
86
+ @property
87
+ def example_index(self) -> int:
88
+ """
89
+ The zero-based index of this example in the property test run.
90
+ """
91
+ return self._example_index
92
+
93
+ @property
94
+ def seed(self) -> int:
95
+ """
96
+ The seed used to generate this specific example.
97
+ """
98
+ return self._seed
99
+
100
+ def as_dict(self, is_preview: bool = False) -> collections.OrderedDict:
101
+ """
102
+ Converts the check result instance to an :class:`collections.OrderedDict`.
103
+
104
+ The output follows the same structural pattern as
105
+ :meth:`TaskingResult.as_dict`, with property-specific fields
106
+ (``generated_values``, ``example_index``, ``seed``) included.
107
+
108
+ :param is_preview: If ``True``, omit the detail section (errors,
109
+ failures, warnings).
110
+ :returns: An ordered dictionary representing the serialized check result.
111
+ """
112
+ start_datetime = format_datetime_with_fractional(self._start)
113
+
114
+ stop_datetime = ""
115
+ if self._stop is not None:
116
+ stop_datetime = format_datetime_with_fractional(self._stop)
117
+
118
+ # Safely serialize generated values — convert non-serializable types to repr
119
+ safe_values = {}
120
+ for k, v in self._generated_values.items():
121
+ try:
122
+ # Test that the value is JSON-serializable
123
+ import json
124
+ json.dumps(v)
125
+ safe_values[k] = v
126
+ except (TypeError, ValueError):
127
+ safe_values[k] = repr(v)
128
+
129
+ rninfo = collections.OrderedDict([
130
+ ("name", self._name),
131
+ ("instance", self._inst_id),
132
+ ("parent", self._parent_inst),
133
+ ("rtype", self._result_type.name),
134
+ ("result", self._result_code.name),
135
+ ("generated_values", safe_values),
136
+ ("example_index", self._example_index),
137
+ ("seed", self._seed),
138
+ ("start", start_datetime),
139
+ ("stop", stop_datetime)
140
+ ])
141
+
142
+ if not is_preview:
143
+
144
+ errors = [dataclass_as_dict(e) for e in self._errors]
145
+ failures = [dataclass_as_dict(f) for f in self._failures]
146
+
147
+ detail_items = [
148
+ ("errors", errors),
149
+ ("failures", failures),
150
+ ("warnings", self._warnings)
151
+ ]
152
+
153
+ detail = collections.OrderedDict(detail_items)
154
+
155
+ if self._docstr is not None:
156
+ detail["documentation"] = self._docstr
157
+
158
+ rninfo["detail"] = detail
159
+
160
+ return rninfo
161
+
162
+ def format_result(self) -> List[str]:
163
+ """
164
+ Formats the check result into human-readable lines for console output.
165
+
166
+ :returns: A list of formatted strings representing this check result.
167
+ """
168
+ fmt_lines = []
169
+
170
+ result_str = self._result_code.name
171
+ gen_vals = ", ".join(f"{k}={v!r}" for k, v in self._generated_values.items())
172
+
173
+ fmt_lines.append(f" [{result_str}] {self._name}: {gen_vals}")
174
+
175
+ if self._errors:
176
+ for err in self._errors:
177
+ fmt_lines.append(f" ERROR: {err}")
178
+
179
+ if self._failures:
180
+ for fail in self._failures:
181
+ fmt_lines.append(f" FAILURE: {fail}")
182
+
183
+ return fmt_lines
@@ -0,0 +1,30 @@
1
+ """
2
+ .. module:: ccai.testbase.results.model.forwardinginfo
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for forwardinginfo.
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
+
21
+
22
+ @dataclass
23
+ class ForwardingInfo:
24
+ """
25
+ Information controlling progress forwarding operations.
26
+ """
27
+
28
+ forwarding_interval: float # The interval in seconds to use when forwarding job summary information
29
+ forwarding_url: str # identifier such as a uuid which identifies a particular pipeline.
30
+ forwarding_headers: Optional[dict] = None # Headers to use when forwarding progress, results or summaries.
@@ -0,0 +1,32 @@
1
+ """
2
+ .. module:: ccai.testbase.results.model.jobcontainer
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for jobcontainer.
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 ccai.testbase.results.model.resulttype import ResultType
17
+ from ccai.testbase.results.model.resultcontainer import ResultContainer
18
+
19
+ class JobContainer(ResultContainer):
20
+ """
21
+ The :class:`JobContainer` instances are container nodes that are used to link result nodes in the
22
+ result tree. The :class:`JobContainer` node is the base node for the tree.
23
+ """
24
+ def __init__(self, inst_id: str, name: str):
25
+ """
26
+ Creates an instance of a result container.
27
+
28
+ :param inst_id: The unique identifier to link this result container with its children.
29
+ :param name: The name of the result container.
30
+ """
31
+ super().__init__(inst_id, name, ResultType.JOB, parent_inst=None)
32
+ return
@@ -0,0 +1,91 @@
1
+ """
2
+ .. module:: ccai.testbase.results.model.jobinfo
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for jobinfo.
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 warnings
19
+
20
+ from dataclasses import dataclass
21
+
22
+
23
+ class MissingOptionalFieldWarning(UserWarning):
24
+ """
25
+ Warning issued when an optional field in JobInfo is not provided.
26
+
27
+ This warning helps developers identify when optional metadata fields
28
+ are missing, which may affect result reporting or correlation with
29
+ external systems.
30
+
31
+ The warning can be filtered using Python's standard warning filtering
32
+ mechanisms if desired.
33
+ """
34
+ pass
35
+
36
+
37
+ @dataclass
38
+ class JobInfo:
39
+ """
40
+ Descriptor for job execution metadata.
41
+
42
+ Required fields (id, name, type) must be non-empty strings. Optional fields
43
+ (owner, label, initiator, venue, seed, tag) will generate warnings if not
44
+ provided, to help identify potentially missing metadata.
45
+
46
+ :raises ValueError: If any required field (id, name, type) is None or empty.
47
+ """
48
+
49
+ id: str # identifier for a job from the runner perspective
50
+ name: str # name of the job.
51
+ type: str # job type.
52
+ owner: Optional[str] = None # Optional owner of the job.
53
+ label: Optional[str] = None # Optional label associated with the job.
54
+ initiator: Optional[str] = None # Optional name of the initiator of the job.
55
+ venue: Optional[str] = None # Optional identifier of a venue the job was run in.
56
+ seed: Optional[str] = None # Optional seed for the job.
57
+ tag: Optional[str] = None # Optional correlation tag to associate with the job.
58
+
59
+ def __post_init__(self):
60
+ """
61
+ Validates required fields and warns about missing optional fields.
62
+
63
+ This method is called automatically by the dataclass after __init__.
64
+ It ensures that required fields contain valid, non-empty string values
65
+ and issues warnings for any optional fields that are not provided.
66
+
67
+ :raises ValueError: If any required field (id, name, type) is None or empty.
68
+ The error message includes the name of the invalid field.
69
+ """
70
+ # Validate required fields
71
+ required_fields = ['id', 'name', 'type']
72
+
73
+ for field_name in required_fields:
74
+ value = getattr(self, field_name)
75
+ if value is None or (isinstance(value, str) and value.strip() == ''):
76
+ raise ValueError(
77
+ f"JobInfo field '{field_name}' is required and cannot be None or empty."
78
+ )
79
+
80
+ # Warn about missing optional fields
81
+ optional_fields = ['owner', 'label', 'initiator', 'venue', 'seed', 'tag']
82
+
83
+ for field_name in optional_fields:
84
+ value = getattr(self, field_name)
85
+ if value is None:
86
+ warnings.warn(
87
+ f"JobInfo optional field '{field_name}' is not set. "
88
+ f"Consider providing this field for better result correlation.",
89
+ MissingOptionalFieldWarning,
90
+ stacklevel=2
91
+ )
@@ -0,0 +1,211 @@
1
+ """
2
+ .. module:: ccai.testbase.results.model.nestedprogressinfo
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for nested progress information supporting hierarchical progress tracking.
5
+
6
+ .. moduleauthor:: CodeCraftX
7
+ """
8
+
9
+ __author__ = "CodeCraftX"
10
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
11
+ __credits__ = []
12
+
13
+
14
+ from typing import List, Optional
15
+
16
+ from dataclasses import dataclass, field
17
+ from datetime import datetime
18
+
19
+ from ccai.testbase.results.model.progresscode import ProgressCode
20
+ from ccai.testbase.results.model.progresstype import ProgressType
21
+ from ccai.testbase.results.model.progressinfo import ProgressInfo
22
+
23
+
24
+ @dataclass
25
+ class NestedProgressInfo(ProgressInfo):
26
+ """
27
+ Representation of a nested progress update event that supports hierarchical
28
+ progress tracking.
29
+
30
+ This class extends :class:`ProgressInfo` to add support for parent-child
31
+ relationships between progress indicators. This enables tracking of complex
32
+ multi-level progress scenarios such as:
33
+
34
+ - A test suite containing multiple test modules
35
+ - A test module containing multiple test functions
36
+ - A distributed task containing multiple sub-tasks
37
+
38
+ The parent_id field links child progress indicators to their parent,
39
+ allowing the progress tracking system to build and maintain a tree
40
+ structure of progress information.
41
+
42
+ Attributes:
43
+ parent_id: Optional identifier of the parent progress indicator.
44
+ If None, this is a root-level progress indicator.
45
+ children_ids: List of child progress indicator IDs. This is populated
46
+ by the progress aggregator when building the tree.
47
+ depth: The depth level in the progress hierarchy (0 for root).
48
+
49
+ Example Usage::
50
+
51
+ # Create a parent progress indicator for a test suite
52
+ suite_progress = NestedProgressInfo(
53
+ id="suite-123",
54
+ category="test-suite",
55
+ moniker="Integration Tests",
56
+ ptype=ProgressType.NumericRange,
57
+ range_min="0",
58
+ range_max="100",
59
+ position="0",
60
+ status=ProgressCode.Running,
61
+ when=datetime.now(),
62
+ parent_id=None, # Root level
63
+ depth=0
64
+ )
65
+
66
+ # Create a child progress indicator for a test module
67
+ module_progress = NestedProgressInfo(
68
+ id="module-456",
69
+ category="test-module",
70
+ moniker="test_authentication",
71
+ ptype=ProgressType.Sequential,
72
+ range_min="0",
73
+ range_max="10",
74
+ position="3",
75
+ status=ProgressCode.Running,
76
+ when=datetime.now(),
77
+ parent_id="suite-123", # Links to parent
78
+ depth=1
79
+ )
80
+ """
81
+
82
+ parent_id: Optional[str] = None
83
+ children_ids: List[str] = field(default_factory=list)
84
+ depth: int = 0
85
+
86
+ def as_dict(self) -> dict:
87
+ """
88
+ Converts the nested progress info to a dictionary representation.
89
+
90
+ This method extends the base :class:`ProgressInfo.as_dict` method to
91
+ include the additional nested progress fields (parent_id, children_ids,
92
+ depth).
93
+
94
+ :returns: A dictionary containing all progress fields including
95
+ nested hierarchy information.
96
+
97
+ :rtype: dict
98
+ """
99
+ rtnval = super().as_dict()
100
+
101
+ rtnval["parent_id"] = self.parent_id
102
+ rtnval["children_ids"] = list(self.children_ids)
103
+ rtnval["depth"] = self.depth
104
+
105
+ return rtnval
106
+
107
+ @classmethod
108
+ def from_dict(cls, data: dict) -> "NestedProgressInfo":
109
+ """
110
+ Creates a NestedProgressInfo instance from a dictionary.
111
+
112
+ This class method deserializes a dictionary representation back into
113
+ a NestedProgressInfo object, handling type conversions for enum fields
114
+ and datetime parsing.
115
+
116
+ :param data: A dictionary containing the serialized progress data.
117
+
118
+ :returns: A new NestedProgressInfo instance populated with the
119
+ dictionary data.
120
+
121
+ :rtype: NestedProgressInfo
122
+ """
123
+ when = datetime.fromisoformat(data["when"])
124
+
125
+ # Convert string values to enum types
126
+ ptype = data["ptype"]
127
+ if isinstance(ptype, str):
128
+ ptype = ProgressType(ptype)
129
+
130
+ status = data["status"]
131
+ if isinstance(status, str):
132
+ status = ProgressCode(status)
133
+
134
+ inst = cls(
135
+ id=data["id"],
136
+ category=data["category"],
137
+ moniker=data["moniker"],
138
+ ptype=ptype,
139
+ range_min=data["range_min"],
140
+ range_max=data["range_max"],
141
+ position=data["position"],
142
+ status=status,
143
+ when=when,
144
+ data=data.get("data"),
145
+ parent_id=data.get("parent_id"),
146
+ children_ids=data.get("children_ids", []),
147
+ depth=data.get("depth", 0)
148
+ )
149
+
150
+ return inst
151
+
152
+ @classmethod
153
+ def from_progress_info(cls, progress: ProgressInfo, parent_id: Optional[str] = None,
154
+ depth: int = 0) -> "NestedProgressInfo":
155
+ """
156
+ Creates a NestedProgressInfo from an existing ProgressInfo instance.
157
+
158
+ This factory method allows converting a flat ProgressInfo into a
159
+ nested progress indicator by adding parent relationship and depth
160
+ information.
161
+
162
+ :param progress: The source ProgressInfo to convert.
163
+ :param parent_id: Optional parent progress indicator ID.
164
+ :param depth: The depth level in the hierarchy.
165
+
166
+ :returns: A new NestedProgressInfo instance with the same data as
167
+ the source plus nested hierarchy fields.
168
+
169
+ :rtype: NestedProgressInfo
170
+ """
171
+ return cls(
172
+ id=progress.id,
173
+ category=progress.category,
174
+ moniker=progress.moniker,
175
+ ptype=progress.ptype,
176
+ range_min=progress.range_min,
177
+ range_max=progress.range_max,
178
+ position=progress.position,
179
+ status=progress.status,
180
+ when=progress.when,
181
+ data=progress.data,
182
+ parent_id=parent_id,
183
+ children_ids=[],
184
+ depth=depth
185
+ )
186
+
187
+ def add_child(self, child_id: str) -> None:
188
+ """
189
+ Adds a child progress indicator ID to this progress indicator.
190
+
191
+ :param child_id: The ID of the child progress indicator to add.
192
+
193
+ :returns: None
194
+ """
195
+ if child_id not in self.children_ids:
196
+ self.children_ids.append(child_id)
197
+
198
+ def remove_child(self, child_id: str) -> None:
199
+ """
200
+ Removes a child progress indicator ID from this progress indicator.
201
+
202
+ :param child_id: The ID of the child progress indicator to remove.
203
+
204
+ :returns: None
205
+ """
206
+ if child_id in self.children_ids:
207
+ self.children_ids.remove(child_id)
208
+
209
+ def __repr__(self):
210
+ reprval = repr(self.as_dict())
211
+ return reprval
@@ -0,0 +1,51 @@
1
+ """
2
+ .. module:: ccai.testbase.results.model.pipelineinfo
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for pipelineinfo.
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
+
19
+ @dataclass
20
+ class PipelineInfo:
21
+ """
22
+ Metadata describing the pipeline associated with a run.
23
+
24
+ All fields are required and must be non-empty strings. Validation is
25
+ performed automatically after initialization.
26
+
27
+ :raises ValueError: If any required field is None or an empty string.
28
+ """
29
+
30
+ id: str # identifier such as a uuid which identifies a particular venue associated with the pipeline.
31
+ name: str # name for the venue associated pipeline.
32
+ instance: str # identifier such as a uuid which identifies an instance of a pipeline.
33
+
34
+ def __post_init__(self):
35
+ """
36
+ Validates that all required fields are present and non-empty.
37
+
38
+ This method is called automatically by the dataclass after __init__.
39
+ It ensures that all PipelineInfo fields contain valid, non-empty string values.
40
+
41
+ :raises ValueError: If any required field is None or an empty string.
42
+ The error message includes the name of the invalid field.
43
+ """
44
+ required_fields = ['id', 'name', 'instance']
45
+
46
+ for field_name in required_fields:
47
+ value = getattr(self, field_name)
48
+ if value is None or (isinstance(value, str) and value.strip() == ''):
49
+ raise ValueError(
50
+ f"PipelineInfo field '{field_name}' is required and cannot be None or empty."
51
+ )