Skip to content

Commit 3d80093

Browse files
j-ororkerestyled-commitscecille
authored
[Fix] Created possible fix for issue #229: Remove PICS from python PWRTL tests (#34094)
* Created possible fix for issue #229: - Removed PICS if statements from TC_PWRTL_2_1 test module - Added if statements to check if attribute ID's for available and active endpoints gathered from DUT's are contained in attribute list - Updated method from NullValue to also include checking for empty lists from DUT's for available and active endpoints * Restyled by autopep8 * Updated TC_PWRTL_2_1.py: - Added else condition to return for cases where active or available attribute ID's were not in attibute list on DUT * Restyled by autopep8 * Updated TC_PWRTL_2_1 test module: - Replaced method for setting endpoint variable - Removed null check for available endpoints in test step 2. - Reworded verbiage for skipping test step 3 if condition is not met. * Restyled by autopep8 * Updated TC_PWRTL_2_1 test module - Fixed found linting errors * Updated TC_PWRTL_2_1 test module: - Resolved new found linting errors. * Restyled by autopep8 * Apply suggestions from code review Co-authored-by: C Freeman <cecille@google.com> * Update src/python_testing/TC_PWRTL_2_1.py Co-authored-by: C Freeman <cecille@google.com> --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: C Freeman <cecille@google.com>
1 parent fa46641 commit 3d80093

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

src/python_testing/TC_PWRTL_2_1.py

+30-17
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,43 @@ async def test_TC_PWRTL_2_1(self):
5353

5454
endpoint = self.user_params.get("endpoint", 1)
5555

56-
self.print_step(1, "Commissioning, already done")
56+
powertop_attr_list = Clusters.Objects.PowerTopology.Attributes.AttributeList
57+
powertop_cluster = Clusters.Objects.PowerTopology
58+
attribute_list = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=powertop_cluster, attribute=powertop_attr_list)
59+
avail_endpoints_attr_id = Clusters.Objects.PowerTopology.Attributes.ActiveEndpoints.attribute_id
60+
act_endpoints_attr_id = Clusters.Objects.PowerTopology.Attributes.AvailableEndpoints.attribute_id
5761

58-
if not self.check_pics("PWRTL.S.A0000"):
59-
logging.info("Test skipped because PICS PWRTL.S.A0000 is not set")
60-
return
62+
self.print_step(1, "Commissioning, already done")
6163

6264
self.print_step(2, "Read AvailableAttributes attribute")
63-
available_endpoints = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=Clusters.Objects.PowerTopology, attribute=attributes.AvailableEndpoints)
65+
if avail_endpoints_attr_id in attribute_list:
66+
available_endpoints = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=Clusters.Objects.PowerTopology, attribute=attributes.AvailableEndpoints)
6467

65-
asserts.assert_less_equal(len(available_endpoints), 20,
66-
"AvailableEndpoints length %d must be less than 21!" % len(available_endpoints))
68+
if available_endpoints == []:
69+
logging.info("AvailableEndpoints is an empty list")
70+
else:
71+
logging.info("AvailableEndpoints: %s" % (available_endpoints))
72+
asserts.assert_less_equal(len(available_endpoints), 20,
73+
"AvailableEndpoints length %d must be less than 21!" % len(available_endpoints))
6774

68-
if not self.check_pics("PWRTL.S.A0001"):
69-
logging.info("Test skipped because PICS PWRTL.S.A0001 is not set")
70-
return
75+
else:
76+
self.mark_current_step_skipped()
7177

7278
self.print_step(3, "Read ActiveEndpoints attribute")
73-
active_endpoints = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=Clusters.Objects.PowerTopology, attribute=attributes.ActiveEndpoints)
74-
logging.info("ActiveEndpoints: %s" % (active_endpoints))
75-
asserts.assert_less_equal(len(active_endpoints), 20,
76-
"ActiveEndpoints length %d must be less than 21!" % len(active_endpoints))
77-
# Verify that ActiveEndpoints is a subset of AvailableEndpoints
78-
asserts.assert_true(set(active_endpoints).issubset(set(available_endpoints)),
79-
"ActiveEndpoints should be a subset of AvailableEndpoints")
79+
80+
if act_endpoints_attr_id in attribute_list:
81+
active_endpoints = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=Clusters.Objects.PowerTopology, attribute=attributes.ActiveEndpoints)
82+
logging.info("ActiveEndpoints: %s" % (active_endpoints))
83+
asserts.assert_less_equal(len(active_endpoints), 20,
84+
"ActiveEndpoints length %d must be less than 21!" % len(active_endpoints))
85+
86+
if available_endpoints == []:
87+
# Verify that ActiveEndpoints is a subset of AvailableEndpoints
88+
asserts.assert_true(set(active_endpoints).issubset(set(available_endpoints)),
89+
"ActiveEndpoints should be a subset of AvailableEndpoints")
90+
91+
else:
92+
self.mark_current_step_skipped()
8093

8194

8295
if __name__ == "__main__":

0 commit comments

Comments
 (0)