def test_sending_none_message(self): """Test send with None as message.""" self._setup_notify() with pytest.raises(vol.Invalid): common.send_message(self.hass, None) self.hass.block_till_done() assert len(self.events) == 0
def test_sending_templated_message(self): """Send a templated message.""" self._setup_notify() self.hass.states.set('sensor.temperature', 10) common.send_message(self.hass, '{{ states.sensor.temperature.state }}', '{{ states.sensor.temperature.name }}') self.hass.block_till_done() last_event = self.events[-1] assert last_event.data[notify.ATTR_TITLE] == 'temperature' assert last_event.data[notify.ATTR_MESSAGE] == '10'
def test_sending_templated_message(self): """Send a templated message.""" self._setup_notify() self.hass.states.set('sensor.temperature', 10) common.send_message(self.hass, '{{ states.sensor.temperature.state }}', '{{ states.sensor.temperature.name }}') self.hass.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.""" self._setup_notify() common.send_message(self.hass, "my message", "my title", {"hello": "world"}) self.hass.block_till_done() assert 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() common.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_templated_message(self): """Send a templated message.""" self._setup_notify() self.opp.states.set("sensor.temperature", 10) common.send_message( self.opp, "{{ states.sensor.temperature.state }}", "{{ states.sensor.temperature.name }}", ) self.opp.block_till_done() last_event = self.events[-1] assert last_event.data[notify.ATTR_TITLE] == "temperature" assert 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.""" self._setup_notify() common.send_message(self.hass, 'my message', 'my title', {'hello': 'world'}) self.hass.block_till_done() assert 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.""" self._setup_notify() common.send_message(self.hass, None) self.hass.block_till_done() self.assertTrue(len(self.events) == 0)