From 0cbff92975c5129891ac9bc0e5b6adc49d9599b7 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Thu, 5 Nov 2026 15:24:54 -0300 Subject: [PATCH 1/9] rescan-tests: report added, modified and removed test cases Render the `changes` returned by the backend rescan: test cases added, modified and removed grouped by collection, the collections without changes, and the scripts that failed to parse with the reason. A rescan without changes now says so explicitly. The autogen models and rescan return type are updated by hand to match the backend response; regenerate them with scripts/generate_client.sh against the updated backend. Part of #1200 --- tests/test_rescan_tests.py | 97 ++++++++++++++++++- .../api/test_collections_api.py | 10 +- th_cli/api_lib_autogen/models.py | 24 +++++ th_cli/commands/rescan_tests.py | 54 ++++++++++- 4 files changed, 177 insertions(+), 8 deletions(-) diff --git a/tests/test_rescan_tests.py b/tests/test_rescan_tests.py index a61f905..05697b3 100644 --- a/tests/test_rescan_tests.py +++ b/tests/test_rescan_tests.py @@ -27,6 +27,17 @@ from th_cli.exceptions import ConfigurationError +def _rescan_response(test_collections: api_models.TestCollections, **changes: list) -> api_models.RescanTestCollections: + return api_models.RescanTestCollections( + test_collections=test_collections.test_collections, + changes=api_models.RescanChanges(collections=list(test_collections.test_collections), **changes), + ) + + +def _change(collection: str, test_case: str) -> api_models.TestCaseChange: + return api_models.TestCaseChange(collection=collection, test_suite="suite", test_case=test_case) + + @pytest.mark.unit @pytest.mark.cli class TestRescanTestsCommand: @@ -42,7 +53,7 @@ def test_rescan_tests_success( """Test successful rescan of test collections.""" # Arrange api = mock_sync_apis.test_collections_api.rescan_test_collections_api_v1_test_collections_rescan_post - api.return_value = sample_test_collections + api.return_value = _rescan_response(sample_test_collections) with patch("th_cli.commands.rescan_tests.get_client", return_value=mock_api_client): with patch("th_cli.commands.rescan_tests.SyncApis", return_value=mock_sync_apis): @@ -52,9 +63,93 @@ def test_rescan_tests_success( # Assert assert result.exit_code == 0 assert "Rescanned test collections successfully" in result.output + assert "No changes detected." in result.output api.assert_called_once() mock_api_client.close.assert_called_once() + def _invoke( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + response: api_models.RescanTestCollections, + ) -> str: + api = mock_sync_apis.test_collections_api.rescan_test_collections_api_v1_test_collections_rescan_post + api.return_value = response + + with patch("th_cli.commands.rescan_tests.get_client", return_value=mock_api_client): + with patch("th_cli.commands.rescan_tests.SyncApis", return_value=mock_sync_apis): + result = cli_runner.invoke(rescan_tests) + + assert result.exit_code == 0 + return result.output + + def test_rescan_tests_reports_changes_grouped_by_collection( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + sample_test_collections: api_models.TestCollections, + ) -> None: + """Added, modified and removed test cases are listed under their collection, + and the collections without changes are summarized.""" + names = list(sample_test_collections.test_collections) + changed, unchanged = names[0], names[1:] + response = _rescan_response( + sample_test_collections, + added=[_change(changed, "TC-FAKE-1.1-custom")], + modified=[_change(changed, "TC-ACE-1.3-custom")], + removed=[_change(changed, "TC-OLD-1.1-custom")], + ) + + output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, response) + + assert f"Rescanned test collections successfully ({len(names)} found)" in output + assert "No changes detected" not in output + lines = output.splitlines() + assert changed in lines + assert any(line.startswith(" + TC-FAKE-1.1-custom") and line.endswith("added") for line in lines) + assert any(line.startswith(" ~ TC-ACE-1.3-custom") and line.endswith("modified") for line in lines) + assert any(line.startswith(" - TC-OLD-1.1-custom") and line.endswith("removed") for line in lines) + if unchanged: + assert f"No changes in: {', '.join(unchanged)}" in output + + def test_rescan_tests_no_changes( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + sample_test_collections: api_models.TestCollections, + ) -> None: + output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, _rescan_response(sample_test_collections)) + + count = len(sample_test_collections.test_collections) + assert f"Rescanned test collections successfully ({count} found). No changes detected." in output + assert "Scripts that could not be parsed" not in output + + def test_rescan_tests_reports_parse_errors( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + sample_test_collections: api_models.TestCollections, + ) -> None: + """Scripts that failed to parse are listed with the reason, also when nothing else changed.""" + response = _rescan_response( + sample_test_collections, + errors=[ + api_models.ScriptError(script="TC_BAD_1_1.py", reason="Syntax error: invalid syntax (line 3)"), + api_models.ScriptError(reason="Failed running command:\n boom"), + ], + ) + + output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, response) + + assert "No changes detected." in output + assert "Scripts that could not be parsed (skipped):" in output + assert " ! TC_BAD_1_1.py: Syntax error: invalid syntax (line 3)" in output + assert " ! Failed running command: boom" in output + def test_rescan_tests_no_response( self, cli_runner: CliRunner, diff --git a/th_cli/api_lib_autogen/api/test_collections_api.py b/th_cli/api_lib_autogen/api/test_collections_api.py index c439214..f8bf443 100644 --- a/th_cli/api_lib_autogen/api/test_collections_api.py +++ b/th_cli/api_lib_autogen/api/test_collections_api.py @@ -35,11 +35,13 @@ def _build_for_read_test_collections_api_v1_test_collections__get(self) -> Corou def _build_for_rescan_test_collections_api_v1_test_collections_rescan_post( self, - ) -> Coroutine[Any, Any, m.TestCollections]: + ) -> Coroutine[Any, Any, m.RescanTestCollections]: """ Rescan Test Collections """ - return self.api_client.request(type_=m.TestCollections, method="POST", url="/api/v1/test_collections/rescan") + return self.api_client.request( + type_=m.RescanTestCollections, method="POST", url="/api/v1/test_collections/rescan" + ) class AsyncTestCollectionsApi(_TestCollectionsApi): @@ -49,7 +51,7 @@ async def read_test_collections_api_v1_test_collections__get(self) -> m.TestColl """ return await self._build_for_read_test_collections_api_v1_test_collections__get() - async def rescan_test_collections_api_v1_test_collections_rescan_post(self) -> m.TestCollections: + async def rescan_test_collections_api_v1_test_collections_rescan_post(self) -> m.RescanTestCollections: """ Rescan Test Collections """ @@ -64,7 +66,7 @@ def read_test_collections_api_v1_test_collections__get(self) -> m.TestCollection coroutine = self._build_for_read_test_collections_api_v1_test_collections__get() return get_event_loop().run_until_complete(coroutine) - def rescan_test_collections_api_v1_test_collections_rescan_post(self) -> m.TestCollections: + def rescan_test_collections_api_v1_test_collections_rescan_post(self) -> m.RescanTestCollections: """ Rescan Test Collections """ diff --git a/th_cli/api_lib_autogen/models.py b/th_cli/api_lib_autogen/models.py index 2c26b3b..be9f0f6 100644 --- a/th_cli/api_lib_autogen/models.py +++ b/th_cli/api_lib_autogen/models.py @@ -433,6 +433,30 @@ class TestCollections(BaseModel): test_collections: Annotated[dict[str, TestCollection], Field(title="Test Collections")] +class TestCaseChange(BaseModel): + collection: Annotated[str, Field(title="Collection")] + test_suite: Annotated[str, Field(title="Test Suite")] + test_case: Annotated[str, Field(title="Test Case")] + + +class ScriptError(BaseModel): + script: Annotated[str | None, Field(title="Script")] = None + reason: Annotated[str, Field(title="Reason")] + + +class RescanChanges(BaseModel): + added: Annotated[list[TestCaseChange] | None, Field(title="Added")] = None + modified: Annotated[list[TestCaseChange] | None, Field(title="Modified")] = None + removed: Annotated[list[TestCaseChange] | None, Field(title="Removed")] = None + errors: Annotated[list[ScriptError] | None, Field(title="Errors")] = None + collections: Annotated[list[str] | None, Field(title="Collections")] = None + + +class RescanTestCollections(BaseModel): + test_collections: Annotated[dict[str, TestCollection], Field(title="Test Collections")] + changes: RescanChanges + + class TestRunExecutionToExport(BaseModel): title: Annotated[str, Field(title="Title")] description: Annotated[str | None, Field(title="Description")] = None diff --git a/th_cli/commands/rescan_tests.py b/th_cli/commands/rescan_tests.py index 6990bab..f905567 100644 --- a/th_cli/commands/rescan_tests.py +++ b/th_cli/commands/rescan_tests.py @@ -17,10 +17,11 @@ import click from httpx import Timeout, TimeoutException +from th_cli.api_lib_autogen import models as api_models from th_cli.api_lib_autogen.api_client import SyncApis from th_cli.api_lib_autogen.exceptions import ResponseHandlingException, UnexpectedResponse from th_cli.client import get_client -from th_cli.colorize import colorize_cmd_help, colorize_help, colorize_success +from th_cli.colorize import colorize_cmd_help, colorize_help, colorize_success, colorize_warning from th_cli.exceptions import CLIError, handle_api_error # Rescanning regenerates the Python test JSON files via the SDK container, @@ -28,6 +29,54 @@ RESCAN_TIMEOUT = Timeout(120.0, connect=10.0) # 120s total, 10s connect +def _render_changes(changes: api_models.RescanChanges) -> list[str]: + """Render the test case changes grouped by collection, followed by the collections + that did not change.""" + markers = (("+", "added", changes.added), ("~", "modified", changes.modified), ("-", "removed", changes.removed)) + + lines_by_collection: dict[str, list[str]] = {} + for marker, label, test_cases in markers: + for change in test_cases or []: + lines_by_collection.setdefault(change.collection, []).append(f" {marker} {change.test_case:<30} {label}") + + lines: list[str] = [] + for collection, collection_lines in lines_by_collection.items(): + lines.append("") + lines.append(collection) + lines.extend(collection_lines) + + unchanged = [name for name in changes.collections or [] if name not in lines_by_collection] + if unchanged: + lines.append(f"No changes in: {', '.join(unchanged)}") + return lines + + +def _render_errors(errors: list[api_models.ScriptError]) -> list[str]: + lines = ["", "Scripts that could not be parsed (skipped):"] + for error in errors: + reason = " ".join(error.reason.split()) + lines.append(f" ! {error.script}: {reason}" if error.script else f" ! {reason}") + return lines + + +def print_rescan_report(response: api_models.RescanTestCollections) -> None: + """Print the outcome of a rescan, including what it changed.""" + collection_count = len(response.test_collections) + changes = response.changes + has_changes = bool(changes.added or changes.modified or changes.removed) + + summary = f"Rescanned test collections successfully ({collection_count} found)" + if has_changes: + click.echo(colorize_success(summary)) + for line in _render_changes(changes): + click.echo(line) + else: + click.echo(colorize_success(f"{summary}. No changes detected.")) + + if changes.errors: + click.echo(colorize_warning("\n".join(_render_errors(changes.errors)))) + + @click.command( short_help=colorize_help("Rescan available test collections"), help=colorize_cmd_help( @@ -48,8 +97,7 @@ def rescan_tests() -> None: if test_collections is None: raise CLIError("Server did not return test_collections") - collection_count = len(test_collections.test_collections) - click.echo(colorize_success(f"Rescanned test collections successfully ({collection_count} found)")) + print_rescan_report(test_collections) except CLIError: raise # Re-raise CLI Errors as-is except ResponseHandlingException as e: From 82b3af846769510b42f91ce218a88b543a802bb2 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 6 Nov 2026 09:38:18 -0300 Subject: [PATCH 2/9] rescan-tests: use the optional `changes` field on TestCollections Match the backend, which now returns the change report on TestCollections instead of a separate response model (that made datamodel-codegen emit an invalid `class TestCollections(TestCollections2)`). Fall back to the plain summary when the backend response has no `changes`. Part of #1200 --- tests/test_rescan_tests.py | 24 +++++++++++++++---- .../api/test_collections_api.py | 10 ++++---- th_cli/api_lib_autogen/models.py | 18 ++++++-------- th_cli/commands/rescan_tests.py | 13 ++++++---- 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/tests/test_rescan_tests.py b/tests/test_rescan_tests.py index 05697b3..ebbe271 100644 --- a/tests/test_rescan_tests.py +++ b/tests/test_rescan_tests.py @@ -27,10 +27,12 @@ from th_cli.exceptions import ConfigurationError -def _rescan_response(test_collections: api_models.TestCollections, **changes: list) -> api_models.RescanTestCollections: - return api_models.RescanTestCollections( +def _rescan_response(test_collections: api_models.TestCollections, **changes: list) -> api_models.TestCollections: + changes_by_kind: dict[str, list] = {"added": [], "modified": [], "removed": [], "errors": []} + changes_by_kind.update(changes) + return api_models.TestCollections( test_collections=test_collections.test_collections, - changes=api_models.RescanChanges(collections=list(test_collections.test_collections), **changes), + changes=api_models.RescanChanges(collections=list(test_collections.test_collections), **changes_by_kind), ) @@ -72,7 +74,7 @@ def _invoke( cli_runner: CliRunner, mock_sync_apis: Mock, mock_api_client: Mock, - response: api_models.RescanTestCollections, + response: api_models.TestCollections, ) -> str: api = mock_sync_apis.test_collections_api.rescan_test_collections_api_v1_test_collections_rescan_post api.return_value = response @@ -150,6 +152,20 @@ def test_rescan_tests_reports_parse_errors( assert " ! TC_BAD_1_1.py: Syntax error: invalid syntax (line 3)" in output assert " ! Failed running command: boom" in output + def test_rescan_tests_backend_without_change_report( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + sample_test_collections: api_models.TestCollections, + ) -> None: + """A response without `changes` (older backend) falls back to the plain summary.""" + output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, sample_test_collections) + + count = len(sample_test_collections.test_collections) + assert f"Rescanned test collections successfully ({count} found)" in output + assert "No changes detected" not in output + def test_rescan_tests_no_response( self, cli_runner: CliRunner, diff --git a/th_cli/api_lib_autogen/api/test_collections_api.py b/th_cli/api_lib_autogen/api/test_collections_api.py index f8bf443..c439214 100644 --- a/th_cli/api_lib_autogen/api/test_collections_api.py +++ b/th_cli/api_lib_autogen/api/test_collections_api.py @@ -35,13 +35,11 @@ def _build_for_read_test_collections_api_v1_test_collections__get(self) -> Corou def _build_for_rescan_test_collections_api_v1_test_collections_rescan_post( self, - ) -> Coroutine[Any, Any, m.RescanTestCollections]: + ) -> Coroutine[Any, Any, m.TestCollections]: """ Rescan Test Collections """ - return self.api_client.request( - type_=m.RescanTestCollections, method="POST", url="/api/v1/test_collections/rescan" - ) + return self.api_client.request(type_=m.TestCollections, method="POST", url="/api/v1/test_collections/rescan") class AsyncTestCollectionsApi(_TestCollectionsApi): @@ -51,7 +49,7 @@ async def read_test_collections_api_v1_test_collections__get(self) -> m.TestColl """ return await self._build_for_read_test_collections_api_v1_test_collections__get() - async def rescan_test_collections_api_v1_test_collections_rescan_post(self) -> m.RescanTestCollections: + async def rescan_test_collections_api_v1_test_collections_rescan_post(self) -> m.TestCollections: """ Rescan Test Collections """ @@ -66,7 +64,7 @@ def read_test_collections_api_v1_test_collections__get(self) -> m.TestCollection coroutine = self._build_for_read_test_collections_api_v1_test_collections__get() return get_event_loop().run_until_complete(coroutine) - def rescan_test_collections_api_v1_test_collections_rescan_post(self) -> m.RescanTestCollections: + def rescan_test_collections_api_v1_test_collections_rescan_post(self) -> m.TestCollections: """ Rescan Test Collections """ diff --git a/th_cli/api_lib_autogen/models.py b/th_cli/api_lib_autogen/models.py index be9f0f6..1954e26 100644 --- a/th_cli/api_lib_autogen/models.py +++ b/th_cli/api_lib_autogen/models.py @@ -429,10 +429,6 @@ class TestCollection(BaseModel): test_suites: Annotated[dict[str, TestSuite], Field(title="Test Suites")] -class TestCollections(BaseModel): - test_collections: Annotated[dict[str, TestCollection], Field(title="Test Collections")] - - class TestCaseChange(BaseModel): collection: Annotated[str, Field(title="Collection")] test_suite: Annotated[str, Field(title="Test Suite")] @@ -445,16 +441,16 @@ class ScriptError(BaseModel): class RescanChanges(BaseModel): - added: Annotated[list[TestCaseChange] | None, Field(title="Added")] = None - modified: Annotated[list[TestCaseChange] | None, Field(title="Modified")] = None - removed: Annotated[list[TestCaseChange] | None, Field(title="Removed")] = None - errors: Annotated[list[ScriptError] | None, Field(title="Errors")] = None - collections: Annotated[list[str] | None, Field(title="Collections")] = None + added: Annotated[list[TestCaseChange], Field(title="Added")] + modified: Annotated[list[TestCaseChange], Field(title="Modified")] + removed: Annotated[list[TestCaseChange], Field(title="Removed")] + errors: Annotated[list[ScriptError], Field(title="Errors")] + collections: Annotated[list[str], Field(title="Collections")] -class RescanTestCollections(BaseModel): +class TestCollections(BaseModel): test_collections: Annotated[dict[str, TestCollection], Field(title="Test Collections")] - changes: RescanChanges + changes: RescanChanges | None = None class TestRunExecutionToExport(BaseModel): diff --git a/th_cli/commands/rescan_tests.py b/th_cli/commands/rescan_tests.py index f905567..f5778ec 100644 --- a/th_cli/commands/rescan_tests.py +++ b/th_cli/commands/rescan_tests.py @@ -36,7 +36,7 @@ def _render_changes(changes: api_models.RescanChanges) -> list[str]: lines_by_collection: dict[str, list[str]] = {} for marker, label, test_cases in markers: - for change in test_cases or []: + for change in test_cases: lines_by_collection.setdefault(change.collection, []).append(f" {marker} {change.test_case:<30} {label}") lines: list[str] = [] @@ -45,7 +45,7 @@ def _render_changes(changes: api_models.RescanChanges) -> list[str]: lines.append(collection) lines.extend(collection_lines) - unchanged = [name for name in changes.collections or [] if name not in lines_by_collection] + unchanged = [name for name in changes.collections if name not in lines_by_collection] if unchanged: lines.append(f"No changes in: {', '.join(unchanged)}") return lines @@ -59,13 +59,18 @@ def _render_errors(errors: list[api_models.ScriptError]) -> list[str]: return lines -def print_rescan_report(response: api_models.RescanTestCollections) -> None: +def print_rescan_report(response: api_models.TestCollections) -> None: """Print the outcome of a rescan, including what it changed.""" collection_count = len(response.test_collections) changes = response.changes - has_changes = bool(changes.added or changes.modified or changes.removed) summary = f"Rescanned test collections successfully ({collection_count} found)" + if changes is None: + # Backend that predates the change report + click.echo(colorize_success(summary)) + return + + has_changes = bool(changes.added or changes.modified or changes.removed) if has_changes: click.echo(colorize_success(summary)) for line in _render_changes(changes): From 6d6352c6fc34c569edf9fb3584894b53a935af3c Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 6 Nov 2026 18:16:05 -0300 Subject: [PATCH 3/9] rescan-tests: list custom files that override SDK modules Print the backend's changes.custom_overrides: custom/*.py files that replace an SDK module of the same name (used by every test that imports them), and, apart, same-name copies that nothing imports. A backend without the field, or with empty lists, prints nothing extra. The models are edited by hand to match the backend schema; regenerate with scripts/generate_client.sh once the backend change is merged. Refs project-chip/certification-tool#1200 --- tests/test_rescan_tests.py | 40 ++++++++++++++++++++++++++++++-- th_cli/api_lib_autogen/models.py | 6 +++++ th_cli/commands/rescan_tests.py | 18 ++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/tests/test_rescan_tests.py b/tests/test_rescan_tests.py index ebbe271..b616069 100644 --- a/tests/test_rescan_tests.py +++ b/tests/test_rescan_tests.py @@ -27,8 +27,8 @@ from th_cli.exceptions import ConfigurationError -def _rescan_response(test_collections: api_models.TestCollections, **changes: list) -> api_models.TestCollections: - changes_by_kind: dict[str, list] = {"added": [], "modified": [], "removed": [], "errors": []} +def _rescan_response(test_collections: api_models.TestCollections, **changes: object) -> api_models.TestCollections: + changes_by_kind: dict[str, object] = {"added": [], "modified": [], "removed": [], "errors": []} changes_by_kind.update(changes) return api_models.TestCollections( test_collections=test_collections.test_collections, @@ -152,6 +152,42 @@ def test_rescan_tests_reports_parse_errors( assert " ! TC_BAD_1_1.py: Syntax error: invalid syntax (line 3)" in output assert " ! Failed running command: boom" in output + def test_rescan_tests_reports_custom_overrides( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + sample_test_collections: api_models.TestCollections, + ) -> None: + """Custom files overriding SDK modules are listed, separately from same-name copies nothing imports.""" + response = _rescan_response( + sample_test_collections, + custom_overrides=api_models.CustomOverrides( + overriding=["TC_SUTestBase.py"], unused_copies=["TC_ACE_1_3.py"] + ), + ) + + output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, response) + + assert "No changes detected." in output + assert "Custom files overriding SDK modules (used by every test that imports them):" in output + assert " ! TC_SUTestBase.py" in output + assert "override nothing" in output + assert " - TC_ACE_1_3.py" in output + + def test_rescan_tests_no_custom_overrides_prints_nothing( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + sample_test_collections: api_models.TestCollections, + ) -> None: + response = _rescan_response(sample_test_collections, custom_overrides=api_models.CustomOverrides()) + + output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, response) + + assert "overriding SDK modules" not in output + def test_rescan_tests_backend_without_change_report( self, cli_runner: CliRunner, diff --git a/th_cli/api_lib_autogen/models.py b/th_cli/api_lib_autogen/models.py index 1954e26..2d240ff 100644 --- a/th_cli/api_lib_autogen/models.py +++ b/th_cli/api_lib_autogen/models.py @@ -440,12 +440,18 @@ class ScriptError(BaseModel): reason: Annotated[str, Field(title="Reason")] +class CustomOverrides(BaseModel): + overriding: Annotated[list[str], Field(title="Overriding")] = [] + unused_copies: Annotated[list[str], Field(title="Unused Copies")] = [] + + class RescanChanges(BaseModel): added: Annotated[list[TestCaseChange], Field(title="Added")] modified: Annotated[list[TestCaseChange], Field(title="Modified")] removed: Annotated[list[TestCaseChange], Field(title="Removed")] errors: Annotated[list[ScriptError], Field(title="Errors")] collections: Annotated[list[str], Field(title="Collections")] + custom_overrides: CustomOverrides | None = None class TestCollections(BaseModel): diff --git a/th_cli/commands/rescan_tests.py b/th_cli/commands/rescan_tests.py index f5778ec..d60b444 100644 --- a/th_cli/commands/rescan_tests.py +++ b/th_cli/commands/rescan_tests.py @@ -59,6 +59,19 @@ def _render_errors(errors: list[api_models.ScriptError]) -> list[str]: return lines +def _render_overrides(overrides: api_models.CustomOverrides) -> list[str]: + lines: list[str] = [] + if overrides.overriding: + lines.append("") + lines.append("Custom files overriding SDK modules (used by every test that imports them):") + lines.extend(f" ! {name}" for name in overrides.overriding) + if overrides.unused_copies: + lines.append("") + lines.append("Custom files with the same name as an SDK file that nothing imports (override nothing):") + lines.extend(f" - {name}" for name in overrides.unused_copies) + return lines + + def print_rescan_report(response: api_models.TestCollections) -> None: """Print the outcome of a rescan, including what it changed.""" collection_count = len(response.test_collections) @@ -81,6 +94,11 @@ def print_rescan_report(response: api_models.TestCollections) -> None: if changes.errors: click.echo(colorize_warning("\n".join(_render_errors(changes.errors)))) + if changes.custom_overrides: + override_lines = _render_overrides(changes.custom_overrides) + if override_lines: + click.echo(colorize_warning("\n".join(override_lines))) + @click.command( short_help=colorize_help("Rescan available test collections"), From 81e8c1b7b918e65032b5317f3c8812036e36f4ba Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 6 Nov 2026 22:46:39 +0000 Subject: [PATCH 4/9] Updated models after gen_client --- th_cli/api_lib_autogen/models.py | 64 +++++++++++++++++--------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/th_cli/api_lib_autogen/models.py b/th_cli/api_lib_autogen/models.py index 2d240ff..34dcd8c 100644 --- a/th_cli/api_lib_autogen/models.py +++ b/th_cli/api_lib_autogen/models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: -# filename: tmp6b_blt9g.json -# timestamp: 2026-10-28T16:52:46+00:00 +# filename: tmpfqda1arb.json +# timestamp: 2026-11-06T22:44:49+00:00 from __future__ import annotations @@ -42,6 +42,11 @@ class ChipServerInfo(BaseModel): manual_pairing_code: Annotated[str | None, Field(title="Manual Pairing Code")] = None +class CustomOverrides(BaseModel): + overriding: Annotated[list[str] | None, Field(title="Overriding")] = [] + unused_copies: Annotated[list[str] | None, Field(title="Unused Copies")] = [] + + class Name(RootModel[str]): root: Annotated[str, Field(title="Name")] @@ -76,6 +81,11 @@ class PICSItem(BaseModel): enabled: Annotated[bool, Field(title="Enabled")] +class ScriptError(BaseModel): + script: Annotated[str | None, Field(title="Script")] = None + reason: Annotated[str, Field(title="Reason")] + + class THConfig(BaseModel): prompt_timeout_seconds: Annotated[int | None, Field(title="Prompt Timeout Seconds")] = 60 enable_realtime_python_test_logs: Annotated[bool | None, Field(title="Enable Realtime Python Test Logs")] = None @@ -83,6 +93,12 @@ class THConfig(BaseModel): sdk_container_apps_dir: Annotated[str | None, Field(title="Sdk Container Apps Dir")] = None +class TestCaseChange(BaseModel): + collection: Annotated[str, Field(title="Collection")] + test_suite: Annotated[str, Field(title="Test Suite")] + test_case: Annotated[str, Field(title="Test Case")] + + class PublicId(RootModel[str]): root: Annotated[str, Field(title="Public Id")] @@ -279,6 +295,21 @@ class PICSCluster(BaseModel): ] +class RescanChanges(BaseModel): + added: Annotated[list[TestCaseChange], Field(title="Added")] + modified: Annotated[list[TestCaseChange], Field(title="Modified")] + removed: Annotated[list[TestCaseChange], Field(title="Removed")] + errors: Annotated[list[ScriptError], Field(title="Errors")] + collections: Annotated[list[str], Field(title="Collections")] + custom_overrides: Annotated[ + CustomOverrides | None, + Field( + default_factory=lambda: CustomOverrides.model_validate({"overriding": [], "unused_copies": []}), + title="Custom Overrides", + ), + ] + + class TestCase(BaseModel): metadata: TestMetadata @@ -360,7 +391,7 @@ class TestRunExecutionWithStats(BaseModel): test_case_stats: TestRunExecutionStats -class TestSuite(BaseModel): +class TestSuiteModel(BaseModel): metadata: TestMetadata test_cases: Annotated[dict[str, TestCase], Field(title="Test Cases")] @@ -426,32 +457,7 @@ class ProjectUpdate(BaseModel): class TestCollection(BaseModel): name: Annotated[str, Field(title="Name")] path: Annotated[str, Field(title="Path")] - test_suites: Annotated[dict[str, TestSuite], Field(title="Test Suites")] - - -class TestCaseChange(BaseModel): - collection: Annotated[str, Field(title="Collection")] - test_suite: Annotated[str, Field(title="Test Suite")] - test_case: Annotated[str, Field(title="Test Case")] - - -class ScriptError(BaseModel): - script: Annotated[str | None, Field(title="Script")] = None - reason: Annotated[str, Field(title="Reason")] - - -class CustomOverrides(BaseModel): - overriding: Annotated[list[str], Field(title="Overriding")] = [] - unused_copies: Annotated[list[str], Field(title="Unused Copies")] = [] - - -class RescanChanges(BaseModel): - added: Annotated[list[TestCaseChange], Field(title="Added")] - modified: Annotated[list[TestCaseChange], Field(title="Modified")] - removed: Annotated[list[TestCaseChange], Field(title="Removed")] - errors: Annotated[list[ScriptError], Field(title="Errors")] - collections: Annotated[list[str], Field(title="Collections")] - custom_overrides: CustomOverrides | None = None + test_suites: Annotated[dict[str, TestSuiteModel], Field(title="Test Suites")] class TestCollections(BaseModel): From 76dba1579bc2c45293c790f65e9ade593b7fed8e Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 6 Nov 2026 22:47:32 +0000 Subject: [PATCH 5/9] Updated shared_constants after gen_client --- th_cli/shared_constants.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/th_cli/shared_constants.py b/th_cli/shared_constants.py index 788c02b..ea818ec 100644 --- a/th_cli/shared_constants.py +++ b/th_cli/shared_constants.py @@ -17,14 +17,14 @@ # limitations under the License. # -from enum import Enum +from enum import StrEnum """ Shared constants across the application. """ -class TestStateEnum(str, Enum): +class TestStateEnum(StrEnum): __test__ = False # Needed to indicate to PyTest that this is not a "test" PENDING = "pending" EXECUTING = "executing" @@ -37,7 +37,7 @@ class TestStateEnum(str, Enum): # Enum Keys for different types of messages currently supported by the tool -class MessageTypeEnum(str, Enum): +class MessageTypeEnum(StrEnum): PROMPT_REQUEST = "prompt_request" PROMPT_RESPONSE = "prompt_response" OPTIONS_REQUEST = "options_request" @@ -54,13 +54,13 @@ class MessageTypeEnum(str, Enum): # Enum keys used with messages at the top level -class MessageKeysEnum(str, Enum): +class MessageKeysEnum(StrEnum): TYPE = "type" PAYLOAD = "payload" # Enum for DUT Pairing Modes -class DutPairingModeEnum(str, Enum): +class DutPairingModeEnum(StrEnum): ON_NETWORK = "onnetwork" BLE_WIFI = "ble-wifi" NFC_WIFI = "nfc-wifi" From 3f079c09c1ff78f24f8d5b0e3dd953d1d225dcf1 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 6 Nov 2026 20:05:21 -0300 Subject: [PATCH 6/9] rescan-tests: report custom file changes instead of override lists Print the backend's changes.custom_files as a "Custom files" block: files added, modified or removed in custom/, with "(replaces sdk/X)" on the ones that replace an SDK module. Replaces the two override lists, which listed same-name copies of SDK tests that replace nothing. A change limited to custom files, a helper for example, is no longer reported as "No changes detected". The models are edited by hand to match the backend schema; regenerate with scripts/generate_client.sh once the backend change is merged. Refs project-chip/certification-tool#1200 --- tests/test_rescan_tests.py | 70 ++++++++++++++++++++++++++------ th_cli/api_lib_autogen/models.py | 20 +++++---- th_cli/commands/rescan_tests.py | 43 ++++++++++++-------- 3 files changed, 97 insertions(+), 36 deletions(-) diff --git a/tests/test_rescan_tests.py b/tests/test_rescan_tests.py index b616069..d7dd5a0 100644 --- a/tests/test_rescan_tests.py +++ b/tests/test_rescan_tests.py @@ -152,41 +152,87 @@ def test_rescan_tests_reports_parse_errors( assert " ! TC_BAD_1_1.py: Syntax error: invalid syntax (line 3)" in output assert " ! Failed running command: boom" in output - def test_rescan_tests_reports_custom_overrides( + def test_rescan_tests_reports_custom_file_changes( self, cli_runner: CliRunner, mock_sync_apis: Mock, mock_api_client: Mock, sample_test_collections: api_models.TestCollections, ) -> None: - """Custom files overriding SDK modules are listed, separately from same-name copies nothing imports.""" + """Added, modified and removed files in custom/ are listed, flagging the ones that replace an SDK module.""" response = _rescan_response( sample_test_collections, - custom_overrides=api_models.CustomOverrides( - overriding=["TC_SUTestBase.py"], unused_copies=["TC_ACE_1_3.py"] + custom_files=api_models.CustomFileChanges( + added=[api_models.CustomFileChange(name="TC_SUTestBase.py", replaces_sdk=True)], + modified=[api_models.CustomFileChange(name="TC_ACE_1_3.py")], + removed=[api_models.CustomFileChange(name="TC_OLD_1_1.py")], ), ) output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, response) - assert "No changes detected." in output - assert "Custom files overriding SDK modules (used by every test that imports them):" in output - assert " ! TC_SUTestBase.py" in output - assert "override nothing" in output - assert " - TC_ACE_1_3.py" in output + assert "Custom files" in output + assert " + TC_SUTestBase.py" in output + assert "added (replaces sdk/TC_SUTestBase.py)" in output + assert " ~ TC_ACE_1_3.py" in output + assert "modified" in output + assert " - TC_OLD_1_1.py" in output + assert "removed" in output + # Only files that replace an SDK module get the note. + assert "sdk/TC_ACE_1_3.py" not in output + assert "sdk/TC_OLD_1_1.py" not in output + + def test_rescan_tests_custom_file_changes_alone_are_not_reported_as_no_changes( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + sample_test_collections: api_models.TestCollections, + ) -> None: + """A changed helper has no test case, but the rescan did pick up a change.""" + response = _rescan_response( + sample_test_collections, + custom_files=api_models.CustomFileChanges(modified=[api_models.CustomFileChange(name="Helper.py")]), + ) + + output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, response) + + count = len(sample_test_collections.test_collections) + assert f"Rescanned test collections successfully ({count} found)" in output + assert "No changes detected" not in output + assert " ~ Helper.py" in output - def test_rescan_tests_no_custom_overrides_prints_nothing( + def test_rescan_tests_removed_file_that_replaced_an_sdk_module( self, cli_runner: CliRunner, mock_sync_apis: Mock, mock_api_client: Mock, sample_test_collections: api_models.TestCollections, ) -> None: - response = _rescan_response(sample_test_collections, custom_overrides=api_models.CustomOverrides()) + response = _rescan_response( + sample_test_collections, + custom_files=api_models.CustomFileChanges( + removed=[api_models.CustomFileChange(name="Helper.py", replaces_sdk=True)] + ), + ) output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, response) - assert "overriding SDK modules" not in output + assert "removed (was replacing sdk/Helper.py)" in output + + def test_rescan_tests_no_custom_file_changes_prints_nothing_extra( + self, + cli_runner: CliRunner, + mock_sync_apis: Mock, + mock_api_client: Mock, + sample_test_collections: api_models.TestCollections, + ) -> None: + response = _rescan_response(sample_test_collections, custom_files=api_models.CustomFileChanges()) + + output = self._invoke(cli_runner, mock_sync_apis, mock_api_client, response) + + assert "No changes detected." in output + assert "Custom files" not in output def test_rescan_tests_backend_without_change_report( self, diff --git a/th_cli/api_lib_autogen/models.py b/th_cli/api_lib_autogen/models.py index 34dcd8c..44d5c6d 100644 --- a/th_cli/api_lib_autogen/models.py +++ b/th_cli/api_lib_autogen/models.py @@ -42,9 +42,15 @@ class ChipServerInfo(BaseModel): manual_pairing_code: Annotated[str | None, Field(title="Manual Pairing Code")] = None -class CustomOverrides(BaseModel): - overriding: Annotated[list[str] | None, Field(title="Overriding")] = [] - unused_copies: Annotated[list[str] | None, Field(title="Unused Copies")] = [] +class CustomFileChange(BaseModel): + name: Annotated[str, Field(title="Name")] + replaces_sdk: Annotated[bool | None, Field(title="Replaces Sdk")] = False + + +class CustomFileChanges(BaseModel): + added: Annotated[list[CustomFileChange] | None, Field(title="Added")] = [] + modified: Annotated[list[CustomFileChange] | None, Field(title="Modified")] = [] + removed: Annotated[list[CustomFileChange] | None, Field(title="Removed")] = [] class Name(RootModel[str]): @@ -301,11 +307,11 @@ class RescanChanges(BaseModel): removed: Annotated[list[TestCaseChange], Field(title="Removed")] errors: Annotated[list[ScriptError], Field(title="Errors")] collections: Annotated[list[str], Field(title="Collections")] - custom_overrides: Annotated[ - CustomOverrides | None, + custom_files: Annotated[ + CustomFileChanges | None, Field( - default_factory=lambda: CustomOverrides.model_validate({"overriding": [], "unused_copies": []}), - title="Custom Overrides", + default_factory=lambda: CustomFileChanges.model_validate({"added": [], "modified": [], "removed": []}), + title="Custom Files", ), ] diff --git a/th_cli/commands/rescan_tests.py b/th_cli/commands/rescan_tests.py index d60b444..bded5eb 100644 --- a/th_cli/commands/rescan_tests.py +++ b/th_cli/commands/rescan_tests.py @@ -59,16 +59,25 @@ def _render_errors(errors: list[api_models.ScriptError]) -> list[str]: return lines -def _render_overrides(overrides: api_models.CustomOverrides) -> list[str]: +def _render_custom_files(custom_files: api_models.CustomFileChanges) -> list[str]: + """Render the files added, modified or removed in custom/, flagging the ones that + replace an SDK module.""" + markers = ( + ("+", "added", custom_files.added), + ("~", "modified", custom_files.modified), + ("-", "removed", custom_files.removed), + ) + lines: list[str] = [] - if overrides.overriding: - lines.append("") - lines.append("Custom files overriding SDK modules (used by every test that imports them):") - lines.extend(f" ! {name}" for name in overrides.overriding) - if overrides.unused_copies: - lines.append("") - lines.append("Custom files with the same name as an SDK file that nothing imports (override nothing):") - lines.extend(f" - {name}" for name in overrides.unused_copies) + for marker, label, files in markers: + for file in files or []: + replaces = "" + if file.replaces_sdk: + replaces = f" ({'was replacing' if label == 'removed' else 'replaces'} sdk/{file.name})" + lines.append(f" {marker} {file.name:<30} {label}{replaces}") + if lines: + lines.insert(0, "") + lines.insert(1, "Custom files") return lines @@ -83,10 +92,15 @@ def print_rescan_report(response: api_models.TestCollections) -> None: click.echo(colorize_success(summary)) return - has_changes = bool(changes.added or changes.modified or changes.removed) - if has_changes: + test_cases_changed = bool(changes.added or changes.modified or changes.removed) + custom_file_lines = _render_custom_files(changes.custom_files) if changes.custom_files else [] + + if test_cases_changed or custom_file_lines: click.echo(colorize_success(summary)) - for line in _render_changes(changes): + if test_cases_changed: + for line in _render_changes(changes): + click.echo(line) + for line in custom_file_lines: click.echo(line) else: click.echo(colorize_success(f"{summary}. No changes detected.")) @@ -94,11 +108,6 @@ def print_rescan_report(response: api_models.TestCollections) -> None: if changes.errors: click.echo(colorize_warning("\n".join(_render_errors(changes.errors)))) - if changes.custom_overrides: - override_lines = _render_overrides(changes.custom_overrides) - if override_lines: - click.echo(colorize_warning("\n".join(override_lines))) - @click.command( short_help=colorize_help("Rescan available test collections"), From 323bfc667770352c459d523a142c98e1c58818d2 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 6 Nov 2026 20:17:19 -0300 Subject: [PATCH 7/9] rescan-tests: colorize changes by type Color the added, modified and removed lines green, yellow and red, for test cases and custom files. The +, ~ and - markers and the labels stay, so the output reads the same without color. Honors TH_CLI_NO_COLOR and is stripped when the output is not a terminal. Refs project-chip/certification-tool#1200 --- tests/test_colorize.py | 34 +++++++++++++++++++++++++++++++++ th_cli/colorize.py | 28 +++++++++++++++++++++++++++ th_cli/commands/rescan_tests.py | 7 ++++--- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/tests/test_colorize.py b/tests/test_colorize.py index 0d7546e..56f1ef0 100644 --- a/tests/test_colorize.py +++ b/tests/test_colorize.py @@ -15,12 +15,14 @@ # """Unit tests for th_cli/colorize.py.""" +import click import pytest from th_cli.colorize import ( ColorConfig, HierarchyEnum, TextTypeEnum, + colorize_change, colorize_cmd_help, colorize_dump, colorize_error, @@ -436,3 +438,35 @@ def test_non_empty_with_colors_enabled(self): set_colors_enabled(True) result = italic("hello") assert "hello" in result + + +# --------------------------------------------------------------------------- +# colorize_change +# --------------------------------------------------------------------------- + + +@pytest.mark.unit +class TestColorizeChange: + def test_plain_when_colors_disabled(self): + set_colors_enabled(False) + assert colorize_change("added", " + TC_A_1_1.py") == " + TC_A_1_1.py" + + @pytest.mark.parametrize("kind", ["added", "modified", "removed"]) + def test_styled_text_keeps_the_content_when_colors_enabled(self, kind): + set_colors_enabled(True) + result = colorize_change(kind, " ~ TC_A_1_1.py") + assert result != " ~ TC_A_1_1.py" + assert click.unstyle(result) == " ~ TC_A_1_1.py" + + def test_each_kind_has_its_own_color(self): + set_colors_enabled(True) + results = {kind: colorize_change(kind, "x") for kind in ("added", "modified", "removed")} + assert len(set(results.values())) == 3 + + def test_get_change_color(self): + cfg = ColorConfig() + assert cfg.get_change_color("added") == "green" + assert cfg.get_change_color("MODIFIED") == "yellow" + assert cfg.get_change_color("removed") == "red" + assert cfg.get_change_color("unknown") == "white" + diff --git a/th_cli/colorize.py b/th_cli/colorize.py index 724043a..c4ed773 100644 --- a/th_cli/colorize.py +++ b/th_cli/colorize.py @@ -71,6 +71,13 @@ class ColorConfig: HierarchyEnum.TEST_STEP.value: "bright_black", } + # Colors for the kind of change reported by rescan-tests + CHANGE_COLORS: dict[str, str] = { + "added": "green", + "modified": "yellow", + "removed": "red", + } + # Default colors for logs TEXT_COLORS: dict[str, str] = { TextTypeEnum.CMD.value: "bright_blue", @@ -109,6 +116,10 @@ def get_hierarchy_color(self, level: str) -> str: """Get color for a hierarchy level.""" return self.TEST_HIERARCHY_COLORS.get(level.lower(), "white") + def get_change_color(self, kind: str) -> str: + """Get color for a kind of change (added, modified, removed).""" + return self.CHANGE_COLORS.get(kind.lower(), "white") + # Global color configuration instance color_config = ColorConfig() @@ -153,6 +164,23 @@ def colorize_state(state_name: str) -> str: return click.style(state_text, fg=color, bold=True) +def colorize_change(kind: str, text: str) -> str: + """ + Colorize a line describing an added, modified or removed item. + + Args: + kind: The kind of change: "added", "modified" or "removed" + text: The text to colorize + + Returns: + Colored string if colors are enabled, plain string otherwise + """ + if not color_config.colors_enabled: + return text + + return click.style(text, fg=color_config.get_change_color(kind)) + + def colorize_runner_state(runner_state_name: str) -> str: """ Colorize test runner state based on semantic meaning. diff --git a/th_cli/commands/rescan_tests.py b/th_cli/commands/rescan_tests.py index bded5eb..12a7fb6 100644 --- a/th_cli/commands/rescan_tests.py +++ b/th_cli/commands/rescan_tests.py @@ -21,7 +21,7 @@ from th_cli.api_lib_autogen.api_client import SyncApis from th_cli.api_lib_autogen.exceptions import ResponseHandlingException, UnexpectedResponse from th_cli.client import get_client -from th_cli.colorize import colorize_cmd_help, colorize_help, colorize_success, colorize_warning +from th_cli.colorize import colorize_change, colorize_cmd_help, colorize_help, colorize_success, colorize_warning from th_cli.exceptions import CLIError, handle_api_error # Rescanning regenerates the Python test JSON files via the SDK container, @@ -37,7 +37,8 @@ def _render_changes(changes: api_models.RescanChanges) -> list[str]: lines_by_collection: dict[str, list[str]] = {} for marker, label, test_cases in markers: for change in test_cases: - lines_by_collection.setdefault(change.collection, []).append(f" {marker} {change.test_case:<30} {label}") + line = f" {marker} {change.test_case:<30} {label}" + lines_by_collection.setdefault(change.collection, []).append(colorize_change(label, line)) lines: list[str] = [] for collection, collection_lines in lines_by_collection.items(): @@ -74,7 +75,7 @@ def _render_custom_files(custom_files: api_models.CustomFileChanges) -> list[str replaces = "" if file.replaces_sdk: replaces = f" ({'was replacing' if label == 'removed' else 'replaces'} sdk/{file.name})" - lines.append(f" {marker} {file.name:<30} {label}{replaces}") + lines.append(colorize_change(label, f" {marker} {file.name:<30} {label}{replaces}")) if lines: lines.insert(0, "") lines.insert(1, "Custom files") From fbe32ce621e22656493c04eaa2c02aa9df540f5e Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 6 Nov 2026 23:35:50 +0000 Subject: [PATCH 8/9] updated api_lib_autogen/models.py --- th_cli/api_lib_autogen/models.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/th_cli/api_lib_autogen/models.py b/th_cli/api_lib_autogen/models.py index 44d5c6d..ac0d51a 100644 --- a/th_cli/api_lib_autogen/models.py +++ b/th_cli/api_lib_autogen/models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: -# filename: tmpfqda1arb.json -# timestamp: 2026-11-06T22:44:49+00:00 +# filename: tmpekg77xf8.json +# timestamp: 2026-11-06T23:35:21+00:00 from __future__ import annotations @@ -42,19 +42,19 @@ class ChipServerInfo(BaseModel): manual_pairing_code: Annotated[str | None, Field(title="Manual Pairing Code")] = None +class Name(RootModel[str]): + root: Annotated[str, Field(title="Name")] + + class CustomFileChange(BaseModel): name: Annotated[str, Field(title="Name")] replaces_sdk: Annotated[bool | None, Field(title="Replaces Sdk")] = False class CustomFileChanges(BaseModel): - added: Annotated[list[CustomFileChange] | None, Field(title="Added")] = [] - modified: Annotated[list[CustomFileChange] | None, Field(title="Modified")] = [] - removed: Annotated[list[CustomFileChange] | None, Field(title="Removed")] = [] - - -class Name(RootModel[str]): - root: Annotated[str, Field(title="Name")] + added: Annotated[list[CustomFileChange] | None, Field(default_factory=list, title="Added")] + modified: Annotated[list[CustomFileChange] | None, Field(default_factory=list, title="Modified")] + removed: Annotated[list[CustomFileChange] | None, Field(default_factory=list, title="Removed")] class Id(RootModel[int]): From 42dabb052e2e0f49df0f3ad2e079fc72112c55b2 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Sat, 7 Nov 2026 00:10:33 +0000 Subject: [PATCH 9/9] th_cli/api_lib_autogen/models.py updated after backend fix --- th_cli/api_lib_autogen/models.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/th_cli/api_lib_autogen/models.py b/th_cli/api_lib_autogen/models.py index ac0d51a..9c75a01 100644 --- a/th_cli/api_lib_autogen/models.py +++ b/th_cli/api_lib_autogen/models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: -# filename: tmpekg77xf8.json -# timestamp: 2026-11-06T23:35:21+00:00 +# filename: tmpjqwdpe1o.json +# timestamp: 2026-11-07T00:09:37+00:00 from __future__ import annotations @@ -101,8 +101,8 @@ class THConfig(BaseModel): class TestCaseChange(BaseModel): collection: Annotated[str, Field(title="Collection")] - test_suite: Annotated[str, Field(title="Test Suite")] - test_case: Annotated[str, Field(title="Test Case")] + test_suite: Annotated[str, Field(title="Test Suite Id")] + test_case: Annotated[str, Field(title="Test Case Id")] class PublicId(RootModel[str]): @@ -397,7 +397,7 @@ class TestRunExecutionWithStats(BaseModel): test_case_stats: TestRunExecutionStats -class TestSuiteModel(BaseModel): +class TestSuite(BaseModel): metadata: TestMetadata test_cases: Annotated[dict[str, TestCase], Field(title="Test Cases")] @@ -463,7 +463,7 @@ class ProjectUpdate(BaseModel): class TestCollection(BaseModel): name: Annotated[str, Field(title="Name")] path: Annotated[str, Field(title="Path")] - test_suites: Annotated[dict[str, TestSuiteModel], Field(title="Test Suites")] + test_suites: Annotated[dict[str, TestSuite], Field(title="Test Suites")] class TestCollections(BaseModel):