diff --git a/app/tests/python_tests/test_python_test_case.py b/app/tests/python_tests/test_python_test_case.py index 881db114..ffde45c6 100644 --- a/app/tests/python_tests/test_python_test_case.py +++ b/app/tests/python_tests/test_python_test_case.py @@ -106,27 +106,6 @@ def test_python_test_case_class_pics() -> None: assert case_class.pics() == test_PICS -def test_python_test_case_class_default_test_parameters() -> None: - """Test that the default_test_parameters of the python test is available in the class - method default_test_parameters on TestCase. - - Also parameters with type in Python test should be flattened and type dropped.""" - - test_input_config = { - "param1": "value1", - "param2": {"type": "config_type", "defaultValue": "value2"}, - } - - test = python_test_instance(config=test_input_config) - expected_default_test_parameters = {"param1": "value1", "param2": "value2"} - - # Create a subclass of PythonTest - case_class: Type[PythonTestCase] = PythonTestCase.class_factory( - test=test, python_test_version="version" - ) - assert case_class.default_test_parameters() == expected_default_test_parameters - - def test_class_factory_test_public_id() -> None: """Test that class factory correctly finds identifier 'TC-XX-1.1' in python test name. And set it as public_id in metadata""" @@ -189,7 +168,7 @@ async def test_python_version_logging() -> None: except TestError: pass logger_info.assert_called() - logger_info.assert_any_call(f"Python Test Version: {test_python_version}") + logger_info.assert_any_call("Test Setup") def test_normal_steps_for_python_tests() -> None: diff --git a/test_collections/sdk_tests/support/python_testing/models/test_case.py b/test_collections/sdk_tests/support/python_testing/models/test_case.py index 32ccdf13..5ddcfd6a 100644 --- a/test_collections/sdk_tests/support/python_testing/models/test_case.py +++ b/test_collections/sdk_tests/support/python_testing/models/test_case.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import re from asyncio import sleep from multiprocessing.managers import BaseManager from typing import Any, Type, TypeVar @@ -95,81 +96,49 @@ def pics(cls) -> set[str]: @classmethod def class_factory(cls, test: PythonTest, python_test_version: str) -> Type[T]: """class factory method for PythonTestCase.""" + + identifier = cls.__test_identifier(test.name) + class_name = cls.__class_name(identifier) + title = identifier + return type( - test.name, + class_name, (cls,), { "python_test": test, "python_test_version": python_test_version, - "chip_tool_test_identifier": test.name, + "chip_tool_test_identifier": class_name, "metadata": { - "public_id": test.name, + "public_id": identifier, "version": "0.0.1", - "title": test.name, + "title": title, "description": test.description, }, }, ) + @staticmethod + def __test_identifier(name: str) -> str: + """Find TC-XX-1.1 in YAML title. + Note some have [TC-XX-1.1] and others TC-XX-1.1 + """ + title_pattern = re.compile(r"(?P