Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Replace automatable PICS in TSTAT test modules #35238

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
41 changes: 26 additions & 15 deletions src/python_testing/TC_TSTAT_4_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@


class TC_TSTAT_4_2(MatterBaseTest):
async def read_tstat_attribute_expect_success(self, attribute):
return await self.read_single_attribute_check_success(endpoint=None, cluster=cluster, attribute=attribute)

def check_atomic_response(self, response: object, expected_status: Status = Status.Success,
expected_overall_status: Status = Status.Success,
Expand Down Expand Up @@ -243,10 +245,17 @@ async def test_TC_TSTAT_4_2(self):
params = await self.default_controller.OpenCommissioningWindow(
nodeid=self.dut_node_id, timeout=600, iteration=10000, discriminator=1234, option=1)

features = await self.read_single_attribute_check_success(endpoint=None, cluster=cluster, attribute=cluster.Attributes.FeatureMap)
supports_presets = bool(features | cluster.Bitmaps.Feature.kPresets)
attribute_list = await self.read_tstat_attribute_expect_success(attribute=cluster.Attributes.AttributeList)
presets_attr_id = cluster.Attributes.Presets.attribute_id

secondary_authority = self.certificate_authority_manager.NewCertificateAuthority()
secondary_fabric_admin = secondary_authority.NewFabricAdmin(vendorId=0xFFF1, fabricId=2)
secondary_controller = secondary_fabric_admin.NewController(nodeId=112233)

accepted_cmd_list = await self.read_tstat_attribute_expect_success(attribute=cluster.Attributes.AcceptedCommandList)

await secondary_controller.CommissionOnNetwork(
nodeId=self.dut_node_id, setupPinCode=params.setupPinCode,
filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=1234)
Expand All @@ -267,7 +276,7 @@ async def test_TC_TSTAT_4_2(self):
coolSetpoint = minCoolSetpointLimit + ((maxCoolSetpointLimit - minCoolSetpointLimit) / 2)

self.step("2")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050")):
if supports_presets and presets_attr_id in attribute_list:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in the other tests, this is going to remove the skip markers. I think let's wait until 34290 goes in and just update to use the attribute guard. It might make sense to add something similar for features (and commands) to get it working with this PR too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to include attribute_guard(), feature_guard(), and command_guard() after 34290 got merged recently.


# Read the numberOfPresets supported.
numberOfPresetsSupported = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.NumberOfPresets)
Expand All @@ -285,7 +294,7 @@ async def test_TC_TSTAT_4_2(self):
await self.write_presets(endpoint=endpoint, presets=current_presets, expected_status=Status.InvalidInState)

self.step("3")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

availableScenario = self.get_available_scenario(presetTypes=presetTypes, presetScenarioCounts=presetScenarioCounts)

Expand Down Expand Up @@ -321,7 +330,7 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 3 since there was no available preset scenario to append")

self.step("4")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

availableScenario = self.get_available_scenario(presetTypes=presetTypes, presetScenarioCounts=presetScenarioCounts)

Expand Down Expand Up @@ -362,7 +371,7 @@ async def test_TC_TSTAT_4_2(self):
activePresetHandle = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.ActivePresetHandle)

self.step("5")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

# Write to the presets attribute after removing a built in preset from the list. Remove the first entry.
test_presets = current_presets.copy()
Expand All @@ -385,7 +394,7 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 5 since there were no built-in presets")

self.step("6")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.C06.Rsp") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

notBuiltInPresets = list(preset for preset in current_presets if preset.builtIn is False)
if len(notBuiltInPresets) > 0:
Expand Down Expand Up @@ -422,7 +431,7 @@ async def test_TC_TSTAT_4_2(self):
asserts.assert_equal(activePresetHandle, NullValue, "Active preset handle was not cleared as expected")

self.step("7")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

# Write to the presets attribute after setting the builtIn flag to False for a built-in preset.
test_presets = copy.deepcopy(current_presets)
Expand All @@ -444,7 +453,7 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 7 since there was no built-in presets")

self.step("8")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

availableScenario = self.get_available_scenario(presetTypes=presetTypes, presetScenarioCounts=presetScenarioCounts)

Expand All @@ -468,7 +477,7 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 8 since there was no available preset scenario to append")

self.step("9")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

# Send the AtomicRequest begin command
await self.send_atomic_request_begin_command()
Expand All @@ -484,7 +493,7 @@ async def test_TC_TSTAT_4_2(self):
await self.send_atomic_request_rollback_command()

self.step("10")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

availableScenario = self.get_available_scenario(presetTypes=presetTypes, presetScenarioCounts=presetScenarioCounts)

Expand All @@ -509,7 +518,7 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 10 since there was no available preset scenario to duplicate")

self.step("11")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

test_presets = copy.deepcopy(current_presets)

Expand All @@ -531,7 +540,7 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 11 since there were no presets that were not built-in")

self.step("12")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

availableScenarios = list(presetType.presetScenario for presetType in presetTypes if (presetType.presetTypeFeatures & cluster.Bitmaps.PresetTypeFeaturesBitmap.kSupportsNames) == 0 and presetScenarioCounts.get(
presetType.presetScenario, 0) <= presetType.numberOfPresets)
Expand Down Expand Up @@ -562,7 +571,7 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 12 since there was no available preset scenario without name support")

self.step("13")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

availableScenario = self.get_available_scenario(presetTypes=presetTypes, presetScenarioCounts=presetScenarioCounts)

Expand All @@ -588,7 +597,8 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 13 since there was no available preset scenario to add")

self.step("14")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

await self.send_atomic_request_begin_command()
# Send the AtomicRequest begin command from separate controller, which should receive busy
status = await self.send_atomic_request_begin_command(dev_ctrl=secondary_controller, expected_overall_status=Status.Failure, expected_preset_status=Status.Busy)
Expand All @@ -597,7 +607,8 @@ async def test_TC_TSTAT_4_2(self):
await self.send_atomic_request_rollback_command()

self.step("15")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

# Send the AtomicRequest begin command from the secondary controller
await self.send_atomic_request_begin_command()

Expand All @@ -607,7 +618,7 @@ async def test_TC_TSTAT_4_2(self):
await self.send_atomic_request_rollback_command()

self.step("16")
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050") and self.check_pics("TSTAT.S.Cfe.Rsp")):
if supports_presets and presets_attr_id in attribute_list and cluster.Commands.AtomicRequest.command_id in accepted_cmd_list:

# Send the AtomicRequest begin command from the secondary controller
await self.send_atomic_request_begin_command(dev_ctrl=secondary_controller)
Expand Down
Loading