Skip to content

Commit

Permalink
Worked on issue 243; replaced input with self.wait_for_user_input; ot…
Browse files Browse the repository at this point in the history
…her changes (project-chip#33672)

* Worked on issue 243; replaced input with self.wait_for_user_input; removed input_msg message argument and made several adjustments accordingly

* Restyled by autopep8

* Clarified text for user input by adding test step.

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: C Freeman <[email protected]>
  • Loading branch information
3 people authored Jun 25, 2024
1 parent 57fc697 commit 857accf
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 82 deletions.
4 changes: 2 additions & 2 deletions src/python_testing/TC_OpstateCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def send_raw_manual_or_pipe_command(self, command):
self.write_to_app_pipe(command)
time.sleep(0.1)
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg="Press Enter when ready.\n")

def send_manual_or_pipe_command(self, device: str, name: str, operation: str, param: Any = None):
command = {
Expand Down Expand Up @@ -1113,7 +1113,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):
# In CI environment, the STOP coommand (step 8) already resets the variables. Only ask for
# reboot outside CI environment.
if not self.is_ci:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg="Restart DUT. Press Enter when ready.\n")

# STEP 12: TH waits for {PIXIT.WAITTIME.REBOOT}
self.step(12)
Expand Down
6 changes: 4 additions & 2 deletions src/python_testing/TC_RVCCLEANM_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ class CommonCodes(Enum):
print("Changing mode to Cleaning")
await self.send_run_change_to_mode_cmd(1)
else:
input("Press Enter when done.\n")
self.wait_for_user_input(
prompt_msg="Manually put the device in a state from which it will FAIL to transition to mode %d, and press Enter when done" % (self.mode_fail))

self.print_step(6, "Read CurrentMode attribute")
old_current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
Expand Down Expand Up @@ -169,7 +170,8 @@ class CommonCodes(Enum):
print("Changing mode to Idle")
await self.send_run_change_to_mode_cmd(0)
else:
input("Press Enter when done.\n")
self.wait_for_user_input(
prompt_msg="Manually put the device in a state from which it will SUCCESSFULLY transition to mode %d, and press Enter when done" % (self.mode_ok))

self.print_step(10, "Read CurrentMode attribute")
old_current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode)
Expand Down
5 changes: 3 additions & 2 deletions src/python_testing/TC_RVCCLEANM_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def send_run_change_to_mode_cmd(self, newMode) -> Clusters.Objects.RvcRunM
# Prints the instruction and waits for a user input to continue
def print_instruction(self, step_number, instruction):
self.print_step(step_number, instruction)
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{instruction}, and press Enter when ready.")

def pics_TC_RVCCLEANM_2_2(self) -> list[str]:
return ["RVCCLEANM.S"]
Expand Down Expand Up @@ -101,7 +101,8 @@ async def test_TC_RVCCLEANM_2_2(self):
if self.is_ci:
await self.send_run_change_to_mode_cmd(1)
else:
input("Press Enter when done.\n")
self.wait_for_user_input(
prompt_msg="Manually put the device in a state in which the RVC Run Mode cluster’s CurrentMode attribute is set to a mode without the Idle mode tag, and press Enter when done.")

self.print_step(3, "Read the RvcRunMode SupportedModes attribute")
supported_run_modes = await self.read_run_supported_modes()
Expand Down
95 changes: 57 additions & 38 deletions src/python_testing/TC_RVCOPSTATE_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,53 +158,60 @@ async def test_TC_RVCOPSTATE_2_1(self):
asserts.assert_true(operational_state in defined_states or in_range, "OperationalState has an invalid ID value!")

