Skip to content

Commit

Permalink
Improve test assertions and manual testing steps
Browse files Browse the repository at this point in the history
- Use Matter-specific type assertions in TC_CGEN_2_5
- Update TC_CGEN_2_8 manual testing flow and prompts
  • Loading branch information
swan-amazon committed Feb 5, 2025
1 parent 2d8722d commit 6cfe31e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/python_testing/TC_CGEN_2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from chip import ChipDeviceCtrl
from chip.clusters.Attribute import ValueDecodeFailure
from chip.commissioning import ROOT_ENDPOINT_ID
from chip.testing import matter_asserts
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from mobly import asserts

Expand Down Expand Up @@ -120,7 +121,7 @@ async def test_TC_CGEN_2_5(self):
if isinstance(tc_update_deadline, ValueDecodeFailure):
asserts.assert_is_none(tc_update_deadline.TLVValue)
else:
asserts.assert_less(tc_update_deadline, 2**32, "TCUpdateDeadline exceeds uint32 range")
matter_asserts.assert_valid_uint32(tc_update_deadline, "TCUpdateDeadline exceeds uint32 range")

# Step 4: Verify TC feature flag in FeatureMap
self.step(4)
Expand All @@ -129,7 +130,7 @@ async def test_TC_CGEN_2_5(self):
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.FeatureMap)],
)
feature_map = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.FeatureMap]
asserts.assert_equal(feature_map & 0x1, 0x1, "TC feature flag is not set.")
asserts.assert_equal(feature_map & Clusters.GeneralCommissioning.Bitmaps.Feature.kTermsAndConditions, Clusters.GeneralCommissioning.Bitmaps.Feature.kTermsAndConditions, "TC feature flag is not set.")

# Step 5: Send SetTCAcknowledgements
self.step(5)
Expand Down Expand Up @@ -184,7 +185,7 @@ async def test_TC_CGEN_2_5(self):
self.step(11)
response = await commissioner.ReadAttribute(nodeid=self.dut_node_id, attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCMinRequiredVersion)])
min_required_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCMinRequiredVersion]
asserts.assert_is_instance(min_required_version, int, "TCMinRequiredVersion is not a uint16 type.")
matter_asserts.assert_valid_uint16(min_required_version, "TCMinRequiredVersion is not a uint16 type.")

# Step 12: Verify TCAcknowledgementsRequired is False again
self.step(12)
Expand Down
13 changes: 7 additions & 6 deletions src/python_testing/TC_CGEN_2_8.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,17 @@ async def test_TC_CGEN_2_8(self):
"First CommissioningComplete failed",
)

# Step 5: Factory reset is handled by test runner configuration
# Step 5: Factory reset is handled by test operator
self.step(5)

# Step 6: Put device in commissioning mode (requiring user input, so skip in CI)
self.step(6)
if not self.check_pics('PICS_USER_PROMPT'):
self.skip_all_remaining_steps(7)
self.skip_all_remaining_steps(6)
return

self.wait_for_user_input(prompt_msg="Set the DUT into commissioning mode")
self.wait_for_user_input(prompt_msg="Manually trigger factory reset on the DUT, then continue")

# Step 6: Put device in commissioning mode (requiring user input, so skip in CI)
self.step(6)
self.wait_for_user_input(prompt_msg="Manually set the DUT into commissioning mode, then continue")

# Step 7: Commission without TC acknowledgements
self.step(7)
Expand Down

0 comments on commit 6cfe31e

Please sign in to comment.