def test_ZigBeeOutput_throws_exception( self, zo, t ):
     queue = HMQueue()
     thread = ZigBeeOutputThread( queue , 1 )
     zo.side_effect = KeyError( 'boom' )
     thread.zigbeeConnect()
     self.assertFalse( thread.connected )
     self.assertFalse( thread.talking )
Esempio n. 2
0
 def test_run(self):
     queue = HMQueue()
     packet = 555
     thread = ZigBeeOutputThread(queue, 1)
     thread.connectAndProcessZigBeeCommands = MagicMock()
     thread.run()
     thread.connectAndProcessZigBeeCommands.assert_called_once_with()
 def test_run( self ):
     queue = HMQueue()
     packet = 555
     thread = ZigBeeOutputThread( queue, 1 )
     thread.connectAndProcessZigBeeCommands = MagicMock()
     thread.run()
     thread.connectAndProcessZigBeeCommands.assert_called_once_with()
Esempio n. 4
0
 def test_ZigBeeOutput_throws_exception(self, zo, t):
     queue = HMQueue()
     thread = ZigBeeOutputThread(queue, 1)
     zo.side_effect = KeyError('boom')
     thread.zigbeeConnect()
     self.assertFalse(thread.connected)
     self.assertFalse(thread.talking)
Esempio n. 5
0
class ZigBeeControl(Base):
    '''
    ZigBeeControl starts the ZigBee processing to send data to ZigBee at the following
    URL:

    https://cosm.com/

    '''
    queue = None
    ZigBeeOutputThread = None
    cosm = None
    in_test_mode = False

    def __init__(self):
        '''
        Constructor
        '''
        super(ZigBeeControl, self).__init__()

    @property
    def logger_name(self):
        """ Set the logger level. This needs to be added to house_monitoring_logging.conf"""
        return Constants.LogKeys.outputsZigBee

    def startZigBee(self, in_test_mode):
        '''
        Start the ZigBee processing.

        This consists of three parts:

        #. Start the ZigBeeQueue which used Queue, a thread safe queue for communcating
        between threads.

        #. Start the ZigBeeOutputThread which talks to the ZigBee server.  This is a slow process.

        #. Start the ZigBeeOutputProcessing object which takes massages sent to ZigBee on the
        main thread and sends them to the ZigBee thread.

        '''
        self.queue = HMQueue('ZigBeeInput')
        self.in_test_mode = in_test_mode
        self.zig = ZigBeeOutputStep(self.queue)

        self.ZigBeeOutputThread = ZigBeeOutputThread(self.queue,
                                                     self.in_test_mode)
        self.ZigBeeOutputThread.start()
Esempio n. 6
0
class ZigBeeControl( Base ):
    '''
    ZigBeeControl starts the ZigBee processing to send data to ZigBee at the following
    URL:

    https://cosm.com/

    '''
    queue = None
    ZigBeeOutputThread = None
    cosm = None
    in_test_mode = False

    def __init__( self ):
        '''
        Constructor
        '''
        super( ZigBeeControl, self ).__init__()

    @property
    def logger_name( self ):
        """ Set the logger level. This needs to be added to house_monitoring_logging.conf"""
        return Constants.LogKeys.outputsZigBee

    def startZigBee( self, in_test_mode ):
        '''
        Start the ZigBee processing.

        This consists of three parts:

        #. Start the ZigBeeQueue which used Queue, a thread safe queue for communcating
        between threads.

        #. Start the ZigBeeOutputThread which talks to the ZigBee server.  This is a slow process.

        #. Start the ZigBeeOutputProcessing object which takes massages sent to ZigBee on the
        main thread and sends them to the ZigBee thread.

        '''
        self.queue = HMQueue( 'ZigBeeInput' )
        self.in_test_mode = in_test_mode
        self.zig = ZigBeeOutputStep( self.queue )

        self.ZigBeeOutputThread = ZigBeeOutputThread( self.queue, self.in_test_mode )
        self.ZigBeeOutputThread.start()
Esempio n. 7
0
 def test_processCommandToZigBee_with_IOError_in_SendCommand(self):
     queue = HMQueue()
     packet = 555
     thread = ZigBeeOutputThread(queue, 1)
     thread.output_queue = MagicMock()
     thread.output_queue.receive = MagicMock()
     thread.connected = True
     thread.talking = True
     thread.done = False
     thread.zigbee_output = MagicMock()
     thread.zigbee_output.sendCommand = MagicMock(side_effect=IOError())
     thread.processCommandToZigBee()
     self.assertFalse(thread.connected)
     self.assertFalse(thread.talking)
     self.assertFalse(thread.done)
