Skip to content

Commit f95ee6f

Browse files
committed
Enhace code based on PR reviews.
1 parent 98f8ea2 commit f95ee6f

File tree

1 file changed

+36
-20
lines changed

1 file changed

+36
-20
lines changed

src/python_testing/TC_BINFO_3_1.py

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545

4646
class TC_BINFO_3_1(MatterBaseTest):
4747
async def read_binfo_attribute_expect_success(self, endpoint, attribute):
48+
"""Read a Basic Information cluster attribute and verify the read succeeds.
49+
50+
Args:
51+
endpoint: The endpoint ID to read the attribute from.
52+
attribute: The Basic Information cluster attribute to read.
53+
54+
Returns:
55+
The attribute value read from the device.
56+
"""
4857
cluster = Clusters.Objects.BasicInformation
4958
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
5059

@@ -78,47 +87,54 @@ def pics_TC_BINFO_3_1(self) -> list[str]:
7887
]
7988
return pics
8089

90+
@async_test_body
91+
async def setup_test(self):
92+
"""Validate required PIXIT parameters before test execution."""
93+
asserts.assert_true("PIXIT.BINFO.Finish" in self.matter_test_config.global_test_params,
94+
"PIXIT.BINFO.Finish must be included on the command line in "
95+
"the --int-arg flag as PIXIT.BINFO.Finish:<finish_value>")
96+
self.pixit_finish = self.matter_test_config.global_test_params["PIXIT.BINFO.Finish"]
97+
98+
asserts.assert_true("PIXIT.BINFO.PrimaryColor" in self.matter_test_config.global_test_params,
99+
"PIXIT.BINFO.PrimaryColor must be included on the command line in "
100+
"the --int-arg flag as PIXIT.BINFO.PrimaryColor:<primary_color_value>")
101+
self.pixit_primary_color = self.matter_test_config.global_test_params["PIXIT.BINFO.PrimaryColor"]
102+
103+
await super().setup_test()
104+
81105
@async_test_body
82106
async def test_TC_BINFO_3_1(self):
83107

84108
endpoint = self.get_endpoint(default=0)
85109
attributes = Clusters.BasicInformation.Attributes
86110

87111
# Read ProductAppearance once and reuse for all steps since the attribute value doesn't change
88-
productAppearance = await self.read_binfo_attribute_expect_success(
112+
product_appearance = await self.read_binfo_attribute_expect_success(
89113
endpoint=endpoint, attribute=attributes.ProductAppearance)
90-
asserts.assert_is_not_none(productAppearance, "ProductAppearance attribute read failed")
114+
asserts.assert_is_not_none(product_appearance, "ProductAppearance attribute read failed")
91115

92116
self.step(1)
93-
asserts.assert_greater_equal(productAppearance.finish, 0, "Finish value is below minimum range")
94-
asserts.assert_less_equal(productAppearance.finish, 5, "Finish value is above maximum range")
117+
asserts.assert_greater_equal(product_appearance.finish, 0, "Finish value is below minimum range")
118+
asserts.assert_less_equal(product_appearance.finish, 5, "Finish value is above maximum range")
95119

96120
self.step(2)
97-
asserts.assert_greater_equal(productAppearance.primaryColor, 0, "PrimaryColor value is below minimum range")
98-
asserts.assert_less_equal(productAppearance.primaryColor, 20, "PrimaryColor value is above maximum range")
121+
asserts.assert_greater_equal(product_appearance.primaryColor, 0, "PrimaryColor value is below minimum range")
122+
asserts.assert_less_equal(product_appearance.primaryColor, 20, "PrimaryColor value is above maximum range")
99123

100124
self.step(3)
101125
# Vendor specific test: This step should verify the actual Finish value matches PIXIT.BINFO.Finish
102126
# For example, if PIXIT.BINFO.Finish is satin(2), the test should verify finish == 2
103-
asserts.assert_true("PIXIT.BINFO.Finish" in self.matter_test_config.global_test_params,
104-
"PIXIT.BINFO.Finish must be included on the command line in "
105-
"the --int-arg flag as PIXIT.BINFO.Finish:<finish_value>")
106-
pixit_finish = self.matter_test_config.global_test_params["PIXIT.BINFO.Finish"]
107-
asserts.assert_equal(productAppearance.finish, pixit_finish,
108-
(f"ProductAppearance.Finish ({productAppearance.finish}) "
109-
f"does not match PIXIT.BINFO.Finish ({pixit_finish})\n"
127+
asserts.assert_equal(product_appearance.finish, self.pixit_finish,
128+
(f"ProductAppearance.Finish ({product_appearance.finish}) "
129+
f"does not match PIXIT.BINFO.Finish ({self.pixit_finish})\n"
110130
"Please verify the PIXIT.BINFO.Finish setting and try again."))
111131

112132
self.step(4)
113133
# Vendor specific test: This step should verify the actual PrimaryColor value matches PIXIT.BINFO.PrimaryColor
114134
# For example, if PIXIT.BINFO.PrimaryColor is purple(5), the test should verify primaryColor == 5
115-
asserts.assert_true("PIXIT.BINFO.PrimaryColor" in self.matter_test_config.global_test_params,
116-
"PIXIT.BINFO.PrimaryColor must be included on the command line in "
117-
"the --int-arg flag as PIXIT.BINFO.PrimaryColor:<primary_color_value>")
118-
pixit_primary_color = self.matter_test_config.global_test_params["PIXIT.BINFO.PrimaryColor"]
119-
asserts.assert_equal(productAppearance.primaryColor, pixit_primary_color,
120-
(f"ProductAppearance.PrimaryColor ({productAppearance.primaryColor})\n"
121-
f"does not match PIXIT.BINFO.PrimaryColor ({pixit_primary_color})\n"
135+
asserts.assert_equal(product_appearance.primaryColor, self.pixit_primary_color,
136+
(f"ProductAppearance.PrimaryColor ({product_appearance.primaryColor}) "
137+
f"does not match PIXIT.BINFO.PrimaryColor ({self.pixit_primary_color})\n"
122138
"Please verify the PIXIT.BINFO.PrimaryColor setting and try again."))
123139

124140

0 commit comments

Comments
 (0)