@patch('homeassistant.helpers.service._LOGGER.error')
def test_fail_silently_if_no_service(self, mock_log):
    'Test failing if service is missing.'
    service.call_from_config(self.hass, None)
    self.assertEqual(1, mock_log.call_count)
    service.call_from_config(self.hass, {})
    self.assertEqual(2, mock_log.call_count)
    service.call_from_config(self.hass, {'service': 'invalid'})
    self.assertEqual(3, mock_log.call_count)
Test failing if service is missing.
@patch('homeassistant.helpers.service._LOGGER.error')
def test_fail_silently_if_no_service(self, mock_log):
    
    service.call_from_config(self.hass, None)
    self.assertEqual(1, mock_log.call_count)
    service.call_from_config(self.hass, {})
    self.assertEqual(2, mock_log.call_count)
    service.call_from_config(self.hass, {'service': 'invalid'})
    self.assertEqual(3, mock_log.call_count)