fixed unix server/client tests

This commit is contained in:
Daniil Fajnberg 2022-03-08 10:22:07 +01:00
parent d05f84b2c3
commit eb152e4d75
2 changed files with 6 additions and 6 deletions

View File

@ -190,9 +190,9 @@ class UnixControlClientTestCase(IsolatedAsyncioTestCase):
self.mock_base_init.assert_called_once_with(**self.kwargs) self.mock_base_init.assert_called_once_with(**self.kwargs)
@patch.object(client, 'print') @patch.object(client, 'print')
@patch.object(client, 'open_unix_connection') async def test__open_connection(self, mock_print: MagicMock):
async def test__open_connection(self, mock_open_unix_connection: AsyncMock, mock_print: MagicMock): expected_output = 'something'
mock_open_unix_connection.return_value = expected_output = 'something' self.client._open_unix_connection = mock_open_unix_connection = AsyncMock(return_value=expected_output)
kwargs = {'a': 1, 'b': 2} kwargs = {'a': 1, 'b': 2}
output = await self.client._open_connection(**kwargs) output = await self.client._open_connection(**kwargs)
self.assertEqual(expected_output, output) self.assertEqual(expected_output, output)

View File

@ -151,9 +151,9 @@ class UnixControlServerTestCase(IsolatedAsyncioTestCase):
self.assertEqual(Path(self.path), self.server._socket_path) self.assertEqual(Path(self.path), self.server._socket_path)
self.mock_base_init.assert_called_once_with(self.mock_pool, **self.kwargs) self.mock_base_init.assert_called_once_with(self.mock_pool, **self.kwargs)
@patch.object(server, 'start_unix_server') async def test__get_server_instance(self):
async def test__get_server_instance(self, mock_start_unix_server: AsyncMock): expected_output = 'totally_a_server'
mock_start_unix_server.return_value = expected_output = 'totally_a_server' self.server._start_unix_server = mock_start_unix_server = AsyncMock(return_value=expected_output)
mock_callback, mock_kwargs = MagicMock(), {'a': 1, 'b': 2} mock_callback, mock_kwargs = MagicMock(), {'a': 1, 'b': 2}
args = [mock_callback] args = [mock_callback]
output = await self.server._get_server_instance(*args, **mock_kwargs) output = await self.server._get_server_instance(*args, **mock_kwargs)