'Test the event listener for missing units.'

def test_event_listener_no_units(self, mock_client):

    self._setup()
    for unit in (None, ''):
        if unit:
            attrs = {'unit_of_measurement': unit}
        else:
            attrs = {}
        state = mock.MagicMock(state=1, domain='fake', entity_id='fake.entity-id', object_id='entity', attributes=attrs)
        event = mock.MagicMock(data={'new_state': state}, time_fired=12345)
        body = [{'measurement': 'fake.entity-id', 'tags': {'domain': 'fake', 'entity_id': 'entity'}, 'time': 12345, 'fields': {'value': 1}}]
        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()
