Skip to content

Commit

Permalink
use write_single_attribute method instead of WriteAttribute, remove d…
Browse files Browse the repository at this point in the history
…ebug logging
  • Loading branch information
asirko-soft committed Jan 21, 2025
1 parent b0ee082 commit 2806364
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions src/python_testing/TC_FLABEL_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@
# quiet: true
# === END CI TEST ARGUMENTS ===

import logging
import chip.clusters as Clusters
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from chip.interaction_model import Status
from mobly import asserts

logger = logging.getLogger(__name__)


class Test_TC_FLABEL_2_1(MatterBaseTest):
def pics_TC_FLABEL_2_1(self) -> list[str]:
Expand All @@ -64,36 +61,29 @@ async def test_TC_FLABEL_2_1(self):
attribute=Clusters.Objects.FixedLabel.Attributes.LabelList
)
asserts.assert_true(isinstance(initial_labels, list), "LabelList should be a list type")
logger.info(f"Initial LabelList: {initial_labels}")

# Step 3: Attempt to write LabelList (should fail)
self.step(3)
test_label = [Clusters.Objects.FixedLabel.Structs.LabelStruct(
label="Test_Label",
value="Test_Value"
)]
logger.info(f"Attempting to write LabelList: {test_label}")
test_label = Clusters.Objects.FixedLabel.Attributes.LabelList(
[Clusters.Objects.FixedLabel.Structs.LabelStruct(
label="Test_Label",
value="Test_Value"
)]
)

try:
result = await self.default_controller.WriteAttribute(
self.dut_node_id,
[(1, Clusters.Objects.FixedLabel.Attributes.LabelList(test_label))]
)
logger.info(f"Write result: {result}")
logger.info(f"Write status: {result[0]}")
asserts.assert_equal(result[0].Status, Status.UnsupportedWrite, "Expected UNSUPPORTED_WRITE status")
except Exception as e:
logger.error(f"Unexpected error during write: {str(e)}")
asserts.fail(f"Unexpected error during write: {str(e)}")
# Use write_single_attribute with expect_success=False since we expect it to fail
write_status = await self.write_single_attribute(
attribute_value=test_label,
expect_success=False
)
asserts.assert_equal(write_status, Status.UnsupportedWrite, "Expected UNSUPPORTED_WRITE status")

# Step 4: Verify LabelList hasn't changed
self.step(4)
final_labels = await self.read_single_attribute_check_success(
cluster=Clusters.Objects.FixedLabel,
attribute=Clusters.Objects.FixedLabel.Attributes.LabelList
)
logger.info(f"Final LabelList: {final_labels}")

asserts.assert_equal(initial_labels, final_labels,
"LabelList should remain unchanged after write attempt")

Expand Down

0 comments on commit 2806364

Please sign in to comment.