Tests verifying user socket functionality works correctly.
| 100 | |
| 101 | |
| 102 | class TestUserSocketFunctionality: |
| 103 | """Tests verifying user socket functionality works correctly.""" |
| 104 | |
| 105 | @pytest.mark.asyncio |
| 106 | async def test_user_socket_recv_timeout(self, clientAsync, socket_manager): |
| 107 | """User socket recv() should timeout gracefully when no events.""" |
| 108 | user_socket = socket_manager.user_socket() |
| 109 | |
| 110 | async with user_socket: |
| 111 | # recv() should timeout without errors (no events on quiet account) |
| 112 | with pytest.raises(asyncio.TimeoutError): |
| 113 | await asyncio.wait_for(user_socket.recv(), timeout=2) |
| 114 | |
| 115 | @pytest.mark.asyncio |
| 116 | async def test_user_socket_context_manager(self, clientAsync, socket_manager): |
| 117 | """User socket should work as async context manager.""" |
| 118 | user_socket = socket_manager.user_socket() |
| 119 | |
| 120 | # Should not be connected initially |
| 121 | assert user_socket._subscription_id is None |
| 122 | |
| 123 | async with user_socket: |
| 124 | # Should be connected inside context |
| 125 | assert user_socket._subscription_id is not None |
| 126 | assert user_socket._uses_ws_api_subscription is True |
| 127 | |
| 128 | # Subscription ID is cleared after unsubscribe |
| 129 | assert user_socket._subscription_id is None |
| 130 | |
| 131 | |
| 132 | class TestNonUserSockets: |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…