From 6061a1b383244d60c7bcf891fdbfda746b4ded30 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:28:12 -0300 Subject: [PATCH] Check user prompt answer FAILED for DUT commissioning (#155) --- .../support/python_testing/models/test_suite.py | 13 ++++++++++--- test_collections/matter/sdk_tests/support/utils.py | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test_collections/matter/sdk_tests/support/python_testing/models/test_suite.py b/test_collections/matter/sdk_tests/support/python_testing/models/test_suite.py index 943522b4..ac2618ed 100644 --- a/test_collections/matter/sdk_tests/support/python_testing/models/test_suite.py +++ b/test_collections/matter/sdk_tests/support/python_testing/models/test_suite.py @@ -29,8 +29,8 @@ ) from ...sdk_container import SDKContainer -from ...utils import prompt_for_commissioning_mode -from .utils import commission_device +from ...utils import PromptOption, prompt_for_commissioning_mode +from .utils import DUTCommissioningError, commission_device class SuiteType(Enum): @@ -124,7 +124,14 @@ class CommissioningPythonTestSuite(PythonTestSuite, UserPromptSupport): async def setup(self) -> None: await super().setup() - await prompt_for_commissioning_mode(self, logger, None, self.cancel) + user_response = await prompt_for_commissioning_mode( + self, logger, None, self.cancel + ) + + if user_response == PromptOption.FAIL: + raise DUTCommissioningError( + "User chose prompt option FAILED for DUT is in Commissioning Mode" + ) logger.info("Commission DUT") diff --git a/test_collections/matter/sdk_tests/support/utils.py b/test_collections/matter/sdk_tests/support/utils.py index 7903099a..d35a0e9f 100644 --- a/test_collections/matter/sdk_tests/support/utils.py +++ b/test_collections/matter/sdk_tests/support/utils.py @@ -35,7 +35,7 @@ async def prompt_for_commissioning_mode( logger: loguru.Logger, on_success: Optional[Callable] = None, on_failure: Optional[Callable] = None, -) -> None: +) -> PromptOption: prompt = "Make sure the DUT is in Commissioning Mode" options = { "DONE": PromptOption.PASS, @@ -62,3 +62,4 @@ async def prompt_for_commissioning_mode( f"Received unknown prompt option for \ commissioning step: {prompt_response.response}" ) + return prompt_response.response