def test_serial_client_send(self): """ Test the serial client send method""" client = ModbusSerialClient() self.assertRaises(ConnectionException, lambda: client.send(None)) client.socket = MockSocket() self.assertEqual(0, client.send(None)) self.assertEqual(4, client.send('1234'))
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))