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
File without changes
@@ -0,0 +1,25 @@
1
+
2
+ __author__ = "Myron Walker"
3
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
4
+ __credits__ = []
5
+
6
+ from typing import Type
7
+
8
+ from ccai.extension.factory.factoryextension import FactoryExtension
9
+
10
+ from ccai.testbase.factoryprotocols import TestBaseFactoryProtocol
11
+
12
+ from ccai.testbase.testjob import TestJob, DefaultTestJob
13
+
14
+
15
+ class TestBaseDefaultExtensionFactory(FactoryExtension, TestBaseFactoryProtocol):
16
+
17
+ PRECEDENCE = 0
18
+
19
+ @classmethod
20
+ def get_testbase_default_job_type(cls) -> Type[TestJob]:
21
+ """
22
+ Used to lookup and return the most relevant default job type as determined
23
+ by the super factory search path.
24
+ """
25
+ return DefaultTestJob
@@ -0,0 +1,63 @@
1
+ """
2
+ .. module:: ccai.testbase
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for testbase.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+ """
8
+
9
+
10
+
11
+
12
+ __author__ = "Myron Walker"
13
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
14
+ __credits__ = []
15
+
16
+
17
+ from ccai.xmodules.xlogging.enhancedloggers import EnhancedLogger, getEnhancedLogger
18
+
19
+ logger: EnhancedLogger = getEnhancedLogger()
20
+
21
+ from ccai.testbase.declaration import attachments as attach
22
+ from ccai.testbase.declaration import registrations as register
23
+ from ccai.testbase.declaration import originations as originate
24
+
25
+ from ccai.testbase.declaration.parameterization import (
26
+ parametrize, ParametrizedCaseError
27
+ )
28
+
29
+
30
+ from ccai.testbase.verification import (
31
+ raises,
32
+ assert_dict_response_has_keys,
33
+ assert_dict_response_has_paths,
34
+ assert_equal,
35
+ assert_expression,
36
+ assert_false,
37
+ assert_greater,
38
+ assert_lessthan,
39
+ assert_list_length,
40
+ assert_list_length_greater,
41
+ assert_not_equal,
42
+ assert_true,
43
+ assert_type
44
+ )
45
+
46
+ from ccai.testbase.markers import (
47
+ mark_categories,
48
+ mark_keywords,
49
+ mark_priority,
50
+ mark_descendent_categories,
51
+ mark_descendent_keywords,
52
+ mark_descendent_priority
53
+ )
54
+
55
+ from ccai.testbase.results.model.taskingresult import (
56
+ verify_tasking_results
57
+ )
58
+
59
+ from ccai.testbase.constraints import (
60
+ Constraints,
61
+ ConstraintsCatalog,
62
+ FeatureConstraints
63
+ )
@@ -0,0 +1,110 @@
1
+ """
2
+ .. module:: breakpoints
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Declares the wellknown breakpoints available in the 'testbase' application.
5
+
6
+ .. moduleauthor:: Myron Walker <myron.walker@gmail.com>
7
+
8
+ This module defines the ``WELLKNOWN_BREAKPOINTS`` enumeration, which provides
9
+ predefined breakpoint locations within the test execution lifecycle. These
10
+ breakpoints allow developers to pause test execution at key stages for
11
+ debugging purposes.
12
+
13
+ Example Usage::
14
+
15
+ from ccai.testbase.breakpoints import WELLKNOWN_BREAKPOINTS
16
+
17
+ # Check if a breakpoint is enabled
18
+ if "test-discovery" in configured_breakpoints:
19
+ print("Test discovery breakpoint is enabled")
20
+
21
+ # Use enum member for comparison
22
+ if WELLKNOWN_BREAKPOINTS.TESTRUN_START in configured_breakpoints:
23
+ print("Testrun start breakpoint is enabled")
24
+
25
+ # String comparison works due to str inheritance
26
+ assert WELLKNOWN_BREAKPOINTS.TEST_DISCOVERY == "test-discovery"
27
+
28
+ """
29
+
30
+ __author__ = "Myron Walker"
31
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
32
+ __credits__ = []
33
+
34
+ from enum import Enum
35
+
36
+
37
+ class WELLKNOWN_BREAKPOINTS(str, Enum):
38
+ """
39
+ Enumeration of well-known breakpoint locations within the test execution lifecycle.
40
+
41
+ This enum inherits from both ``str`` and ``Enum``, allowing enum members to be
42
+ compared directly with string values. This design enables flexible breakpoint
43
+ configuration via CLI options while maintaining type safety in code.
44
+
45
+ The breakpoints defined here represent key stages in test execution where
46
+ developers may want to pause for debugging:
47
+
48
+ - **TEST_DISCOVERY**: Pause during the test discovery phase, before test
49
+ collection begins. Useful for debugging test collection issues.
50
+ - **TESTRUN_START**: Pause at the start of test execution, at the entry
51
+ point of the session() method in the sequence document. Useful for
52
+ debugging test setup and initialization.
53
+
54
+ Attributes:
55
+ TEST_DISCOVERY (str): Breakpoint identifier for the test discovery phase.
56
+ Value: ``"test-discovery"``
57
+ TESTRUN_START (str): Breakpoint identifier for the start of test execution.
58
+ Value: ``"testrun-start"``
59
+
60
+ Example::
61
+
62
+ from ccai.testbase.breakpoints import WELLKNOWN_BREAKPOINTS
63
+
64
+ # Access enum members as class attributes
65
+ bp = WELLKNOWN_BREAKPOINTS.TEST_DISCOVERY
66
+ print(bp) # Output: test-discovery
67
+
68
+ # String comparison works due to str inheritance
69
+ assert WELLKNOWN_BREAKPOINTS.TESTRUN_START == "testrun-start"
70
+
71
+ # Use in conditional checks
72
+ configured = ["test-discovery", "testrun-start"]
73
+ if WELLKNOWN_BREAKPOINTS.TEST_DISCOVERY in configured:
74
+ print("Discovery breakpoint enabled")
75
+
76
+ # Iterate over all breakpoints
77
+ for bp in WELLKNOWN_BREAKPOINTS:
78
+ print(f"Breakpoint: {bp.name} = {bp.value}")
79
+
80
+ See Also:
81
+ - :mod:`ccai.xmodules.debugging`: Core debugging infrastructure
82
+ - :class:`ccai.testbase.cli.options.DiagnosticOptionGroup`: CLI options for debugging
83
+ """
84
+
85
+ TEST_DISCOVERY = "test-discovery"
86
+ """
87
+ Breakpoint that pauses execution during the test discovery phase.
88
+
89
+ When enabled, this breakpoint triggers before test collection begins,
90
+ allowing developers to debug issues related to test discovery, module
91
+ loading, and test registration.
92
+
93
+ CLI Usage::
94
+
95
+ testbase testing run --root ./tests --debugger pdb --breakpoint test-discovery
96
+ """
97
+
98
+ TESTRUN_START = "testrun-start"
99
+ """
100
+ Breakpoint that pauses execution at the start of test execution.
101
+
102
+ When enabled, this breakpoint triggers at the entry point of the
103
+ session() method in the generated test sequence document, before
104
+ the session scope context is entered. This is useful for debugging
105
+ test initialization and setup.
106
+
107
+ CLI Usage::
108
+
109
+ testbase testing run --root ./tests --debugger debugpy --breakpoint testrun-start
110
+ """
@@ -0,0 +1,13 @@
1
+ """
2
+ .. module:: ccai.testbase.cli
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for cli.
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
+
@@ -0,0 +1,28 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.cmdtree.agents
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Agent tooling command group for AI agent consumption.
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
+ from ccai.arcli import decorators as arcli
14
+
15
+ from ccai.testbase.cli.cmdtree.agents.summary import group_testbase_agents_summary
16
+ from ccai.testbase.cli.cmdtree.agents.testresult import group_testbase_agents_testresult
17
+ from ccai.testbase.cli.cmdtree.agents.config import group_testbase_agents_config
18
+
19
+ @arcli.group("agents")
20
+ def group_testbase_agents():
21
+ """
22
+ Commands for AI agents to extract and analyze test result data.
23
+ """
24
+ return
25
+
26
+ group_testbase_agents.add_command(group_testbase_agents_summary)
27
+ group_testbase_agents.add_command(group_testbase_agents_testresult)
28
+ group_testbase_agents.add_command(group_testbase_agents_config)
@@ -0,0 +1,24 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.cmdtree.agents.config
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Config subgroup for agent commands.
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
+ from ccai.arcli import decorators as arcli
14
+
15
+ from ccai.testbase.cli.cmdtree.agents.config.extract import command_agents_config_extract
16
+
17
+ @arcli.group("config")
18
+ def group_testbase_agents_config():
19
+ """
20
+ Commands for extracting test run configuration.
21
+ """
22
+ return
23
+
24
+ group_testbase_agents_config.add_command(command_agents_config_extract)
@@ -0,0 +1,94 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.cmdtree.agents.config.extract
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Agent command for extracting test run configuration.
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
+ import json
14
+ import sys
15
+
16
+ from ccai.arcli import decorators as arcli
17
+
18
+ from ccai.testbase.cli.cmdtree.agents.formatting import (
19
+ format_kv,
20
+ format_section,
21
+ format_error,
22
+ omit_unset
23
+ )
24
+ from ccai.testbase.cli.cmdtree.agents.pathresolver import resolve_file_path
25
+
26
+
27
+ HELP_CONFIG_FILE = "Path to a startup-configuration.json file."
28
+
29
+
30
+ @arcli.option("--config-file", required=True, help=HELP_CONFIG_FILE)
31
+ @arcli.command("extract")
32
+ def command_agents_config_extract(config_file: str):
33
+ """
34
+ Extracts key configuration information from a test run startup-configuration.json file.
35
+ """
36
+
37
+ try:
38
+ resolved = resolve_file_path(config_file)
39
+ except FileNotFoundError as err:
40
+ format_error(str(err))
41
+ sys.exit(1)
42
+
43
+ try:
44
+ with open(resolved, "r") as fh:
45
+ data = json.load(fh)
46
+ except json.JSONDecodeError:
47
+ format_error(f"Invalid JSON in file: {resolved}")
48
+ sys.exit(1)
49
+
50
+ lines = []
51
+
52
+ # Extract key configuration fields
53
+ # The configuration structure varies, so we extract known fields safely
54
+ _extract_field(lines, data, "testroot", "testroot")
55
+ _extract_field(lines, data, "output_directory", "output_directory")
56
+ _extract_field(lines, data, "runid", "runid")
57
+ _extract_field(lines, data, "starttime", "starttime")
58
+
59
+ # Logging levels
60
+ log_lines = []
61
+ _extract_field(log_lines, data, "console_log_level", "console", indent=2)
62
+ _extract_field(log_lines, data, "file_log_level", "file", indent=2)
63
+ if log_lines:
64
+ lines.append(format_section("logging"))
65
+ lines.extend(log_lines)
66
+
67
+ # Debug settings
68
+ debug_lines = []
69
+ _extract_field(debug_lines, data, "debugger", "debugger", indent=2)
70
+ _extract_field(debug_lines, data, "breakpoints", "breakpoints", indent=2)
71
+ if debug_lines:
72
+ lines.append(format_section("debug"))
73
+ lines.extend(debug_lines)
74
+
75
+ if lines:
76
+ print("\n".join(lines))
77
+ else:
78
+ print("No configuration data extracted")
79
+
80
+
81
+ def _extract_field(lines: list, data: dict, source_key: str, output_key: str, indent: int = 0):
82
+ """
83
+ Extracts a field from the data dict and appends a formatted line if the value is set.
84
+
85
+ :param lines: The list of output lines to append to.
86
+ :param data: The JSON data dictionary.
87
+ :param source_key: The key to look up in the data.
88
+ :param output_key: The key name to use in the output.
89
+ :param indent: Number of spaces to indent.
90
+ """
91
+ val = data.get(source_key)
92
+ clean = omit_unset(val)
93
+ if clean is not None:
94
+ lines.append(format_kv(output_key, clean, indent=indent))
@@ -0,0 +1,71 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.cmdtree.agents.formatting
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Compact output formatting utilities for agent commands.
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
+ import sys
14
+
15
+ from typing import Optional
16
+
17
+
18
+ # Placeholder values that indicate "not set" in TestBase result artifacts
19
+ UNSET_PLACEHOLDERS = {"(not-set)", "(unknown)", "null", "", None}
20
+
21
+
22
+ def omit_unset(value) -> Optional[str]:
23
+ """
24
+ Returns the value as a string if it is a meaningful value, or None
25
+ if it matches a known placeholder.
26
+
27
+ :param value: The value to check.
28
+ :returns: The string value, or None if it should be omitted.
29
+ """
30
+ if value is None:
31
+ return None
32
+
33
+ sval = str(value)
34
+ if sval in UNSET_PLACEHOLDERS:
35
+ return None
36
+
37
+ return sval
38
+
39
+
40
+ def format_kv(key: str, value: str, indent: int = 0) -> str:
41
+ """
42
+ Formats a key-value pair as a compact output line.
43
+
44
+ :param key: The key name.
45
+ :param value: The value.
46
+ :param indent: Number of spaces to indent.
47
+ :returns: A formatted string in the form 'key: value'.
48
+ """
49
+ prefix = " " * indent
50
+ return f"{prefix}{key}: {value}"
51
+
52
+
53
+ def format_section(name: str, indent: int = 0) -> str:
54
+ """
55
+ Formats a section header line.
56
+
57
+ :param name: The section name.
58
+ :param indent: Number of spaces to indent.
59
+ :returns: A formatted section header string.
60
+ """
61
+ prefix = " " * indent
62
+ return f"{prefix}{name}:"
63
+
64
+
65
+ def format_error(message: str) -> None:
66
+ """
67
+ Prints an error message to stderr in the standard agent error format.
68
+
69
+ :param message: The error description.
70
+ """
71
+ print(f"ERROR: {message}", file=sys.stderr)
@@ -0,0 +1,119 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.cmdtree.agents.jsosparser
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Parser for JSOS (JSON Stream of Objects) result files.
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
+ from typing import List
14
+ from collections import OrderedDict
15
+
16
+ import json
17
+
18
+
19
+ def parse_file(filepath: str) -> List[dict]:
20
+ """
21
+ Parses a JSOS file into a list of dictionaries.
22
+
23
+ JSOS files use ASCII Record Separator (0x1e) to delimit JSON objects.
24
+ Falls back to blank-line splitting when no RS characters are found.
25
+
26
+ :param filepath: Path to the JSOS file.
27
+ :returns: A list of parsed JSON objects.
28
+ :raises ValueError: If a chunk contains invalid JSON.
29
+ """
30
+ entries = []
31
+
32
+ with open(filepath, "r") as fh:
33
+ content = fh.read()
34
+
35
+ chunks = _split_chunks(content)
36
+
37
+ for chunk in chunks:
38
+ chunk = chunk.strip()
39
+ if not chunk:
40
+ continue
41
+ try:
42
+ entry = json.loads(chunk)
43
+ entries.append(entry)
44
+ except json.JSONDecodeError as err:
45
+ raise ValueError(
46
+ f"Invalid JSON in JSOS file '{filepath}': {err}"
47
+ )
48
+
49
+ return entries
50
+
51
+
52
+ def filter_tests(entries: List[dict]) -> List[dict]:
53
+ """
54
+ Filters a list of JSOS entries to include only test entries (rtype=TEST).
55
+
56
+ :param entries: List of parsed JSOS entries.
57
+ :returns: List of entries where rtype is 'TEST'.
58
+ """
59
+ return [e for e in entries if e.get("rtype") == "TEST"]
60
+
61
+
62
+ def get_final_results(entries: List[dict]) -> OrderedDict:
63
+ """
64
+ Deduplicates test entries by name and returns only the final result
65
+ for each test, preserving the order in which tests first appear.
66
+
67
+ When a test has multiple entries (e.g., UNSET followed by PASSED),
68
+ the last entry wins.
69
+
70
+ :param entries: List of parsed JSOS entries.
71
+ :returns: An OrderedDict mapping test name to its final result entry.
72
+ """
73
+ test_entries = filter_tests(entries)
74
+ results = OrderedDict()
75
+
76
+ for entry in test_entries:
77
+ name = entry.get("name", "")
78
+ results[name] = entry
79
+
80
+ return results
81
+
82
+
83
+ # ASCII Record Separator character used as JSOS object delimiter
84
+ _RS = "\x1e"
85
+
86
+
87
+ def _split_chunks(content: str) -> List[str]:
88
+ """
89
+ Splits JSOS content into individual JSON object chunks.
90
+
91
+ The primary delimiter is the ASCII Record Separator (0x1e) character,
92
+ which TestBase uses to separate streaming JSON objects. If no RS
93
+ characters are found, falls back to blank-line splitting for
94
+ compatibility with test data.
95
+
96
+ :param content: The raw JSOS file content.
97
+ :returns: A list of chunk strings.
98
+ """
99
+ if _RS in content:
100
+ # Primary format: RS-delimited
101
+ return [chunk for chunk in content.split(_RS) if chunk.strip()]
102
+
103
+ # Fallback: blank-line-delimited (for test data)
104
+ chunks = []
105
+ current_lines = []
106
+
107
+ for line in content.split("\n"):
108
+ stripped = line.strip()
109
+ if stripped == "" and current_lines:
110
+ chunks.append("\n".join(current_lines))
111
+ current_lines = []
112
+ else:
113
+ if stripped:
114
+ current_lines.append(line)
115
+
116
+ if current_lines:
117
+ chunks.append("\n".join(current_lines))
118
+
119
+ return chunks
@@ -0,0 +1,34 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.cmdtree.agents.pathresolver
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: File path resolution utility for agent commands.
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
+ import os
14
+
15
+
16
+ def resolve_file_path(filepath: str) -> str:
17
+ """
18
+ Resolves a file path by expanding environment variables, expanding
19
+ the user home directory, and converting to an absolute path.
20
+
21
+ :param filepath: The file path to resolve.
22
+ :returns: The resolved absolute file path.
23
+ :raises FileNotFoundError: If the resolved path does not exist as a file.
24
+ """
25
+ resolved = os.path.abspath(
26
+ os.path.expandvars(
27
+ os.path.expanduser(filepath)
28
+ )
29
+ )
30
+
31
+ if not os.path.isfile(resolved):
32
+ raise FileNotFoundError(f"File not found: {resolved}")
33
+
34
+ return resolved
@@ -0,0 +1,26 @@
1
+ """
2
+ .. module:: ccai.testbase.cli.cmdtree.agents.summary
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Summary subgroup for agent commands.
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
+ from ccai.arcli import decorators as arcli
14
+
15
+ from ccai.testbase.cli.cmdtree.agents.summary.extract import command_agents_summary_extract
16
+ from ccai.testbase.cli.cmdtree.agents.summary.compare import command_agents_summary_compare
17
+
18
+ @arcli.group("summary")
19
+ def group_testbase_agents_summary():
20
+ """
21
+ Commands for extracting and comparing test run summaries.
22
+ """
23
+ return
24
+
25
+ group_testbase_agents_summary.add_command(command_agents_summary_extract)
26
+ group_testbase_agents_summary.add_command(command_agents_summary_compare)