@@ -35,9 +35,8 @@ def test_encode_mqtt_payload_basic():
3535 assert len (result .payload ) % 16 == 0 # Should be padded to AES block size
3636
3737 # Decode the payload to verify structure
38- # With general stringification, numbers are converted to strings: 42 -> "42"
3938 decoded_data = decode_rpc_response (result )
40- assert decoded_data == {200 : ' {"test": "data", "number": 42}' }
39+ assert decoded_data == {200 : {"test" : "data" , "number" : 42 }}
4140
4241
4342def test_encode_mqtt_payload_empty_data ():
@@ -55,21 +54,6 @@ def test_encode_mqtt_payload_empty_data():
5554 assert decoded_data == {}
5655
5756
58- def test_encode_mqtt_payload_list_conversion ():
59- """Test that lists are converted to string representation (Fix validity)."""
60- # This verifies the fix where lists must be encoded as strings
61- data : dict [RoborockDyadDataProtocol | RoborockZeoProtocol , Any ] = {RoborockDyadDataProtocol .ID_QUERY : [101 , 102 ]}
62-
63- result = encode_mqtt_payload (data )
64-
65- # Decode manually to check the raw JSON structure
66- decoded_json = json .loads (unpad (result .payload , AES .block_size ).decode ())
67-
68- # ID_QUERY (10000) should be a string "[101, 102]", not a list [101, 102]
69- assert decoded_json ["dps" ]["10000" ] == "[101, 102]"
70- assert isinstance (decoded_json ["dps" ]["10000" ], str )
71-
72-
7357def test_encode_mqtt_payload_complex_data ():
7458 """Test encoding with complex nested data."""
7559 data : dict [RoborockDyadDataProtocol | RoborockZeoProtocol , Any ] = {
@@ -92,17 +76,13 @@ def test_encode_mqtt_payload_complex_data():
9276 # Decode the payload to verify structure
9377 decoded_data = decode_rpc_response (result )
9478 assert decoded_data == {
95- 201 : json .dumps (
96- {
97- "nested" : {"deep" : {"value" : 123 }},
98- # Note: The list inside the dictionary is NOT converted because
99- # our fix only targets top-level list values in the dps map
100- "list" : [1 , 2 , 3 , "test" ],
101- "boolean" : True ,
102- "null" : None ,
103- }
104- ),
105- 204 : '"simple_value"' ,
79+ 201 : {
80+ "nested" : {"deep" : {"value" : 123 }},
81+ "list" : [1 , 2 , 3 , "test" ],
82+ "boolean" : True ,
83+ "null" : None ,
84+ },
85+ 204 : "simple_value" ,
10686 }
10787
10888
0 commit comments