|
|
@ -14,8 +14,11 @@ class TestSimpleClient: |
|
|
|
assert not client.connected |
|
|
|
|
|
|
|
def test_connect(self): |
|
|
|
mock_client = mock.MagicMock() |
|
|
|
original_client_class = SimpleClient.client_class |
|
|
|
SimpleClient.client_class = mock_client |
|
|
|
|
|
|
|
client = SimpleClient(123, a='b') |
|
|
|
with mock.patch('socketio.simple_client.Client') as mock_client: |
|
|
|
client.connect('url', headers='h', auth='a', transports='t', |
|
|
|
namespace='n', socketio_path='s', wait_timeout='w') |
|
|
|
mock_client.assert_called_once_with(123, a='b') |
|
|
@ -28,9 +31,14 @@ class TestSimpleClient: |
|
|
|
assert client.namespace == 'n' |
|
|
|
assert not client.input_event.is_set() |
|
|
|
|
|
|
|
SimpleClient.client_class = original_client_class |
|
|
|
|
|
|
|
def test_connect_context_manager(self): |
|
|
|
mock_client = mock.MagicMock() |
|
|
|
original_client_class = SimpleClient.client_class |
|
|
|
SimpleClient.client_class = mock_client |
|
|
|
|
|
|
|
with SimpleClient(123, a='b') as client: |
|
|
|
with mock.patch('socketio.simple_client.Client') as mock_client: |
|
|
|
client.connect('url', headers='h', auth='a', transports='t', |
|
|
|
namespace='n', socketio_path='s', |
|
|
|
wait_timeout='w') |
|
|
@ -44,6 +52,8 @@ class TestSimpleClient: |
|
|
|
assert client.namespace == 'n' |
|
|
|
assert not client.input_event.is_set() |
|
|
|
|
|
|
|
SimpleClient.client_class = original_client_class |
|
|
|
|
|
|
|
def test_connect_twice(self): |
|
|
|
client = SimpleClient(123, a='b') |
|
|
|
client.client = mock.MagicMock() |
|
|
|