def test_setup( self, serial, cfg ): port = 'COM2' baud = 9600 value = 0xaa bb = BeagleboneXbeeCommunications() bb.write_uart_configuration_setup = Mock() bb.config = {Constants.XbeeConfiguration.xbee_beaglebone_port: port, Constants.XbeeConfiguration.xbee_beaglebone_baudrate: baud, Constants.XbeeConfiguration.xbee_beaglebone_mux_mode: 'mux_mode', Constants.XbeeConfiguration.xbee_beaglebone_receive_enable: '0', Constants.XbeeConfiguration.xbee_beaglebone_rx_mux: 'rx_mode', Constants.XbeeConfiguration.xbee_beaglebone_timeout: '10', Constants.XbeeConfiguration.xbee_beaglebone_transmit_enable: '1', Constants.XbeeConfiguration.xbee_beaglebone_tx_mux: 'tx_mux' } serial.return_value = value return_value = bb.setup() bb.write_uart_configuration_setup.assert_any_call( 'tx_mux', 1 ) self.assertEqual( bb.write_uart_configuration_setup.call_count, 2 ) serial.assert_called_once_with( port, baud, timeout=10 ) self.assertEqual( value, return_value )
def test_setup(self, serial, cfg): port = 'COM2' baud = 9600 value = 0xaa bb = BeagleboneXbeeCommunications() bb.write_uart_configuration_setup = Mock() bb.config = { Constants.XbeeConfiguration.xbee_beaglebone_port: port, Constants.XbeeConfiguration.xbee_beaglebone_baudrate: baud, Constants.XbeeConfiguration.xbee_beaglebone_mux_mode: 'mux_mode', Constants.XbeeConfiguration.xbee_beaglebone_receive_enable: '0', Constants.XbeeConfiguration.xbee_beaglebone_rx_mux: 'rx_mode', Constants.XbeeConfiguration.xbee_beaglebone_timeout: '10', Constants.XbeeConfiguration.xbee_beaglebone_transmit_enable: '1', Constants.XbeeConfiguration.xbee_beaglebone_tx_mux: 'tx_mux' } serial.return_value = value return_value = bb.setup() bb.write_uart_configuration_setup.assert_any_call('tx_mux', 1) self.assertEqual(bb.write_uart_configuration_setup.call_count, 2) serial.assert_called_once_with(port, baud, timeout=10) self.assertEqual(value, return_value)
def test_close( self, close, cfg ): bb = BeagleboneXbeeCommunications() bb.close() close.assert_called_once_with()
def test_configuration_file_name(self, cfg): bb = BeagleboneXbeeCommunications() self.assertEqual( bb.configuration_file_name, 'housemonitor.inputs.zigbeeinput.beaglebonexbeecommunications')
def test_close(self, close, cfg): bb = BeagleboneXbeeCommunications() bb.close() close.assert_called_once_with()