示例#1
0
    def testRemoteSlaveSetValues(self):
        ''' Test setting values against a remote slave context '''
        client = mock()
        client.write_coils = lambda a, b: WriteMultipleCoilsResponse()

        context = RemoteSlaveContext(client)
        result = context.setValues(1, 0, [1])
        self.assertTrue(True)
示例#2
0
    def testRemoteSlaveSetValues(self):
        ''' Test setting values against a remote slave context '''
        client  = mock()
        client.write_coils = lambda a,b: WriteMultipleCoilsResponse()

        context = RemoteSlaveContext(client)
        result  = context.setValues(1, 0, [1])
        self.assertTrue(True)
示例#3
0
    def testRemoteSlaveValidateValues(self):
        ''' Test validating against a remote slave context '''
        client  = mock()
        client.read_coils = lambda a,b: ReadCoilsResponse([1]*10)
        client.read_input_registers = lambda a,b: ReadInputRegistersResponse([10]*10)
        client.read_holding_registers = lambda a,b: ExceptionResponse(0x15)

        context = RemoteSlaveContext(client)
        result  = context.validate(1, 0, 10)
        self.assertTrue(result)

        result  = context.validate(4, 0, 10)
        self.assertTrue(result)

        result  = context.validate(3, 0, 10)
        self.assertFalse(result)
示例#4
0
    def testRemoteSlaveGetValues(self):
        ''' Test getting values from a remote slave context '''
        client  = mock()
        client.read_coils = lambda a,b: ReadCoilsResponse([1]*10)
        client.read_input_registers = lambda a,b: ReadInputRegistersResponse([10]*10)
        client.read_holding_registers = lambda a,b: ExceptionResponse(0x15)

        context = RemoteSlaveContext(client)
        result  = context.getValues(1, 0, 10)
        self.assertEqual(result, [1]*10)

        result  = context.getValues(4, 0, 10)
        self.assertEqual(result, [10]*10)

        result  = context.getValues(3, 0, 10)
        self.assertNotEqual(result, [10]*10)
示例#5
0
    def testRemoteSlaveValidateValues(self):
        ''' Test validating against a remote slave context '''
        client = mock()
        client.read_coils = lambda a, b: ReadCoilsResponse([1] * 10)
        client.read_input_registers = lambda a, b: ReadInputRegistersResponse(
            [10] * 10)
        client.read_holding_registers = lambda a, b: ExceptionResponse(0x15)

        context = RemoteSlaveContext(client)
        result = context.validate(1, 0, 10)
        self.assertTrue(result)

        result = context.validate(4, 0, 10)
        self.assertTrue(result)

        result = context.validate(3, 0, 10)
        self.assertFalse(result)
示例#6
0
    def testRemoteSlaveGetValues(self):
        ''' Test getting values from a remote slave context '''
        client = mock()
        client.read_coils = lambda a, b: ReadCoilsResponse([1] * 10)
        client.read_input_registers = lambda a, b: ReadInputRegistersResponse(
            [10] * 10)
        client.read_holding_registers = lambda a, b: ExceptionResponse(0x15)

        context = RemoteSlaveContext(client)
        result = context.getValues(1, 0, 10)
        self.assertEqual(result, [1] * 10)

        result = context.getValues(4, 0, 10)
        self.assertEqual(result, [10] * 10)

        result = context.getValues(3, 0, 10)
        self.assertNotEqual(result, [10] * 10)