'Assert that a single setting changed event is emitted for the user_api_userpreference table.'

@contextmanager
def verify_pref_change_event_during(self, username, user_id, setting, **kwargs):

    expected_event = {'username': username, 'event': {'setting': setting, 'user_id': int(user_id), 'table': 'user_api_userpreference', 'truncated': []}}
    expected_event['event'].update(kwargs)
    event_filter = {'event_type': self.USER_SETTINGS_CHANGED_EVENT_NAME, 'username': username}
    with self.assert_events_match_during(event_filter=event_filter, expected_events=[expected_event]):
        (yield)
