From 7798535a16382ba11e064c75c897f40999e3d78c Mon Sep 17 00:00:00 2001 From: Benjamin Thomas Schwertfeger Date: Fri, 8 Mar 2024 15:59:59 +0100 Subject: [PATCH] fix tests --- kraken/spot/websocket/connectors.py | 2 +- tests/spot/test_spot_websocket_v2.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/kraken/spot/websocket/connectors.py b/kraken/spot/websocket/connectors.py index 1443f4f2..f3c1e971 100644 --- a/kraken/spot/websocket/connectors.py +++ b/kraken/spot/websocket/connectors.py @@ -604,7 +604,7 @@ def __transform_subscription( # Kraken somehow responds with this key - but this is not # accepted when subscribing (Dec 2023). if ( - subscription_copy["method"] == "unsubscribe" + subscription_copy["method"] in {"subscribe", "unsubscribe"} and "maxratecount" in subscription["result"] ): del subscription_copy["result"]["maxratecount"] diff --git a/tests/spot/test_spot_websocket_v2.py b/tests/spot/test_spot_websocket_v2.py index b9ff5d98..7bed992a 100644 --- a/tests/spot/test_spot_websocket_v2.py +++ b/tests/spot/test_spot_websocket_v2.py @@ -234,7 +234,7 @@ async def test_subscription() -> None: asyncio_run(test_subscription()) assert ( - '{"method": "subscribe", "req_id": 12345678, "result": {"channel": "ticker", "snapshot": true, "symbol": "BTC/USD"}, "success": true, "time_in":' + '{"method": "subscribe", "req_id": 12345678, "result": {"channel": "ticker", "event_trigger": "trades", "snapshot": true, "symbol": "BTC/USD"}, "success": true, "time_in":' in caplog.text ) @@ -313,9 +313,9 @@ async def test_unsubscribe() -> None: asyncio_run(test_unsubscribe()) for expected in ( - '{"method": "subscribe", "req_id": 123456789, "result": {"channel": "ticker", "snapshot": true, "symbol": "BTC/USD"}, "success": true, "time_in": ', + '{"method": "subscribe", "req_id": 123456789, "result": {"channel": "ticker", "event_trigger": "trades", "snapshot": true, "symbol": "BTC/USD"}, "success": true, "time_in": ', '{"channel": "ticker", "type": "snapshot", "data": [{"symbol": "BTC/USD", ', - '{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "ticker", "symbol": "BTC/USD"}, "success": true, "time_in": ', + '{"method": "unsubscribe", "req_id": 987654321, "result": {"channel": "ticker", "event_trigger": "trades", "symbol": "BTC/USD"}, "success": true, "time_in": ', ): assert expected in caplog.text @@ -461,6 +461,7 @@ def test___transform_subscription_no_change() -> None: ) +@pytest.mark.wip() @pytest.mark.spot() @pytest.mark.spot_auth() @pytest.mark.spot_websocket() @@ -509,13 +510,13 @@ async def check_reconnect() -> None: '{"channel": "status", "data": [{"api_version": "v2", "connection_id": ', '"system": "online", "version": ', # "2.0.x" '"type": "update"}', - '{"method": "subscribe", "result": {"channel": "ticker", "snapshot": true, "symbol": "BTC/USD"}, "success": true,', + '{"method": "subscribe", "result": {"channel": "ticker", "event_trigger": "trades", "snapshot": true, "symbol": "BTC/USD"}, "success": true,', '"channel": "ticker", "type": "snapshot", "data": [{"symbol": "BTC/USD", ', "got an exception sent 1000 (OK); then received 1000 (OK)", - "Recover public subscriptions [{'channel': 'ticker', 'snapshot': True, 'symbol': ['BTC/USD']}]: waiting", - "Recover public subscriptions [{'channel': 'ticker', 'snapshot': True, 'symbol': ['BTC/USD']}]: done", - "Recover authenticated subscriptions [{'channel': 'executions', 'maxratecount': 180, 'snapshot': True}]: waiting", - "Recover authenticated subscriptions [{'channel': 'executions', 'maxratecount': 180, 'snapshot': True}]: done", + "Recover public subscriptions [{'channel': 'ticker', 'event_trigger': 'trades', 'snapshot': True, 'symbol': ['BTC/USD']}]: waiting", + "Recover public subscriptions [{'channel': 'ticker', 'event_trigger': 'trades', 'snapshot': True, 'symbol': ['BTC/USD']}]: done", + "Recover authenticated subscriptions [{'channel': 'executions', 'snapshot': True}]: waiting", + "Recover authenticated subscriptions [{'channel': 'executions', 'snapshot': True}]: done", ): assert phrase in caplog.text