'Test the running.'

def test_run(self):

    runs = []
    event = mock.MagicMock(event_type=EVENT_STATE_CHANGED, data={'entity_id': 'entity', 'new_state': mock.MagicMock()})
    def fake_get():
        if (len(runs) >= 2):
            return self.gf._quit_object
        elif runs:
            runs.append(1)
            return mock.MagicMock(event_type='somethingelse', data={'new_event': None})
        else:
            runs.append(1)
            return event
    with mock.patch.object(self.gf, '_queue') as mock_queue:
        with mock.patch.object(self.gf, '_report_attributes') as mock_r:
            mock_queue.get.side_effect = fake_get
            self.gf.run()
            self.assertEqual(3, mock_queue.task_done.call_count)
            self.assertEqual(mock_r.call_count, 1)
            self.assertEqual(mock_r.call_args, mock.call('entity', event.data['new_state']))
