'Test the event listener when an attribute has an invalid type.'

def test_event_listener_invalid_type(self, mock_client):

    self._setup()
    valid = {'1': 1, '1.0': 1.0, STATE_ON: 1, STATE_OFF: 0, 'foo': 'foo'}
    for (in_, out) in valid.items():
        attrs = {'unit_of_measurement': 'foobars', 'longitude': '1.1', 'latitude': '2.2', 'invalid_attribute': ['value1', 'value2']}
        state = mock.MagicMock(state=in_, domain='fake', entity_id='fake.entity-id', object_id='entity', attributes=attrs)
        event = mock.MagicMock(data={'new_state': state}, time_fired=12345)
        if isinstance(out, str):
            body = [{'measurement': 'foobars', 'tags': {'domain': 'fake', 'entity_id': 'entity'}, 'time': 12345, 'fields': {'state': out, 'longitude': 1.1, 'latitude': 2.2, 'invalid_attribute_str': "['value1',    'value2']"}}]
        else:
            body = [{'measurement': 'foobars', 'tags': {'domain': 'fake', 'entity_id': 'entity'}, 'time': 12345, 'fields': {'value': float(out), 'longitude': 1.1, 'latitude': 2.2, 'invalid_attribute_str': "['value1',    'value2']"}}]
        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()
