@@ -36,7 +36,7 @@ def test_encode_mqtt_payload_basic():
3636
3737 # Decode the payload to verify structure
3838 decoded_data = decode_rpc_response (result )
39- assert decoded_data == {200 : ' {"test": "data", "number": 42}' }
39+ assert decoded_data == {200 : {"test" : "data" , "number" : 42 }}
4040
4141
4242def test_encode_mqtt_payload_empty_data ():
@@ -54,12 +54,11 @@ def test_encode_mqtt_payload_empty_data():
5454 assert decoded_data == {}
5555
5656
57- def test_encode_mqtt_payload_list_conversion ():
58- """Test that lists are converted to string representation (Fix validity)."""
59- # This verifies the fix where lists must be encoded as strings
57+ def test_value_encoder ():
58+ """Test that value_encoder is applied to all values."""
6059 data : dict [RoborockDyadDataProtocol | RoborockZeoProtocol , Any ] = {RoborockDyadDataProtocol .ID_QUERY : [101 , 102 ]}
6160
62- result = encode_mqtt_payload (data )
61+ result = encode_mqtt_payload (data , value_encoder = json . dumps )
6362
6463 # Decode manually to check the raw JSON structure
6564 decoded_json = json .loads (unpad (result .payload , AES .block_size ).decode ())
@@ -91,17 +90,15 @@ def test_encode_mqtt_payload_complex_data():
9190 # Decode the payload to verify structure
9291 decoded_data = decode_rpc_response (result )
9392 assert decoded_data == {
94- 201 : json .dumps (
95- {
93+ 201 : {
9694 "nested" : {"deep" : {"value" : 123 }},
9795 # Note: The list inside the dictionary is NOT converted because
9896 # our fix only targets top-level list values in the dps map
9997 "list" : [1 , 2 , 3 , "test" ],
10098 "boolean" : True ,
10199 "null" : None ,
102- }
103- ),
104- 204 : '"simple_value"' ,
100+ },
101+ 204 : "simple_value" ,
105102 }
106103
107104
0 commit comments