'Populate a fake Segment event with data of interest'

def create_segmentio_event(self, **kwargs):

    action = kwargs.get('action', 'Track')
    sample_event = {'userId': kwargs.get('user_id', SEGMENTIO_TEST_USER_ID), 'event': 'Did    something', 'properties': {'name': kwargs.get('name', str(sentinel.name)), 'data': kwargs.get('data', {}), 'context': {'course_id': (kwargs.get('course_id') or ''), 'app_name': 'edx.mobile.android'}}, 'channel': 'server', 'context': {'library': {'name': kwargs.get('library_name', 'test-app'), 'version': 'unknown'}, 'app': {'version': '1.0.1'}, 'userAgent': str(sentinel.user_agent)}, 'receivedAt': '2014-08-27T16:33:39.100Z', 'timestamp': '2014-08-27T16:33:39.215Z', 'type': action.lower(), 'projectId': 'u0j33yjkr8', 'messageId': 'qy52hwp4', 'version': 2, 'integrations': {}, 'options': {'library': 'unknown', 'providers': {}}, 'action': action}
    if ('context' in kwargs):
        sample_event['properties']['context'].update(kwargs['context'])
    if ('label' in kwargs):
        sample_event['properties']['label'] = kwargs['label']
    if (kwargs.get('exclude_name') is True):
        del sample_event['properties']['name']
    return sample_event
