@@ -1381,30 +1381,32 @@ class TestWsApiPayload(unittest.TestCase):
13811381 def setUp (self ):
13821382 self .dummy_config = SimpleNamespace (api_key = "test-api-key" , api_secret = "test-api-secret" )
13831383 self .base_payload = {
1384- "id" : "123" ,
13851384 "params" : {
13861385 "some_param" : "value" ,
13871386 "list_param" : [1 , 2 , 3 ],
1388- "dict_param" : {"nested" : "data" }
1387+ "dict_param" : {"nested" : "data" },
1388+ "id" : "123" ,
13891389 }
13901390 }
13911391
13921392 def test_payload_with_api_key_and_signed (self ):
13931393 websocket_options = WebsocketApiOptions (api_key = True , skip_auth = False , is_signed = True , signer = None )
1394-
1394+ expected_id = self .base_payload ["params" ]["id" ]
1395+
13951396 with patch ("binance_common.utils.websocket_api_signature" , return_value = {"signed" : True }) as mock_signature :
13961397 result = ws_api_payload (self .dummy_config , self .base_payload , websocket_options )
13971398 mock_signature .assert_called_once ()
13981399
1399- assert result ["id" ] == self . base_payload [ "id" ]
1400+ assert result ["id" ] == expected_id
14001401 assert result ["params" ] == {"signed" : True }
14011402
14021403 def test_payload_without_api_key (self ):
14031404 websocket_options = WebsocketApiOptions (api_key = False , skip_auth = False , is_signed = False , signer = None )
1405+ expected_id = self .base_payload ["params" ]["id" ]
14041406 result = ws_api_payload (self .dummy_config , self .base_payload , websocket_options )
14051407
14061408 assert "apiKey" not in result ["params" ]
1407- assert result ["id" ] == self . base_payload [ "id" ]
1409+ assert result ["id" ] == expected_id
14081410 assert isinstance (result ["params" ]["listParam" ], str )
14091411 assert isinstance (result ["params" ]["dictParam" ], str )
14101412 assert result ["params" ]["someParam" ] == "value"
0 commit comments