Skip to content

Commit

Permalink
address code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
plauric committed Jul 31, 2024
1 parent e4645ee commit 7d9d4a1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 49 deletions.
19 changes: 7 additions & 12 deletions src/python_testing/TC_SEAR_1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,13 @@ async def read_and_validate_supported_maps(self, step):
logging.info("SupportedMaps: %s" % (supported_maps))
asserts.assert_less_equal(len(supported_maps), 255,
"SupportedMaps should have max 255 entries")
mapid_list = []
for m in supported_maps:
if m.mapID in mapid_list:
asserts.fail("SupportedMaps must have unique MapID values!")
else:
mapid_list.append(m.mapID)
name_list = []
for m in supported_maps:
if m.name in name_list:
asserts.fail("SupportedMaps must have unique Name values!")
else:
name_list.append(m.name)

mapid_list = [m.mapID for m in supported_maps]
asserts.assert_true(len(set(mapid_list)) == len(mapid_list), "SupportedMaps must have unique MapID values!")

name_list = [m.name for m in supported_maps]
asserts.assert_true(len(set(name_list)) == len(name_list), "SupportedMaps must have unique Name values!")

#save so other methods can use this if neeeded
self.mapid_list = mapid_list

Expand Down
2 changes: 1 addition & 1 deletion src/python_testing/TC_SEAR_1_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def read_selected_areas(self, step):
endpoint=self.endpoint, attribute=Clusters.ServiceArea.Attributes.SelectedAreas)
logging.info(f"SelectedAreas {selected_areas}")

return [a.areaID for a in selected_areas]
return selected_areas

async def send_cmd_select_areas_expect_response(self, step, new_areas, expected_response):
self.print_step(step, f"Send SelectAreas command with NewAreas({new_areas})")
Expand Down
77 changes: 41 additions & 36 deletions src/python_testing/TC_SEAR_1_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,47 +169,52 @@ async def test_TC_SEAR_1_5(self):
if old_current_area is not NullValue:
await self.send_cmd_skip_area_expect_response(step=13, skipped_area=old_current_area,
expected_response=Clusters.ServiceArea.SkipAreaStatus.kSuccess)
if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"):
test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\
the next one it should process, or stop operating"
self.print_step("14", test_step)
if not self.is_ci:
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"):
test_step = "(Manual operation) wait for the device to skip the current area, and start operating at\
the next one it should process, or stop operating"
self.print_step("14", test_step)
if not self.is_ci:
self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")

if self.check_pics("SEAR.S.A0005"):
new_progress_list = await self.read_progress(step=15)
asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)")
if self.check_pics("SEAR.S.A0005"):
new_progress_list = await self.read_progress(step=15)
asserts.assert_true(len(new_progress_list) > 0, f"len of Progress({len(new_progress_list)}) should not be zero)")

new_current_area = NullValue
if self.check_pics("SEAR.S.A0003"):
new_current_area = await self.read_current_area(step=16)
for p in new_progress_list:
if p.areaID == old_current_area:
asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped,
"Progress for areaID({old_current_area}) should be Skipped")
break
test_step = "Indicate whether the device has stopped operating (y/n)"
ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")
prog_areas = [p.areaID for p in new_progress_list]

if ret != "y":
for p in new_progress_list:
if p.areaID == new_current_area:
asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating,
"Progress for areaID({new_current_area}) should be Operating")
break
asserts.assert_true(old_current_area in prog_areas, f"Progress should include area {old_current_area}")

was_only_skipped_or_completed = True
for p in old_progress_list:
if p.areaID != old_current_area:
if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped,
Clusters.ServiceArea.OperationalStatusEnum.kCompleted):
was_only_skipped_or_completed = False
new_current_area = await self.read_current_area(step=16)
for p in new_progress_list:
if p.areaID == old_current_area:
asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kSkipped,
"Progress for areaID({old_current_area}) should be Skipped")
break
if was_only_skipped_or_completed:
asserts.assert_true(ret == "y", "The device should not be operating")

self.print_step("17", "")
return
test_step = "Indicate whether the device has stopped operating (y/n)"
ret = self.wait_for_user_input(prompt_msg=f"{test_step}, and press Enter when done.\n")

# Verify that if the device hasn't stopped operating, the `new_progress_list`'s entry matching `new_current_area` shows the Operating status
if ret != "y":
for p in new_progress_list:
if p.areaID == new_current_area:
asserts.assert_true(p.status == Clusters.ServiceArea.OperationalStatusEnum.kOperating,
"Progress for areaID({new_current_area}) should be Operating")
break

# next, we need to check for something else (so the condition of the 'if' above becomes part of the 'then' statement below):
# if before skipping all areas, except the current one, were Skipped or Completed, the device MUST have stopped operating
was_only_skipped_or_completed = True
for p in old_progress_list:
if p.areaID != old_current_area:
if p.status not in (Clusters.ServiceArea.OperationalStatusEnum.kSkipped,
Clusters.ServiceArea.OperationalStatusEnum.kCompleted):
was_only_skipped_or_completed = False
break
if was_only_skipped_or_completed:
asserts.assert_true(ret == "y", "The device should not be operating")

self.print_step("17", "")
return

if self.check_pics("SEAR.S.M.HAS_MANUAL_SKIP_STATE_CONTROL"):
test_step = "Manually intervene to put the device in a state that allows it to execute the SkipArea command"
Expand Down

0 comments on commit 7d9d4a1

Please sign in to comment.