def test_course_staff(self): """Verify that the wrapper return staff list.""" staff = PersonFactory() staff.profile_image_url = None staff.save() # another staff with position by default staff has no position associated. staff_2 = PersonFactory() position = PositionFactory(person=staff_2) self.course_run.staff = [staff, staff_2] self.course_run.save() facebook = PersonSocialNetworkFactory(person=staff_2, type='facebook') twitter = PersonSocialNetworkFactory(person=staff_2, type='twitter') expected = [{ 'uuid': str(staff.uuid), 'full_name': staff.full_name, 'image_url': staff.get_profile_image_url, 'profile_url': staff.profile_url, 'social_networks': {}, 'bio': staff.bio, 'is_new': True, 'email': staff.email }, { 'uuid': str(staff_2.uuid), 'full_name': staff_2.full_name, 'image_url': staff_2.get_profile_image_url, 'position': position.title, 'organization': position.organization_name, 'profile_url': staff.profile_url, 'is_new': False, 'social_networks': { 'facebook': facebook.value, 'twitter': twitter.value }, 'bio': staff_2.bio, 'email': staff_2.email }] self.assertEqual(self.wrapped_course_run.course_staff, expected)
def test_course_staff(self): """Verify that the wrapper return staff list.""" staff = PersonFactory() staff.profile_image_url = None staff.save() # another staff with position by default staff has no position associated. staff_2 = PersonFactory() position = PositionFactory(person=staff_2) self.course_run.staff = [staff, staff_2] self.course_run.save() facebook = PersonSocialNetworkFactory(person=staff_2, type='facebook') twitter = PersonSocialNetworkFactory(person=staff_2, type='twitter', title='@MrTerry') area_1 = PersonAreaOfExpertiseFactory(person=staff) area_2 = PersonAreaOfExpertiseFactory(person=staff) area_3 = PersonAreaOfExpertiseFactory(person=staff_2) expected = [{ 'uuid': str(staff.uuid), 'full_name': staff.full_name, 'image_url': staff.get_profile_image_url, 'profile_url': staff.profile_url, 'social_networks': [], 'major_works': staff.major_works, 'bio': staff.bio, 'areas_of_expertise': [ { 'id': area_1.id, 'value': area_1.value }, { 'id': area_2.id, 'value': area_2.value }, ], }, { 'uuid': str(staff_2.uuid), 'full_name': staff_2.full_name, 'image_url': staff_2.get_profile_image_url, 'position': position.title, 'organization': position.organization_name, 'profile_url': staff_2.profile_url, 'social_networks': [ { 'id': facebook.id, 'type': facebook.type, 'url': facebook.url, 'title': facebook.title, }, { 'id': twitter.id, 'type': twitter.type, 'url': twitter.url, 'title': twitter.title, }, ], 'bio': staff_2.bio, 'major_works': staff_2.major_works, 'areas_of_expertise': [ { 'id': area_3.id, 'value': area_3.value }, ], }] self.assertEqual(self.wrapped_course_run.course_staff, expected)