'Test the event listener against a whitelist.'

def test_event_listener_whitelist_domain(self, mock_client):

    config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass', 'include': {'domains': ['fake']}}}
    assert setup_component(self.hass, influxdb.DOMAIN, config)
    self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
    for domain in ('fake', 'another_fake'):
        state = mock.MagicMock(state=1, domain=domain, entity_id='{}.something'.format(domain), object_id='something', attributes={})
        event = mock.MagicMock(data={'new_state': state}, time_fired=12345)
        body = [{'measurement': '{}.something'.format(domain), 'tags': {'domain': domain, 'entity_id': 'something'}, 'time': 12345, 'fields': {'value': 1}}]
        self.handler_method(event)
        if (domain == 'fake'):
            self.assertEqual(mock_client.return_value.write_points.call_count, 1)
            self.assertEqual(mock_client.return_value.write_points.call_args, mock.call(body))
        else:
            self.assertFalse(mock_client.return_value.write_points.called)
        mock_client.return_value.write_points.reset_mock()
