Skip to content

Commit 86fc530

Browse files
Fix restyle
1 parent 140840c commit 86fc530

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/python_testing/TC_SC_4_3.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
import chip.clusters as Clusters
2222
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
23-
from mobly import asserts
2423
from mdns_discovery.mdns_discovery import MdnsDiscovery, MdnsServiceType
2524

25+
from mobly import asserts
2626

2727
'''
2828
Category
@@ -36,6 +36,7 @@
3636
https://github.com/CHIP-Specifications/chip-test-plans/blob/master/src/securechannel.adoc#343-tc-sc-43-discovery-dut_commissionee
3737
'''
3838

39+
3940
class TC_SC_4_3(MatterBaseTest):
4041

4142
ONE_HOUR_IN_MS = 3600000
@@ -49,29 +50,34 @@ async def get_descriptor_server_list(self):
4950
cluster=Clusters.Descriptor,
5051
attribute=Clusters.Descriptor.Attributes.ServerList
5152
)
53+
5254
async def get_idle_mode_threshhold_ms(self):
5355
return await self.read_single_attribute_check_success(
5456
endpoint=0,
5557
dev_ctrl=self.default_controller,
5658
cluster=Clusters.IcdManagement,
5759
attribute=Clusters.IcdManagement.Attributes.ActiveModeThreshold
5860
)
61+
5962
async def get_icd_feature_map(self):
6063
return await self.read_single_attribute_check_success(
6164
endpoint=0,
6265
dev_ctrl=self.default_controller,
6366
cluster=Clusters.IcdManagement,
6467
attribute=Clusters.IcdManagement.Attributes.FeatureMap
6568
)
69+
6670
def get_dut_instance_name(self) -> str:
6771
node_id = self.dut_node_id
6872
compressed_fabric_id = self.default_controller.GetCompressedFabricId()
6973
instance_name = f'{compressed_fabric_id:016X}-{node_id:016X}'
7074
return instance_name
75+
7176
def get_operational_subtype(self) -> str:
7277
compressed_fabric_id = self.default_controller.GetCompressedFabricId()
7378
service_name = f'_I{compressed_fabric_id:016X}._sub.{MdnsServiceType.OPERATIONAL.value}'
7479
return service_name
80+
7581
@staticmethod
7682
def verify_decimal_value(input_value, comparison_value: int):
7783
try:
@@ -90,6 +96,7 @@ def verify_decimal_value(input_value, comparison_value: int):
9096
return (False, f"Input ({input_value}) exceeds the allowed value {comparison_value}.")
9197
except ValueError:
9298
return (False, f"Input ({input_value}) is not a valid decimal number.")
99+
93100
def verify_t_value(self, t_value):
94101
# Verify t_value is a decimal number without leading zeros and less than or equal to 6
95102
try:
@@ -100,14 +107,15 @@ def verify_t_value(self, t_value):
100107
return False, f"T value ({t_value}) has leading zeros."
101108
if T_int != float(t_value):
102109
return False, f"T value ({t_value}) is not an integer."
103-
110+
104111
# Convert to bitmap and verify bit 0 is clear
105112
if T_int & 1 == 0:
106113
return True, f"T value ({t_value}) is valid and bit 0 is clear."
107114
else:
108115
return False, f"Bit 0 is not clear. T value ({t_value})"
109116
except ValueError:
110117
return False, "T value ({t_value}) is not a valid decimal number."
118+
111119
@staticmethod
112120
def contains_ipv6_address(addresses):
113121
# IPv6 pattern for basic validation
@@ -118,7 +126,7 @@ def contains_ipv6_address(addresses):
118126
return True, "At least one IPv6 address is present."
119127

120128
return False, "No IPv6 addresses found."
121-
129+
122130
@async_test_body
123131
async def test_TC_SC_4_3(self):
124132
print(f"\n"*10)
@@ -132,7 +140,7 @@ async def test_TC_SC_4_3(self):
132140

133141
# *** STEP 1 ***
134142
self.print_step("1", "DUT is commissioned on the same fabric as TH.")
135-
143+
136144
# *** STEP 2 ***
137145
self.print_step("2", "TH reads ServerList attribute from the Descriptor cluster on EP0. If the ICD Management cluster ID (70,0x46) is present in the list, set supports_icd to true, otherwise set supports_icd to false.")
138146
ep0_servers = await self.get_descriptor_server_list()
@@ -142,7 +150,8 @@ async def test_TC_SC_4_3(self):
142150
logging.info(f"\n\n\tsupports_icd: {supports_icd}\n\n")
143151

144152
# *** STEP 3 ***
145-
self.print_step("3", "If supports_icd is true, TH reads ActiveModeThreshold from the ICD Management cluster on EP0 and saves as active_mode_threshold.")
153+
self.print_step(
154+
"3", "If supports_icd is true, TH reads ActiveModeThreshold from the ICD Management cluster on EP0 and saves as active_mode_threshold.")
146155
if supports_icd:
147156
active_mode_threshold_ms = await self.get_idle_mode_threshhold_ms()
148157
logging.info(f"\n\n\tactive_mode_threshold_ms: {active_mode_threshold_ms}\n\n")
@@ -159,11 +168,8 @@ async def test_TC_SC_4_3(self):
159168
self.print_step("5", "TH constructs the instance name for the DUT as the 64-bit compressed Fabric identifier, and the assigned 64-bit Node identifier, each expressed as a fixed-length sixteen-character hexadecimal string, encoded as ASCII (UTF-8) text using capital letters, separated by a hyphen.")
160169
instance_name = self.get_dut_instance_name()
161170

162-
163-
164171
# PENDING STEPS 6-8
165172

166-
167173
mdns = MdnsDiscovery()
168174
operational = await mdns.get_operational_service(
169175
service_name=f"{instance_name}.{MdnsServiceType.OPERATIONAL.value}",
@@ -222,7 +228,8 @@ async def test_TC_SC_4_3(self):
222228

223229
# SAT TXT KEY
224230
if 'SAT' in operational.txt_record:
225-
logging.info(f"SAT key is present in TXT record, verify that it is a decimal value with no leading zeros and is less than or equal to 65535.")
231+
logging.info(
232+
f"SAT key is present in TXT record, verify that it is a decimal value with no leading zeros and is less than or equal to 65535.")
226233
sat_value = operational.txt_record['SAT']
227234
result, message = self.verify_decimal_value(sat_value, self.MAX_SAT_VALUE)
228235
asserts.assert_true(result, message)

0 commit comments

Comments
 (0)