if self.check_pics("RVCOPSTATE.S.M.ST_STOPPED"):
self.print_step("6a", "Manually put the device in the stopped state")
test_step = "Manually put the device in the stopped state"
self.print_step("6a", test_step)
if not self.is_ci:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kStopped)
if self.check_pics("RVCOPSTATE.S.M.ST_RUNNING"):
self.print_step("6c", "Manually put the device in the running state")
test_step = "Manually put the device in the running state"
self.print_step("6c", test_step)
if self.is_ci:
await self.send_run_change_to_mode_cmd(1)
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kRunning)
if self.check_pics("RVCOPSTATE.S.M.ST_PAUSED"):
self.print_step("6e", "Manually put the device in the paused state")
test_step = "Manually put the device in the paused state"
self.print_step("6e", test_step)
if self.is_ci:
await self.send_pause_cmd()
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPaused)
if self.check_pics("RVCOPSTATE.S.M.ST_ERROR"):
self.print_step("6g", "Manually put the device in the error state")
test_step = "Manually put the device in the error state"
self.print_step("6g", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "UnableToStartOrResume"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kError)
if self.check_pics("RVCOPSTATE.S.M.ST_SEEKING_CHARGER"):
self.print_step("6i", "Manually put the device in the seeking charger state")
test_step = "Manually put the device in the seeking charger state"
self.print_step("6i", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "Reset"}')
await self.send_run_change_to_mode_cmd(1)
await self.send_run_change_to_mode_cmd(0)
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_opstate(step="6j", expected_state=Clusters.RvcOperationalState.Enums.OperationalStateEnum.kSeekingCharger)
if self.check_pics("RVCOPSTATE.S.M.ST_CHARGING"):
self.print_step("6k", "Manually put the device in the charging state")
test_step = "Manually put the device in the charging state"
self.print_step("6k", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ChargerFound"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_opstate(step="6l", expected_state=Clusters.RvcOperationalState.Enums.OperationalStateEnum.kCharging)
if self.check_pics("RVCOPSTATE.S.M.ST_DOCKED"):
self.print_step("6m", "Manually put the device in the docked state")
test_step = "Manually put the device in the docked state"
self.print_step("6m", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "Charged"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_opstate(step="6n", expected_state=Clusters.RvcOperationalState.Enums.OperationalStateEnum.kDocked)

if self.check_pics("RVCOPSTATE.S.A0005"):
Expand All @@ -226,86 +233,98 @@ async def test_TC_RVCOPSTATE_2_1(self):
asserts.assert_true(operational_error.errorStateLabel is not None, "ErrorStateLabel should be populated")

if self.check_pics("RVCOPSTATE.S.M.ERR_NO_ERROR"):
self.print_step("7a", "Manually put the device in the no error state")
test_step = "Manually put the device in the no error state"
self.print_step("7a", test_step)
if not self.is_ci:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7b", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kNoError)
if self.check_pics("RVCOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME"):
self.print_step("7c", "Manually put the device in the unable to start or resume error state")
test_step = "Manually put the device in the unable to start or resume error state"
self.print_step("7c", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "UnableToStartOrResume"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7d", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume)
if self.check_pics("RVCOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION"):
self.print_step("7e", "Manually put the device in the unable to complete operation error state")
test_step = "Manually put the device in the unable to complete operation error state"
self.print_step("7e", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "UnableToCompleteOperation"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7f", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation)
if self.check_pics("RVCOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE"):
self.print_step("7g", "Manually put the device in the command invalid error state")
test_step = "Manually put the device in the command invalid error state"
self.print_step("7g", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "CommandInvalidInState"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7h", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState)
if self.check_pics("RVCOPSTATE.S.M.ERR_FAILED_TO_FIND_CHARGING_DOCK"):
self.print_step("7i", "Manually put the device in the failed to find dock error state")
test_step = "Manually put the device in the failed to find dock error state"
self.print_step("7i", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "FailedToFindChargingDock"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7j", expected_error=Clusters.RvcOperationalState.Enums.ErrorStateEnum.kFailedToFindChargingDock)
if self.check_pics("RVCOPSTATE.S.M.ERR_STUCK"):
self.print_step("7k", "Manually put the device in the stuck error state")
test_step = "Manually put the device in the stuck error state"
self.print_step("7k", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "Stuck"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7l", expected_error=Clusters.RvcOperationalState.Enums.ErrorStateEnum.kStuck)
if self.check_pics("RVCOPSTATE.S.M.ERR_DUST_BIN_MISSING"):
self.print_step("7m", "Manually put the device in the dust bin missing error state")
test_step = "Manually put the device in the dust bin missing error state"
self.print_step("7m", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "DustBinMissing"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7n", expected_error=Clusters.RvcOperationalState.Enums.ErrorStateEnum.kDustBinMissing)
if self.check_pics("RVCOPSTATE.S.M.ERR_DUST_BIN_FULL"):
self.print_step("7o", "Manually put the device in the dust bin full error state")
test_step = "Manually put the device in the dust bin full error state"
self.print_step("7o", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "DustBinFull"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7p", expected_error=Clusters.RvcOperationalState.Enums.ErrorStateEnum.kDustBinFull)
if self.check_pics("RVCOPSTATE.S.M.ERR_WATER_TANK_EMPTY"):
self.print_step("7q", "Manually put the device in the water tank empty error state")
test_step = "Manually put the device in the water tank empty error state"
self.print_step("7q", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "WaterTankEmpty"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7r", expected_error=Clusters.RvcOperationalState.Enums.ErrorStateEnum.kWaterTankEmpty)
if self.check_pics("RVCOPSTATE.S.M.ERR_WATER_TANK_MISSING"):
self.print_step("7s", "Manually put the device in the water tank missing error state")
test_step = "Manually put the device in the water tank missing error state"
self.print_step("7s", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "WaterTankMissing"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7t", expected_error=Clusters.RvcOperationalState.Enums.ErrorStateEnum.kWaterTankMissing)
if self.check_pics("RVCOPSTATE.S.M.ERR_WATER_TANK_LID_OPEN"):
self.print_step("7u", "Manually put the device in the water tank lid open error state")
test_step = "Manually put the device in the water tank lid open error state"
self.print_step("7u", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "WaterTankLidOpen"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7v", expected_error=Clusters.RvcOperationalState.Enums.ErrorStateEnum.kWaterTankLidOpen)
if self.check_pics("RVCOPSTATE.S.M.ERR_MOP_CLEANING_PAD_MISSING"):
self.print_step("7w", "Manually put the device in the mop cleaning pad missing error state")
test_step = "Manually put the device in the mop cleaning pad missing error state"
self.print_step("7w", test_step)
if self.is_ci:
self.write_to_app_pipe('{"Name": "ErrorEvent", "Error": "MopCleaningPadMissing"}')
else:
input("Press Enter when done.\n")
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
await self.read_and_validate_operror(step="7x", expected_error=Clusters.RvcOperationalState.Enums.ErrorStateEnum.kMopCleaningPadMissing)


Expand Down
Loading

0 comments on commit 857accf

Please sign in to comment.