Пример #1
0
 def testUdpServerProcess(self):
     ''' test that the synchronous UDP server processes requests '''
     with patch('pymodbus.compat.socketserver.ThreadingUDPServer') as mock_server:
         server = ModbusUdpServer(None)
         request = ('data', 'socket')
         server.process_request(request, 'client')
         self.assertTrue(mock_server.process_request.called)
Пример #2
0
 def testUdpServerClose(self):
     ''' test that the synchronous UDP server closes correctly '''
     with patch.object(socket.socket, 'bind') as mock_socket:
         identity = ModbusDeviceIdentification(info={0x00: 'VendorName'})
         server = ModbusUdpServer(context=None, identity=identity)
         server.threads.append(Mock(**{'running': True}))
         server.server_close()
         self.assertEqual(server.control.Identity.VendorName, 'VendorName')
         self.assertFalse(server.threads[0].running)
Пример #3
0
 def testUdpServerClose(self):
     ''' test that the synchronous UDP server closes correctly '''
     identity = ModbusDeviceIdentification(info={0x00: 'VendorName'})
     server = ModbusUdpServer(context=None,
                              identity=identity,
                              bind_and_activate=False)
     server.server_activate()
     server.threads.append(Mock(**{'running': True}))
     server.server_close()
     self.assertEqual(server.control.Identity.VendorName, 'VendorName')
     self.assertFalse(server.threads[0].running)