diff --git a/test/test_client_async_asyncio.py b/test/test_client_async_asyncio.py index 42455f53cd..035c2dbdda 100644 --- a/test/test_client_async_asyncio.py +++ b/test/test_client_async_asyncio.py @@ -7,6 +7,11 @@ ReconnectingAsyncioModbusTcpClient, ModbusClientProtocol, ModbusUdpClientProtocol) from test.asyncio_test_helper import return_as_coroutine, run_coroutine + from pymodbus.client.asynchronous import schedulers + from pymodbus.client.asynchronous.tcp import AsyncModbusTCPClient + from pymodbus.client.asynchronous.udp import AsyncModbusUDPClient + from pymodbus.client.asynchronous.tls import AsyncModbusTLSClient + from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient from pymodbus.factory import ClientDecoder from pymodbus.exceptions import ConnectionException from pymodbus.transaction import ModbusSocketFramer @@ -68,6 +73,40 @@ def test_factory_initialization_state(self): assert client.loop is mock_loop assert client.protocol_class is mock_protocol_class + @pytest.mark.asyncio + async def test_initialization_tcp_in_loop(self): + _, client = AsyncModbusTCPClient(schedulers.ASYNC_IO, port=5020) + client = await client + + assert not client.connected + assert client.port == 5020 + assert client.delay_ms < client.DELAY_MAX_MS + + @pytest.mark.asyncio + async def test_initialization_udp_in_loop(self): + _, client = AsyncModbusUDPClient(schedulers.ASYNC_IO, port=5020) + client = await client + + assert client.connected + assert client.port == 5020 + assert client.delay_ms < client.DELAY_MAX_MS + + @pytest.mark.asyncio + async def test_initialization_tls_in_loop(self): + _, client = AsyncModbusTLSClient(schedulers.ASYNC_IO, port=5020) + client = await client + + assert not client.connected + assert client.port == 5020 + assert client.delay_ms < client.DELAY_MAX_MS + + @pytest.mark.asyncio + async def test_initialization_serial_in_loop(self): + _, client = AsyncModbusSerialClient(schedulers.ASYNC_IO, port='/tmp/ptyp0', baudrate=9600, method='rtu') + + assert client.port == '/tmp/ptyp0' + assert client.baudrate == 9600 + def test_factory_reset_wait_before_reconnect(self): mock_protocol_class = mock.MagicMock() mock_loop = mock.MagicMock() @@ -80,7 +119,6 @@ def test_factory_reset_wait_before_reconnect(self): client.reset_delay() assert client.delay_ms == initial_delay - def test_factory_stop(self): mock_protocol_class = mock.MagicMock() mock_loop = mock.MagicMock()