Skip to content

Commit

Permalink
Updated TC_OpstateCommon python module:
Browse files Browse the repository at this point in the history
- Updated to using new command_guard() for OPSTATE tests
  • Loading branch information
j-ororke committed Dec 10, 2024
1 parent e57caad commit c21d11b
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions src/python_testing/TC_OpstateCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,19 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature
self.step(6)
expected_value = []

if ((commands.Pause.command_id in accepted_cmd_list) or
(commands.Resume.command_id in accepted_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Pause)) or
(await self.command_guard(endpoint=endpoint, command=commands.Resume))):
expected_value.append(commands.Pause.command_id)

if ((commands.Stop.command_id in accepted_cmd_list) or
(commands.Start.command_id in accepted_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Stop)) or
(await self.command_guard(endpoint=endpoint, command=commands.Start))):
expected_value.append(commands.Stop.command_id)

if commands.Start.command_id in accepted_cmd_list:
if await self.command_guard(endpoint=endpoint, command=commands.Start):
expected_value.append(commands.Start.command_id)

if ((commands.Resume.command_id in accepted_cmd_list) or
(commands.Pause.command_id in accepted_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Pause)) or
(await self.command_guard(endpoint=endpoint, command=commands.Resume))):
expected_value.append(commands.Resume.command_id)

await self.read_and_expect_array_contains(endpoint=endpoint,
Expand All @@ -296,10 +296,10 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature
self.step(7)
expected_value = []

if ((commands.Pause.command_id in accepted_cmd_list) or
(commands.Stop.command_id in accepted_cmd_list) or
(commands.Start.command_id in accepted_cmd_list) or
(commands.Resume.command_id in accepted_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Pause)) or
(await self.command_guard(endpoint=endpoint, command=commands.Resume)) or
(await self.command_guard(endpoint=endpoint, command=commands.Stop)) or
(await self.command_guard(endpoint=endpoint, command=commands.Start))):
expected_value.append(commands.OperationalCommandResponse.command_id)

await self.read_and_expect_array_contains(endpoint=endpoint,
Expand Down Expand Up @@ -570,7 +570,6 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1):
attributes = cluster.Attributes

commands = cluster.Commands
accepted_cmd_list = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attributes.AcceptedCommandList)
generated_cmd_list = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attributes.GeneratedCommandList)

self.init_test()
Expand Down Expand Up @@ -615,7 +614,7 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1):

# STEP 4: TH sends Start command to the DUT
self.step(4)
if ((commands.Start.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Start)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Start(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand Down Expand Up @@ -686,14 +685,14 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1):

# STEP 12: TH sends Start command to the DUT
self.step(12)
if ((commands.Start.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Start)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Start(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)

# STEP 13: TH sends Stop command to the DUT
self.step(13)
if ((commands.Stop.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Stop)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Stop(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand All @@ -706,7 +705,7 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1):

# STEP 15: TH sends Stop command to the DUT
self.step(15)
if ((commands.Stop.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Stop)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Stop(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand All @@ -722,7 +721,7 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1):
# STEP 17: TH sends Start command to the DUT
self.step(17)
if self.pics_guard((self.check_pics(f"{self.test_info.pics_code}.S.M.ERR_UNABLE_TO_START_OR_RESUME")) and
((commands.Start.command_id in accepted_cmd_list) and
((await self.command_guard(endpoint=endpoint, command=commands.Start)) and
(commands.OperationalCommandResponse.command_id in generated_cmd_list))):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Start(),
Expand Down Expand Up @@ -758,7 +757,6 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1):
attributes = cluster.Attributes

commands = cluster.Commands
accepted_cmd_list = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attributes.AcceptedCommandList)
generated_cmd_list = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attributes.GeneratedCommandList)

self.init_test()
Expand Down Expand Up @@ -802,7 +800,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1):

# STEP 4: TH sends Pause command to the DUT
self.step(4)
if ((commands.Pause.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Pause)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Pause(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand Down Expand Up @@ -841,14 +839,14 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1):

# STEP 9: TH sends Pause command to the DUT
self.step(9)
if ((commands.Pause.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Pause)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Pause(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)

# STEP 10: TH sends Resume command to the DUT
self.step(10)
if ((commands.Resume.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Resume)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Resume(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand All @@ -861,7 +859,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1):

# STEP 12: TH sends Resume command to the DUT
self.step(12)
if ((commands.Resume.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Resume)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Resume(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand All @@ -875,14 +873,14 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1):

# STEP 14: TH sends Pause command to the DUT
self.step(14)
if ((commands.Pause.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Pause)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Pause(),
expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState)

# STEP 15: TH sends Resume command to the DUT
self.step(15)
if ((commands.Resume.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Resume)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Resume(),
expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState)
Expand All @@ -897,14 +895,14 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1):

# STEP 17: TH sends Pause command to the DUT
self.step(17)
if ((commands.Pause.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Pause)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Pause(),
expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState)

# STEP 18: TH sends Resume command to the DUT
self.step(18)
if ((commands.Resume.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Resume)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Resume(),
expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState)
Expand Down Expand Up @@ -1011,7 +1009,6 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):
attributes = cluster.Attributes

commands = cluster.Commands
accepted_cmd_list = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attributes.AcceptedCommandList)
generated_cmd_list = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attributes.GeneratedCommandList)

events = cluster.Events
Expand Down Expand Up @@ -1054,7 +1051,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):

# STEP 4: TH sends Start command to the DUT
self.step(4)
if ((commands.Start.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Start)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Start(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand All @@ -1079,7 +1076,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):

# STEP 8: TH sends Stop command to the DUT
self.step(8)
if ((commands.Stop.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Stop)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Stop(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand Down Expand Up @@ -1127,7 +1124,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):

# STEP 13: TH sends Start command to the DUT
self.step(13)
if ((commands.Start.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Start)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Start(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand All @@ -1140,7 +1137,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):

# STEP 15: TH sends Pause command to the DUT
self.step(15)
if ((commands.Pause.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Pause)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Pause(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand All @@ -1157,7 +1154,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):

# STEP 18: TH sends Resume command to the DUT
self.step(18)
if ((commands.Resume.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Resume)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Resume(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand All @@ -1174,7 +1171,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1):

# STEP 21: TH sends Stop command to the DUT
self.step(21)
if ((commands.Stop.command_id in accepted_cmd_list) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
if ((await self.command_guard(endpoint=endpoint, command=commands.Stop)) and (commands.OperationalCommandResponse.command_id in generated_cmd_list)):
await self.send_cmd_expect_response(endpoint=endpoint,
cmd=commands.Stop(),
expected_response=cluster.Enums.ErrorStateEnum.kNoError)
Expand Down

0 comments on commit c21d11b

Please sign in to comment.