def test_has_obsolete_meeting_dates(self, client, admin_session): """Admins can see meeting date changes that might disrupt scheduled recordings.""" with test_approvals_workflow(app): meeting = get_eligible_meeting(section_id=section_1_id, term_id=self.term_id) obsolete_meeting_end_date = '2020-04-01' assert meeting['endDate'] != obsolete_meeting_end_date Scheduled.create( instructor_uids=get_instructor_uids(term_id=self.term_id, section_id=section_1_id), kaltura_schedule_id=random.randint(1, 10), meeting_days=meeting['days'], meeting_end_date=obsolete_meeting_end_date, meeting_end_time=meeting['endTime'], meeting_start_date=meeting['startDate'], meeting_start_time=meeting['startTime'], publish_type_='kaltura_my_media', recording_type_='presentation_audio', room_id=Room.get_room_id(section_id=section_1_id, term_id=self.term_id), section_id=section_1_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = self._api_course_changes(client, term_id=self.term_id) course = _find_course(api_json=api_json, section_id=section_1_id) assert course assert course['scheduled']['hasObsoleteRoom'] is False assert course['scheduled']['hasObsoleteDates'] is True assert course['scheduled']['hasObsoleteTimes'] is False assert course['scheduled']['hasObsoleteInstructors'] is False
def test_has_obsolete_instructors(self, client, admin_session): """Admins can see instructor changes that might disrupt scheduled recordings.""" with test_approvals_workflow(app): meeting = get_eligible_meeting(section_id=section_1_id, term_id=self.term_id) instructor_uids = get_instructor_uids(term_id=self.term_id, section_id=section_1_id) # Course has multiple instructors; we will schedule using only one instructor UID. assert len(instructor_uids) > 1 scheduled_with_uid = instructor_uids[0] Scheduled.create( instructor_uids=[scheduled_with_uid], kaltura_schedule_id=random.randint(1, 10), meeting_days=meeting['days'], meeting_end_date=get_recording_end_date(meeting), meeting_end_time=meeting['endTime'], meeting_start_date=get_recording_start_date(meeting, return_today_if_past_start=True), meeting_start_time=meeting['startTime'], publish_type_='kaltura_my_media', recording_type_='presenter_audio', room_id=Room.get_room_id(section_id=section_1_id, term_id=self.term_id), section_id=section_1_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = self._api_course_changes(client, term_id=self.term_id) course = _find_course(api_json=api_json, section_id=section_1_id) assert course assert course['scheduled']['hasObsoleteRoom'] is False assert course['scheduled']['hasObsoleteDates'] is False assert course['scheduled']['hasObsoleteTimes'] is False assert course['scheduled']['hasObsoleteInstructors'] is True assert len(course['instructors']) == 2 assert len(course['scheduled']['instructors']) == 1 assert course['scheduled']['instructors'][0]['uid'] == scheduled_with_uid
def mock_scheduled( section_id, term_id, meeting=None, override_days=None, override_end_date=None, override_end_time=None, override_room_id=None, override_start_date=None, override_start_time=None, publish_type='kaltura_media_gallery', recording_type='presenter_presentation_audio', ): meeting = meeting or get_eligible_meeting(section_id=section_id, term_id=term_id) Scheduled.create( course_display_name=f'term_id:{term_id} section_id:{section_id}', instructor_uids=get_instructor_uids(term_id=term_id, section_id=section_id), kaltura_schedule_id=random.randint(1, 10), meeting_days=override_days or meeting['days'], meeting_end_date=override_end_date or get_recording_end_date(meeting), meeting_end_time=override_end_time or meeting['endTime'], meeting_start_date=override_start_date or get_recording_start_date(meeting, return_today_if_past_start=True), meeting_start_time=override_start_time or meeting['startTime'], publish_type_=publish_type, recording_type_=recording_type, room_id=override_room_id or Room.get_room_id(section_id=section_id, term_id=term_id), section_id=section_id, term_id=term_id, ) std_commit(allow_test_environment=True)
def test_course_with_partial_approval(self, client, admin_session): """Course with two instructors and one approval.""" with test_approvals_workflow(app): # If course has approvals but not scheduled then it will show up in the feed. approved_by_uid = get_instructor_uids(section_id=section_1_id, term_id=self.term_id)[0] room_id = Room.get_room_id(section_id=section_1_id, term_id=self.term_id) Approval.create( approved_by_uid=approved_by_uid, approver_type_='instructor', publish_type_='kaltura_my_media', recording_type_='presentation_audio', room_id=room_id, section_id=section_1_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = api_get_course( client, term_id=self.term_id, section_id=section_1_id, ) assert [i['uid'] for i in api_json['instructors']] == ['10001', '10002'] approvals = api_json['approvals'] assert len(approvals) == 1 assert approved_by_uid == approvals[0]['approvedBy']['uid'] assert api_json['approvalStatus'] == 'Partially Approved' assert api_json['schedulingStatus'] == 'Not Scheduled' assert api_json['meetings']['eligible'][0]['room']['id'] == room_id assert api_json['meetings']['eligible'][0]['room']['location'] == 'Barrows 106'
def test_has_instructors(self, client, admin_session): """Admins can see instructor changes that might disrupt scheduled recordings.""" with test_approvals_workflow(app): meeting_days, meeting_start_time, meeting_end_time = SisSection.get_meeting_times( term_id=self.term_id, section_id=section_3_id, ) instructor_uids = SisSection.get_instructor_uids(term_id=self.term_id, section_id=section_3_id) Scheduled.create( cross_listed_section_ids=[], instructor_uids=instructor_uids + ['999999'], meeting_days=meeting_days, meeting_start_time=meeting_start_time, meeting_end_time=meeting_end_time, publish_type_='canvas', recording_type_='presenter_audio', room_id=Room.get_room_id(section_id=section_3_id, term_id=self.term_id), section_id=section_3_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = self._api_course_changes(client, term_id=self.term_id) course = _find_course(api_json=api_json, section_id=section_3_id) assert course assert course['scheduled']['hasObsoleteRoom'] is False assert course['scheduled']['hasObsoleteMeetingTimes'] is False assert course['scheduled']['hasObsoleteInstructors'] is True
def test_course_with_partial_approval(self, client, db, admin_session): """Course with two instructors and one approval.""" with test_approvals_workflow(app): # If course has approvals but not scheduled then it will show up in the feed. approved_by_uid = _get_instructor_uids(section_id=section_1_id, term_id=self.term_id)[0] room_id = Room.get_room_id(section_id=section_1_id, term_id=self.term_id) Approval.create( approved_by_uid=approved_by_uid, approver_type_='instructor', cross_listed_section_ids=[], publish_type_='canvas', recording_type_='presentation_audio', room_id=room_id, section_id=section_1_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = api_get_course( client, term_id=self.term_id, section_id=section_1_id, ) assert [i['uid'] for i in api_json['instructors']] == ['234567', '8765432'] approvals = api_json['approvals'] assert len(approvals) == 1 assert approved_by_uid == approvals[0]['approvedBy']['uid'] assert api_json['room']['id'] == room_id assert api_json['room']['location'] == 'Barrows 106'
def _create_approval(self, section_id): Approval.create( approved_by_uid=get_instructor_uids(section_id=section_id, term_id=self.term_id)[0], approver_type_='instructor', publish_type_='kaltura_my_media', recording_type_='presentation_audio', room_id=Room.get_room_id(section_id=section_id, term_id=self.term_id), section_id=section_id, term_id=self.term_id, )
def test_do_not_email_filter(self, client, db, admin_session): """Do Not Email filter: Courses in eligible room; "opt out" is true; all stages of approval; not scheduled.""" with test_approvals_workflow(app): # Send invites them opt_out. for section_id in (section_1_id, section_in_ineligible_room, section_3_id, section_4_id): CoursePreference.update_opt_out(section_id=section_id, term_id=self.term_id, opt_out=True) in_enabled_room = _is_course_in_enabled_room(section_id=section_id, term_id=self.term_id) if section_id == section_in_ineligible_room: # Courses in ineligible rooms will be excluded from the feed. assert not in_enabled_room else: assert in_enabled_room SentEmail.create( section_id=section_id, recipient_uids=_get_instructor_uids(section_id=section_id, term_id=self.term_id), template_type='invitation', term_id=self.term_id, ) # If course has approvals but not scheduled then it will show up in the feed. Approval.create( approved_by_uid=_get_instructor_uids(section_id=section_1_id, term_id=self.term_id)[0], approver_type_='instructor', cross_listed_section_ids=[], publish_type_='canvas', recording_type_='presentation_audio', room_id=Room.get_room_id(section_id=section_1_id, term_id=self.term_id), section_id=section_1_id, term_id=self.term_id, ) # Feed will exclude scheduled. _schedule_recordings( section_id=section_3_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = self._api_courses(client, term_id=self.term_id, filter_='Do Not Email') for section_id in (section_1_id, section_4_id): # The 'Do Not Email' course is in the feed assert _find_course(api_json=api_json, section_id=section_id) for section_id in (section_3_id, section_in_ineligible_room): # Excluded courses assert not _find_course(api_json=api_json, section_id=section_id)
def test_partially_approved_filter(self, client, db, admin_session): """Partially approved: Eligible, invited course with 1+ approvals, but not ALL instructors have approved.""" with test_approvals_workflow(app): # Assert multiple instructors section_1_instructor_uids = _get_instructor_uids(section_id=section_1_id, term_id=self.term_id) section_6_instructor_uids = _get_instructor_uids(section_id=section_6_id, term_id=self.term_id) assert len(section_1_instructor_uids) > 1 assert len(section_6_instructor_uids) > 1 # Send invites courses = [ {'section_id': section_1_id, 'instructor_uids': section_1_instructor_uids}, {'section_id': section_6_id, 'instructor_uids': section_6_instructor_uids}, ] for course in courses: SentEmail.create( section_id=course['section_id'], recipient_uids=course['instructor_uids'], template_type='invitation', term_id=self.term_id, ) Approval.create( approved_by_uid=course['instructor_uids'][0], approver_type_='instructor', cross_listed_section_ids=[], publish_type_='canvas', recording_type_='presentation_audio', room_id=Room.get_room_id(section_id=course['section_id'], term_id=self.term_id), section_id=course['section_id'], term_id=self.term_id, ) # Feed will include both scheduled and not scheduled. _schedule_recordings( section_id=section_1_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = self._api_courses(client, term_id=self.term_id, filter_='Partially Approved') assert len(api_json) == 2 assert _find_course(api_json=api_json, section_id=section_1_id) course = _find_course(api_json=api_json, section_id=section_6_id) assert course assert course['label'] == 'LAW 23, LEC 002'
def test_partially_approved_filter(self, client, admin_session): """Partially approved: Eligible, invited course with 1+ approvals, but not ALL instructors have approved.""" with test_approvals_workflow(app): for section_id in [section_1_id, section_6_id, section_7_id]: # Assert multiple instructors assert len(get_instructor_uids(section_id=section_id, term_id=self.term_id)) > 1 # Send invites self._send_invitation_email(section_id) if section_id == section_1_id: # If course is "approved" by admin only then it will NOT show up on the partially-approval list. Approval.create( approved_by_uid=admin_uid, approver_type_='admin', publish_type_='kaltura_my_media', recording_type_='presentation_audio', room_id=Room.get_room_id(section_id=section_id, term_id=self.term_id), section_id=section_id, term_id=self.term_id, ) else: # Approval by first instructor only self._create_approval(section_id) # Feed will include both scheduled and not scheduled. for section_id in [section_1_id, section_7_id]: mock_scheduled(section_id=section_id, term_id=self.term_id) # Unschedule one of them Approval.delete(section_id=section_7_id, term_id=self.term_id) Scheduled.delete(section_id=section_7_id, term_id=self.term_id) std_commit(allow_test_environment=True) api_json = self._api_courses(client, term_id=self.term_id, filter_='Partially Approved') assert len(api_json) == 1 course = _find_course(api_json=api_json, section_id=section_6_id) assert course assert course['label'] == 'LAW 23, LEC 002' assert course['approvalStatus'] == 'Partially Approved' assert course['schedulingStatus'] == 'Not Scheduled'
def test_scheduled_filter(self, client, db, admin_session): """Scheduled filter: Courses with recordings scheduled.""" with test_approvals_workflow(app): section_1_instructor_uids = _get_instructor_uids(section_id=section_1_id, term_id=self.term_id) section_6_instructor_uids = _get_instructor_uids(section_id=section_6_id, term_id=self.term_id) # Send invites courses = [ {'section_id': section_1_id, 'instructor_uids': section_1_instructor_uids}, {'section_id': section_6_id, 'instructor_uids': section_6_instructor_uids}, ] for course in courses: SentEmail.create( section_id=course['section_id'], recipient_uids=course['instructor_uids'], template_type='invitation', term_id=self.term_id, ) Approval.create( approved_by_uid=course['instructor_uids'][0], approver_type_='instructor', cross_listed_section_ids=[], publish_type_='canvas', recording_type_='presentation_audio', room_id=Room.get_room_id(section_id=course['section_id'], term_id=self.term_id), section_id=course['section_id'], term_id=self.term_id, ) # Feed will only include courses that were scheduled. _schedule_recordings( section_id=section_1_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = self._api_courses(client, term_id=self.term_id, filter_='Scheduled') assert len(api_json) == 1 assert _find_course(api_json=api_json, section_id=section_1_id) assert not _find_course(api_json=api_json, section_id=section_6_id)
def test_not_invited_filter(self, client, db, admin_session): """Not-invited filter: Courses in eligible rooms, never sent an invitation. No approval. Not scheduled.""" with test_approvals_workflow(app): # The first course gets an invitation section_1_instructor_uids = _get_instructor_uids(section_id=section_1_id, term_id=self.term_id) SentEmail.create( section_id=section_1_id, recipient_uids=section_1_instructor_uids, template_type='invitation', term_id=self.term_id, ) # The second course did not receive an invitation BUT it does have approval. invite = SentEmail.get_emails_of_type( section_id=section_4_id, template_type='invitation', term_id=self.term_id, ) assert not invite Approval.create( approved_by_uid=_get_instructor_uids(section_id=section_4_id, term_id=self.term_id)[0], approver_type_='instructor', cross_listed_section_ids=[], publish_type_='canvas', recording_type_='presentation_audio', room_id=Room.get_room_id(section_id=section_4_id, term_id=self.term_id), section_id=section_4_id, term_id=self.term_id, ) std_commit(allow_test_environment=True) api_json = self._api_courses(client, term_id=self.term_id, filter_='Not Invited') assert not _find_course(api_json=api_json, section_id=section_1_id) assert not _find_course(api_json=api_json, section_id=section_4_id) # Third course is in enabled room and has not received an invite. Therefore, it is in the feed. assert _is_course_in_enabled_room(section_id=section_3_id, term_id=self.term_id) course = _find_course(api_json=api_json, section_id=section_3_id) assert course assert course['label'] == 'BIO 1B, LEC 001'
def _schedule_recordings( section_id, term_id, publish_type='kaltura_media_gallery', recording_type='presenter_presentation_audio', room_id=None, ): meeting_days, meeting_start_time, meeting_end_time = SisSection.get_meeting_times( term_id=term_id, section_id=section_id, ) Scheduled.create( cross_listed_section_ids=[], instructor_uids=SisSection.get_instructor_uids(term_id=term_id, section_id=section_id), meeting_days=meeting_days, meeting_start_time=meeting_start_time, meeting_end_time=meeting_end_time, publish_type_=publish_type, recording_type_=recording_type, room_id=room_id or Room.get_room_id(section_id=section_id, term_id=term_id), section_id=section_id, term_id=term_id, ) std_commit(allow_test_environment=True)