def test_add_students(self, asc_advisor, client): """Create group and add students.""" name = 'Cheap Tricks' group = api_curated_group_create(client, name=name, sids=['2345678901', '11667051']) assert group['name'] == name assert group['totalStudentCount'] == 2 # Add students updated_group = api_curated_group_add_students( client, group['id'], return_student_profiles=True, sids=['7890123456'], ) assert updated_group['totalStudentCount'] == 3 students = updated_group['students'] sids = [s['sid'] for s in students] assert sids == ['11667051', '2345678901', '7890123456'] # Add more and ask for FULL student profiles in payload updated_group = api_curated_group_add_students( client, group['id'], return_student_profiles=True, sids=['890127492', '8901234567'], ) assert updated_group['totalStudentCount'] == 5 students = updated_group['students'] students.sort(key=lambda s: s['sid']) student = students[0] assert student['sid'] == '11667051' assert student['canvasUserId'] == '9000100' for expected_key in ('academicStanding', 'cumulativeGPA', 'cumulativeGPA', 'cumulativeUnits', 'majors', 'termGpa'): assert expected_key in student, f'Failed to find {expected_key} in student'
def test_unauthorized(self, asc_curated_groups, admin_user_session, client): """403 if user does not own the group.""" assert api_curated_group_add_students(client, asc_curated_groups[0].id, expected_status_code=403, sids=['2345678901'])
def test_add_student(self, asc_advisor, client): """Create a group and add a student.""" group_name = 'Trams of Old London' group = api_curated_group_create(client, name=group_name) assert group['totalStudentCount'] == 0 sid = '2345678901' updated_group = api_curated_group_add_students(client, group['id'], sids=[sid]) assert updated_group['name'] == group_name assert updated_group['totalStudentCount'] == 1 assert updated_group['students'][0]['sid'] == sid
def test_remove_student(self, asc_advisor, client): """Remove student from a curated group.""" name = 'Furry Green Atom Bowl' sid = '2345678901' curated_group = api_curated_group_create(client, name=name) curated_group_id = curated_group['id'] curated_group = api_curated_group_add_students(client, curated_group_id, sids=[sid]) assert curated_group['name'] == name assert curated_group['totalStudentCount'] == 1 # Remove the SID curated_group = api_curated_group_remove_student(client, curated_group_id, sid) assert curated_group['name'] == name assert curated_group['totalStudentCount'] == 0
def test_add_inactive_to_group(self, asc_advisor, client): group = _api_curated_group_create( client=client, name='Listening to the Higsons', sids=[self.active_sid], ) assert group['totalStudentCount'] == 1 updated_group = api_curated_group_add_students( client, group['id'], return_student_profiles=True, sids=[self.inactive_sid], ) assert updated_group['totalStudentCount'] == 2 assert updated_group['students'][1]['sid'] == self.active_sid assert updated_group['students'][0]['sid'] == self.inactive_sid
def test_not_authenticated(self, asc_curated_groups, client): """Anonymous user is rejected.""" assert api_curated_group_add_students(client, asc_curated_groups[0].id, expected_status_code=401, sids=['2345678901'])