20
20
import chip .clusters as Clusters
21
21
from chip .clusters .Types import NullValue
22
22
from matter_testing_support import MatterBaseTest , async_test_body , default_matter_test_main
23
+ from matter_testing_support import MatterBaseTest , TestStep , async_test_body , default_matter_test_main
23
24
from mobly import asserts
24
25
25
-
26
26
class TC_DISHM_1_2 (MatterBaseTest ):
27
27
28
28
async def read_mode_attribute_expect_success (self , endpoint , attribute ):
29
29
cluster = Clusters .Objects .DishwasherMode
30
30
return await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = attribute )
31
31
32
+ def desc_TC_DISHM_1_2 (self ) -> str :
33
+ return "[TC-DISHM-1.2] Cluster attributes with DUT as Server"
34
+
35
+ def steps_TC_DISHM_1_2 (self ) -> list [TestStep ]:
36
+ steps = [
37
+ TestStep (1 , "Commissioning, already done" , is_commissioning = True ),
38
+ TestStep (2 , "TH reads from the DUT the SupportedModes attribute." ),
39
+ TestStep (3 , "TH reads from the DUT the CurrentMode attribute." ),
40
+ ]
41
+ return steps
42
+
43
+ def pics_TC_DISHM_1_2 (self ) -> list [str ]:
44
+ pics = [
45
+ "DISHM.S" ,
46
+ ]
47
+ return pics
48
+
49
+
32
50
@async_test_body
33
51
async def test_TC_DISHM_1_2 (self ):
34
52
@@ -37,85 +55,77 @@ async def test_TC_DISHM_1_2(self):
37
55
38
56
attributes = Clusters .DishwasherMode .Attributes
39
57
40
- self .print_step (1 , "Commissioning, already done" )
41
-
42
- if self .check_pics ("DISHM.S.A0000" ):
43
- self .print_step (2 , "Read SupportedModes attribute" )
44
- supported_modes = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .SupportedModes )
45
-
46
- logging .info ("SupportedModes: %s" % (supported_modes ))
47
-
48
- asserts .assert_greater_equal (len (supported_modes ), 2 , "SupportedModes must have at least two entries!" )
49
- asserts .assert_less_equal (len (supported_modes ), 255 , "SupportedModes must have at most 255 entries!" )
50
-
51
- supported_modes_dut = []
52
- for m in supported_modes :
53
- if m .mode in supported_modes_dut :
54
- asserts .fail ("SupportedModes must have unique mode values!" )
55
- else :
56
- supported_modes_dut .append (m .mode )
57
-
58
- labels = []
59
- for m in supported_modes :
60
- if m .label in labels :
61
- asserts .fail ("SupportedModes must have unique mode label values!" )
62
- else :
63
- labels .append (m .label )
64
-
65
- # common mode tags
66
- commonTags = {0x0 : 'Auto' ,
67
- 0x1 : 'Quick' ,
68
- 0x2 : 'Quiet' ,
69
- 0x3 : 'LowNoise' ,
70
- 0x4 : 'LowEnergy' ,
71
- 0x5 : 'Vacation' ,
72
- 0x6 : 'Min' ,
73
- 0x7 : 'Max' ,
74
- 0x8 : 'Night' ,
75
- 0x9 : 'Day' }
76
-
77
- # kUnknownEnumValue may not be defined
78
- try :
79
- modeTags = [tag .value for tag in Clusters .DishwasherMode .Enums .ModeTag
80
- if tag is not Clusters .DishwasherMode .Enums .ModeTag .kUnknownEnumValue ]
81
- except AttributeError :
82
- modeTags = Clusters .DishwasherMode .Enums .ModeTag
83
-
84
- for m in supported_modes :
85
- for t in m .modeTags :
86
- is_mfg = (0x8000 <= t .value and t .value <= 0xBFFF )
87
- asserts .assert_true (t .value <= 0xFFFF , "Tag value is > 16 bits" )
88
- asserts .assert_true (t .value in commonTags .keys () or t .value in modeTags or is_mfg ,
89
- "Found a SupportedModes entry with invalid mode tag value!" )
90
-
91
- asserts .assert_true (type (m .label ) is str and len (m .label ) in range (1 , 65 ),
92
- "TagName is not the appropriate length or type" )
93
- if t .value == Clusters .DishwasherMode .Enums .ModeTag .kNormal :
94
- normal_present = True
95
- asserts .assert_true (normal_present , "The Supported Modes does not have an entry of Normal(0x4000)" )
96
-
97
- if self .check_pics ("DISHM.S.A0001" ):
98
- self .print_step (3 , "Read CurrentMode attribute" )
99
- current_mode = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .CurrentMode )
100
-
101
- logging .info ("CurrentMode: %s" % (current_mode ))
102
- asserts .assert_true (current_mode in supported_modes_dut , "CurrentMode is not a supported mode!" )
103
-
104
- if self .check_pics ("DISHM.S.A0003" ):
105
- self .print_step (4 , "Read OnMode attribute" )
106
- on_mode = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .OnMode )
107
-
108
- logging .info ("OnMode: %s" % (on_mode ))
109
- asserts .assert_true (on_mode in supported_modes_dut or on_mode == NullValue , "OnMode is not a supported mode!" )
110
-
111
- if self .check_pics ("DISHM.S.A0002" ):
112
- self .print_step (5 , "Read StartUpMode attribute" )
113
- startup_mode = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .StartUpMode )
114
-
115
- logging .info ("StartUpMode: %s" % (startup_mode ))
116
- asserts .assert_true (startup_mode in supported_modes_dut or startup_mode ==
117
- NullValue , "StartUpMode is not a supported mode!" )
118
-
58
+ self .step (1 )
59
+
60
+ self .step (2 )
61
+ supported_modes = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .SupportedModes )
62
+
63
+ logging .info ("SupportedModes: %s" % (supported_modes ))
64
+
65
+ # Check the number of modes in SupportedModes.
66
+ asserts .assert_greater_equal (len (supported_modes ), 2 , "SupportedModes must have at least two entries!" )
67
+ asserts .assert_less_equal (len (supported_modes ), 255 , "SupportedModes must have at most 255 entries!" )
68
+
69
+ # Check that each Mode field is unique
70
+ supported_modes_dut = []
71
+ for m in supported_modes :
72
+ if m .mode in supported_modes_dut :
73
+ asserts .fail ("SupportedModes must have unique mode values!" )
74
+ else :
75
+ supported_modes_dut .append (m .mode )
76
+
77
+ # Check that each label is unique
78
+ labels = []
79
+ for m in supported_modes :
80
+ if m .label in labels :
81
+ asserts .fail ("SupportedModes must have unique mode label values!" )
82
+ else :
83
+ labels .append (m .label )
84
+
85
+ # common mode tags
86
+ commonTags = {0x0 : 'Auto' ,
87
+ 0x1 : 'Quick' ,
88
+ 0x2 : 'Quiet' ,
89
+ 0x3 : 'LowNoise' ,
90
+ 0x4 : 'LowEnergy' ,
91
+ 0x5 : 'Vacation' ,
92
+ 0x6 : 'Min' ,
93
+ 0x7 : 'Max' ,
94
+ 0x8 : 'Night' ,
95
+ 0x9 : 'Day' }
96
+
97
+ # kUnknownEnumValue may not be defined
98
+ try :
99
+ modeTags = [tag .value for tag in Clusters .DishwasherMode .Enums .ModeTag
100
+ if tag is not Clusters .DishwasherMode .Enums .ModeTag .kUnknownEnumValue ]
101
+ except AttributeError :
102
+ modeTags = Clusters .DishwasherMode .Enums .ModeTag
103
+
104
+ normal_present = false
105
+ for m in supported_modes :
106
+ # need at least 1 mode tag entry
107
+ asserts .assert_greater (len (m .modeTags , 0 , "Must have at least one mode tag." ))
108
+ for t in m .modeTags :
109
+ # value can't exceed 16 bits
110
+ asserts .assert_true (t .value <= 0xFFFF , "Tag value is > 16 bits" )
111
+
112
+ # check that value field is as expected
113
+ is_mfg = (0x8000 <= t .value and t .value <= 0xBFFF )
114
+ asserts .assert_true (t .value in commonTags .keys () or t .value in modeTags or is_mfg ,
115
+ "Found a SupportedModes entry with invalid mode tag value!" )
116
+
117
+ # is this a normal tag? (need at least 1)
118
+ if t .value == Clusters .DishwasherMode .Enums .ModeTag .kNormal :
119
+ normal_present = True
120
+
121
+ # need at least one mode with the normal tag
122
+ asserts .assert_true (normal_present , "The Supported Modes does not have an entry of Normal(0x4000)" )
123
+
124
+ self .step (3 )
125
+ current_mode = await self .read_mode_attribute_expect_success (endpoint = self .endpoint , attribute = attributes .CurrentMode )
126
+
127
+ logging .info ("CurrentMode: %s" % (current_mode ))
128
+ asserts .assert_true (current_mode in supported_modes_dut , "CurrentMode is not a supported mode!" )
119
129
120
130
if __name__ == "__main__" :
121
131
default_matter_test_main ()
0 commit comments