diff --git a/massive/websocket/__init__.py b/massive/websocket/__init__.py index 7463b4cb..da11c040 100644 --- a/massive/websocket/__init__.py +++ b/massive/websocket/__init__.py @@ -265,7 +265,7 @@ def _parse_subscription(s: str): s = s.strip() split = s.split(".", 1) # Split at the first period if len(split) != 2: - logger.warning("invalid subscription:", s) + logger.warning("invalid subscription: %s", s) return [None, None] return split diff --git a/test_websocket/test_status.py b/test_websocket/test_status.py index d333c9c8..c2bf2666 100644 --- a/test_websocket/test_status.py +++ b/test_websocket/test_status.py @@ -95,3 +95,13 @@ async def test_auth_reply_status_is_logged(self): "Maximum number of websocket connections exceeded." ], ) + + async def test_invalid_subscription_is_logged(self): + # a topic without a channel prefix is skipped with a warning + c = WebSocketClient(api_key="") + with self.assertLogs("WebSocketClient", level="WARNING") as logs: + c.subscribe("AAPL") + self.assertEqual( + logs.output, ["WARNING:WebSocketClient:invalid subscription: AAPL"] + ) + self.assertEqual(c.scheduled_subs, set())