'Test if service call create log book entry.'

def test_service_call_create_logbook_entry(self):

    calls = []
    @ha.callback
    def event_listener(event):
        'Append    on    event.'
        calls.append(event)
    self.hass.bus.listen(logbook.EVENT_LOGBOOK_ENTRY, event_listener)
    self.hass.services.call(logbook.DOMAIN, 'log', {logbook.ATTR_NAME: 'Alarm', logbook.ATTR_MESSAGE: 'is    triggered', logbook.ATTR_DOMAIN: 'switch', logbook.ATTR_ENTITY_ID: 'switch.test_switch'}, True)
    self.hass.block_till_done()
    self.assertEqual(1, len(calls))
    last_call = calls[(-1)]
    self.assertEqual('Alarm', last_call.data.get(logbook.ATTR_NAME))
    self.assertEqual('is    triggered', last_call.data.get(logbook.ATTR_MESSAGE))
    self.assertEqual('switch', last_call.data.get(logbook.ATTR_DOMAIN))
    self.assertEqual('switch.test_switch', last_call.data.get(logbook.ATTR_ENTITY_ID))
