def test_get_ntp_servers(self): c = Cube((None, None)) c._socket = Mock(socket.socket) c._socket.recv = Mock(return_value=bytearray()) c.send_message = Mock() self.assertIsNone(c._ntp_servers) c.ntp_servers c.send_message.assert_called_with(FMessage()) c.handle_message(FResponse(bytearray("ntp.homematic.com,ntp.homematic.com", encoding='utf-8'))) self.assertEqual(c._ntp_servers, [u'ntp.homematic.com', u'ntp.homematic.com'])
def test_get_ntp_servers(self): c = Cube((None, None)) c._socket = Mock(socket.socket) c._socket.recv = Mock(return_value=bytearray()) c.send_message = Mock() self.assertIsNone(c._ntp_servers) c.ntp_servers c.send_message.assert_called_with(FMessage()) c.handle_message( FResponse( bytearray("ntp.homematic.com,ntp.homematic.com", encoding='utf-8'))) self.assertEqual(c._ntp_servers, [u'ntp.homematic.com', u'ntp.homematic.com'])
def test_handle_message(self): c = Cube(None, None) msg = HelloResponse(HelloResponseBytes) c.handle_message(msg) self.assertEqual(c.info, msg) msg = FResponse(b"ntp.homematic.com,ntp.homematic.com") c.handle_message(msg) self.assertEqual(c._ntp_servers, ['ntp.homematic.com', 'ntp.homematic.com']) msg = MResponse(MResponseBytes) c.handle_message(msg) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, device_type=2), ]) c = Cube(None, None) c._devices = DeviceList([ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=2, device_type=2), ]) msg = MResponse(MResponseBytes) c.handle_message(msg) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, device_type=2), ]) msg = ConfigurationResponse(ThermostatConfigurationBytes) c.handle_message(msg) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, configuration=msg, device_type=2), ]) c = Cube(None, None) c._devices = DeviceList([ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1), ]) lresp = LResponse("BhIrZfcSGWQ8AOsA") c.handle_message(lresp) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, settings=lresp.responses[0]), ]) msg = ConfigurationResponse(ThermostatConfigurationBytes) c.handle_message(msg) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, configuration=msg, settings=lresp.responses[0]), ]) # Test doesn't work, somehow the extended LResponse is wrong... lrespext = LResponse("CxIrZfcSGWQ8AOsF") c.handle_message(lrespext)
def test_handle_message(self): c = Cube(None, None) msg = HelloResponse(HelloResponseBytes) c.handle_message(msg) self.assertEqual(c.info, msg) msg = FResponse(b"ntp.homematic.com,ntp.homematic.com") c.handle_message(msg) self.assertEqual(c._ntp_servers, ['ntp.homematic.com', 'ntp.homematic.com']) msg = MResponse(MResponseBytes) c.handle_message(msg) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, device_type=2), ]) c = Cube(None, None) c._devices = DeviceList([ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=2, device_type=2), ]) msg = MResponse(MResponseBytes) c.handle_message(msg) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, device_type=2), ]) msg = ConfigurationResponse(ThermostatConfigurationBytes) c.handle_message(msg) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, configuration=msg, device_type=2), ]) c = Cube(None, None) c._devices = DeviceList([ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1), ]) lresp = LResponse("BhIrZfcSGWQ8AOsA") c.handle_message(lresp) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, settings=lresp), ]) msg = ConfigurationResponse(ThermostatConfigurationBytes) c.handle_message(msg) self.assertEqual(c.devices, [ Device(rf_address='122B65', serial='MEQ1472997', name='Heizung', room_id=1, configuration=msg, settings=lresp), ])