def test_serial_client_receive(self): """ Test the serial client receive method""" client = ModbusSerialClient() self.assertRaises(ConnectionException, lambda: client.receive(1024)) client.socket = MockSocket() self.assertEqual('', client.receive(0)) self.assertEqual('\x00'*4, client.receive(4))
def test_serial_client_receive(self): """ Test the serial client receive method""" client = ModbusSerialClient() self.assertRaises(ConnectionException, lambda: client.receive(1024)) client.socket = MockSocket() self.assertEqual('', client.receive(0)) self.assertEqual('\x00' * 4, client.receive(4))
def test_basic_sync_serial_client(self): """ Test the basic methods for the serial sync client""" # receive/send client = ModbusSerialClient() client.socket = MockSocket() self.assertEqual(0, client.send(None)) self.assertEqual(1, client.send('\x00')) self.assertEqual('\x00', client.receive(1)) # connect/disconnect self.assertTrue(client.connect()) client.close() # already closed socket client.socket = False client.close() self.assertEqual('ascii baud[19200]', str(client))
def test_basic_sync_serial_client(self): """ Test the basic methods for the serial sync client""" # receive/send client = ModbusSerialClient() client.socket = MockSocket() self.assertEqual(0, client.send(None)) self.assertEqual(1, client.send('\x00')) self.assertEqual('\x00', client.receive(1)) # connect/disconnect self.assertTrue(client.connect()) client.close() # already closed socket client.socket = False client.close() self.assertEqual('ascii baud[19200]', str(client))