Esempio n. 8
0
 def test_processCconnectAndProcessZigBeeCommands(self):
     queue = HMQueue()
     packet = 555
     thread = ZigBeeOutputThread(queue, 1)
     thread.connected = False
     thread.talking = True
     thread.done = False
     thread.zigbeeConnect = MagicMock(return_value=True)
     thread.processCommandToZigBee = MagicMock(
         side_effect=KeyboardInterrupt)
     thread.connectAndProcessZigBeeCommands()
     thread.zigbeeConnect.assert_called_once_with()
     thread.zigbeeConnect.assert_called_once_with()
     self.assertTrue(thread.connected)
     self.assertTrue(thread.talking)
     self.assertFalse(thread.done)
Esempio n. 9
0
    def startZigBee(self, in_test_mode):
        '''
        Start the ZigBee processing.

        This consists of three parts:

        #. Start the ZigBeeQueue which used Queue, a thread safe queue for communcating
        between threads.

        #. Start the ZigBeeOutputThread which talks to the ZigBee server.  This is a slow process.

        #. Start the ZigBeeOutputProcessing object which takes massages sent to ZigBee on the
        main thread and sends them to the ZigBee thread.

        '''
        self.queue = HMQueue('ZigBeeInput')
        self.in_test_mode = in_test_mode
        self.zig = ZigBeeOutputStep(self.queue)

        self.ZigBeeOutputThread = ZigBeeOutputThread(self.queue,
                                                     self.in_test_mode)
        self.ZigBeeOutputThread.start()
 def test_processCconnectAndProcessZigBeeCommands( self ):
     queue = HMQueue()
     packet = 555
     thread = ZigBeeOutputThread( queue, 1 )
     thread.connected = False
     thread.talking = True
     thread.done = False
     thread.zigbeeConnect = MagicMock( return_value=True )
     thread.processCommandToZigBee = MagicMock( side_effect=KeyboardInterrupt )
     thread.connectAndProcessZigBeeCommands()
     thread.zigbeeConnect.assert_called_once_with()
     thread.zigbeeConnect.assert_called_once_with()
     self.assertTrue( thread.connected )
     self.assertTrue( thread.talking )
     self.assertFalse( thread.done )
 def test_processCommandToZigBee_with_IOError_in_SendCommand( self ):
     queue = HMQueue()
     packet = 555
     thread = ZigBeeOutputThread( queue, 1 )
     thread.output_queue = MagicMock()
     thread.output_queue.receive = MagicMock()
     thread.connected = True
     thread.talking = True
     thread.done = False
     thread.zigbee_output = MagicMock()
     thread.zigbee_output.sendCommand = MagicMock( side_effect=IOError() )
     thread.processCommandToZigBee()
     self.assertFalse( thread.connected )
     self.assertFalse( thread.talking )
     self.assertFalse( thread.done )
Esempio n. 12
0
 def test_processCommandToZigBee(self, qr):
     packet = {}
     queue = HMQueue()
     value = 555
     data = {}
     packet['value'] = value
     packet['data'] = data
     packet['id'] = 0xab
     thread = ZigBeeOutputThread(queue, 1)
     qr.return_value = packet
     thread.zigbee_output = MagicMock()
     thread.zigbee_output.sendCommand = MagicMock()
     thread.connected = True
     thread.talking = True
     thread.done = False
     thread.processCommandToZigBee()
     thread.zigbee_output.sendCommand.assert_called_once_with(**packet)
     self.assertTrue(thread.connected)
     self.assertTrue(thread.talking)
     thread.done = False
 def test_processCommandToZigBee( self, qr ):
     packet = {}
     queue = HMQueue()
     value = 555
     data = {}
     packet['value'] = value
     packet['data'] = data
     packet['id'] = 0xab
     thread = ZigBeeOutputThread( queue, 1 )
     qr.return_value = packet
     thread.zigbee_output = MagicMock()
     thread.zigbee_output.sendCommand = MagicMock()
     thread.connected = True
     thread.talking = True
     thread.done = False
     thread.processCommandToZigBee()
     thread.zigbee_output.sendCommand.assert_called_once_with( **packet )
     self.assertTrue( thread.connected )
     self.assertTrue( thread.talking )
     thread.done = False
Esempio n. 14
0
    def startZigBee( self, in_test_mode ):
        '''
        Start the ZigBee processing.

        This consists of three parts:

        #. Start the ZigBeeQueue which used Queue, a thread safe queue for communcating
        between threads.

        #. Start the ZigBeeOutputThread which talks to the ZigBee server.  This is a slow process.

        #. Start the ZigBeeOutputProcessing object which takes massages sent to ZigBee on the
        main thread and sends them to the ZigBee thread.

        '''
        self.queue = HMQueue( 'ZigBeeInput' )
        self.in_test_mode = in_test_mode
        self.zig = ZigBeeOutputStep( self.queue )

        self.ZigBeeOutputThread = ZigBeeOutputThread( self.queue, self.in_test_mode )
        self.ZigBeeOutputThread.start()
Esempio n. 15
0
 def test_logger_name(self):
     queue = HMQueue()
     thread = ZigBeeOutputThread(queue, 1)
     self.assertEqual(thread.logger_name, Constants.LogKeys.outputsZigBee)