def test_sending_templated_message(self): self.hass.states.set("sensor.temperature", 10) notify.send_message(self.hass, "{{ states.sensor.temperature.state }}", "{{ states.sensor.temperature.name }}") self.hass.pool.block_till_done() last_event = self.events[-1] self.assertEqual(last_event.data[notify.ATTR_TITLE], "temperature") self.assertEqual(last_event.data[notify.ATTR_MESSAGE], "10")
def test_sending_templated_message(self): self.hass.states.set('sensor.temperature', 10) notify.send_message(self.hass, '{{ states.sensor.temperature.state }}', '{{ states.sensor.temperature.name }}') self.hass.pool.block_till_done() last_event = self.events[-1] self.assertEqual(last_event.data[notify.ATTR_TITLE], 'temperature') self.assertEqual(last_event.data[notify.ATTR_MESSAGE], '10')
def test_method_forwards_correct_data(self): """Test that all data from the service gets forwarded to service.""" notify.send_message(self.hass, 'my message', 'my title', {'hello': 'world'}) self.hass.block_till_done() self.assertTrue(len(self.events) == 1) data = self.events[0].data assert { 'message': 'my message', 'title': 'my title', 'data': {'hello': 'world'} } == data
def test_method_forwards_correct_data(self): """Test that all data from the service gets forwarded to service.""" self._setup_notify() notify.send_message(self.hass, 'my message', 'my title', {'hello': 'world'}) self.hass.block_till_done() self.assertTrue(len(self.events) == 1) data = self.events[0].data assert { 'message': 'my message', 'title': 'my title', 'data': {'hello': 'world'} } == data
def test_sending_none_message(self): """Test send with None as message.""" notify.send_message(self.hass, None) self.hass.pool.block_till_done() self.assertTrue(len(self.events) == 0)
def test_sending_none_message(self): """Test send with None as message.""" self._setup_notify() notify.send_message(self.hass, None) self.hass.block_till_done() self.assertTrue(len(self.events) == 0)