'Mock out the parts of the event collector which write to the queue.
Also mocks `domain` and `to_epoch_milliseconds` as it makes writing
tests easier since we pass in mock data to the events as well.'

def mock_eventcollector(self):

    p = patch.object(eventcollector.json, 'dumps', (lambda x: x))
    p.start()
    self.addCleanup(p.stop)
    amqp = MockAmqp(self)
    self.amqp = self.autopatch(g.events, 'queue', amqp)
    self.domain_mock = self.autopatch(eventcollector, 'domain')
    self.created_ts_mock = MagicMock(name='created_ts')
    self.to_epoch_milliseconds = self.autopatch(eventcollector, 'to_epoch_milliseconds', return_value=self.created_ts_mock)
