'Test the event listener when some attributes should be tags.'

def test_event_listener_tags_attributes(self, mock_client):

    config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass', 'tags_attributes': ['friendly_fake']}}
    assert setup_component(self.hass, influxdb.DOMAIN, config)
    self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
    attrs = {'friendly_fake': 'tag_str', 'field_fake': 'field_str'}
    state = mock.MagicMock(state=1, domain='fake', entity_id='fake.something', object_id='something', attributes=attrs)
    event = mock.MagicMock(data={'new_state': state}, time_fired=12345)
    body = [{'measurement': 'fake.something', 'tags': {'domain': 'fake', 'entity_id': 'something', 'friendly_fake': 'tag_str'}, 'time': 12345, 'fields': {'value': 1, 'field_fake_str': 'field_str'}}]
    self.handler_method(event)
    self.assertEqual(mock_client.return_value.write_points.call_count, 1)
    self.assertEqual(mock_client.return_value.write_points.call_args, mock.call(body))
    mock_client.return_value.write_points.reset_mock()
