Example #1
0
    def testSendControlSignalsToBlinds(self):
        c = Controller()
        cp = ControllerProxy(c)

        self.PyroThread(c.daemon).start()

        blinds = UpDownStopArray("Blinds", c)
        blinds.lower = MagicMock(return_value=0)
        blinds.raiseUp = MagicMock(return_value=0)
        blinds.stop = MagicMock(return_value=0)

        c.addDevice(blinds)

        cp["Blinds"].lower(1)
        blinds.lower.assert_called_once_with(1)

        cp["Blinds"].raiseUp(256)
        blinds.raiseUp.assert_called_once_with(256)

        cp["Blinds"].stop(1138)
        blinds.stop.assert_called_once_with(1138)
        c.daemon.shutdown()
Example #2
0
    def testSendControlSignalsToBlinds(self):
        c = Controller()
        cp = ControllerProxy(c)

        self.PyroThread(c.daemon).start()

        blinds = UpDownStopArray("Blinds", c)
        blinds.lower = MagicMock(return_value=0)
        blinds.raiseUp = MagicMock(return_value=0)
        blinds.stop = MagicMock(return_value=0)

        c.addDevice(blinds)

        cp["Blinds"].lower(1)
        blinds.lower.assert_called_once_with(1)

        cp["Blinds"].raiseUp(256)
        blinds.raiseUp.assert_called_once_with(256)

        cp["Blinds"].stop(1138)
        blinds.stop.assert_called_once_with(1138)
        c.daemon.shutdown()
Example #3
0
    def testUpDownStopArray(self, mock_logging):
        udsr1 = MagicMock()
        udsr1.deviceID = "udsr1"
        udsr2 = MagicMock()
        udsr2.deviceID = "udsr2"

        c = Controller()
        c.addDevice(udsr1)
        c.addDevice(udsr2)

        udsa = UpDownStopArray("Test", c, {1: 'udsr1'})

        udsa.add(udsr2, 2)
        self.assertEqual(2, len(udsa.relays.items()))

        udsa.raiseUp(1)
        udsr1.raiseUp.assert_called_once_with()
        self.assertEqual(0, udsr2.raiseUp.call_count)

        udsa.lower(0)
        udsr1.lower.assert_called_once_with()
        udsr2.lower.assert_called_once_with()

        udsa.stop(2)
        udsr2.stop.assert_called_once_with()

        udsa.raiseUp(3)
        mock_logging.error.assert_called_once_with("Tried to raise relay channel 3 but no such device attached to Test")
        mock_logging.reset_mock()
        udsa.lower(-123)
        mock_logging.error.assert_called_once_with("Tried to lower relay channel -123 but no such device attached to Test")
        mock_logging.reset_mock()
        udsa.stop(42)
        mock_logging.error.assert_called_once_with("Tried to stop relay channel 42 but no such device attached to Test")