def merge_sis_profile_names(sis_student_api_feed, sis_profile): for name in sis_student_api_feed.get('names', []): code = name.get('type', {}).get('code') if code == 'PRF': sis_profile['preferredName'] = vacuum_whitespace(name.get('formattedName')) elif code == 'PRI': sis_profile['primaryName'] = vacuum_whitespace(name.get('formattedName')) if 'primaryName' in sis_profile and 'preferredName' in sis_profile: break
def test_vacuum_whitespace(self): """Cleans up leading, trailing, and repeated whitespace.""" assert util.vacuum_whitespace( ' Firstname Lastname ') == 'Firstname Lastname'