Beispiel #1
0
    def testKramer602Listener(self):
        port = MockSerialPort()
        port.read = MagicMock(return_value=[chr(0x28), chr(0x81)])  # Notification that input 1 sent to output 1

        k = Kramer602("Test", port)

        c = Controller()
        c.addDevice(k)
        kl = Kramer602Listener("TestListener", k.deviceID, c, machineNumber=1)

        dispatcher = NullDispatcher()
        dispatcher.updateOutputMappings = MagicMock()
        kl.registerDispatcher(dispatcher)
        kl.start()
        threading.Event().wait(0.1)
        kl.stop()

        dispatcher.updateOutputMappings.assert_called_with({'Test': {1: 1}})

        port = MockSerialPort()
        port.read = MagicMock(return_value=[chr(0x28), chr(0x8A)])  # Notification that input 5 sent to output 2

        k = Kramer602("Test", port)
        c = Controller()
        c.addDevice(k)
        kl = Kramer602Listener("TestListener", k.deviceID, c, machineNumber=1)

        dispatcher = NullDispatcher()
        dispatcher.updateOutputMappings = MagicMock()
        kl.registerDispatcher(dispatcher)
        kl.start()
        threading.Event().wait(0.1)
        kl.stop()

        dispatcher.updateOutputMappings.assert_called_with({'Test': {2: 5}})
Beispiel #2
0
    def testKramer602Listener(self):
        port = MockSerialPort()
        port.read = MagicMock(return_value=[
            chr(0x28), chr(0x81)
        ])  # Notification that input 1 sent to output 1

        k = Kramer602("Test", port)

        c = Controller()
        c.addDevice(k)
        kl = Kramer602Listener("TestListener", k.deviceID, c, machineNumber=1)

        dispatcher = NullDispatcher()
        dispatcher.updateOutputMappings = MagicMock()
        kl.registerDispatcher(dispatcher)
        kl.start()
        threading.Event().wait(0.1)
        kl.stop()

        dispatcher.updateOutputMappings.assert_called_with({'Test': {1: 1}})

        port = MockSerialPort()
        port.read = MagicMock(return_value=[
            chr(0x28), chr(0x8A)
        ])  # Notification that input 5 sent to output 2

        k = Kramer602("Test", port)
        c = Controller()
        c.addDevice(k)
        kl = Kramer602Listener("TestListener", k.deviceID, c, machineNumber=1)

        dispatcher = NullDispatcher()
        dispatcher.updateOutputMappings = MagicMock()
        kl.registerDispatcher(dispatcher)
        kl.start()
        threading.Event().wait(0.1)
        kl.stop()

        dispatcher.updateOutputMappings.assert_called_with({'Test': {2: 5}})