Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger committed Mar 8, 2024
1 parent fd882f0 commit 7798535
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion kraken/spot/websocket/connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
17 changes: 9 additions & 8 deletions tests/spot/test_spot_websocket_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7798535

Please sign in to comment.