'Verify that an event was published with the given parameters.
We can verify that specific event fields are set using the
optional search parameter.'

def assert_event_published(self, event_type, event_fields=None):

    if (not event_fields):
        event_fields = {}
    for event in self.events:
        if (event['event_type'] == event_type):
            found = True
            for field in event_fields:
                if (field not in event['event']):
                    found = False
                elif (event_fields[field] != event['event'][field]):
                    found = False
            if found:
                return
    self.assertIn({'event_type': event_type, 'event': event_fields}, self.events)
