def update_room_capability(): params = request.get_json() room_id = params.get('roomId') room = Room.get_room(room_id) if room_id else None if not room or 'capability' not in params: raise BadRequestError('Missing required parameters') capability = params.get('capability') room = Room.update_capability(room_id, capability) return tolerant_jsonify(room.to_api_json())
def auditorium(): params = request.get_json() room_id = params.get('roomId') room = Room.get_room(room_id) if room_id else None if room: is_auditorium = params.get('isAuditorium') if not room_id or is_auditorium is None: raise BadRequestError("'roomId' and 'isAuditorium' are required.") room = Room.set_auditorium(room_id, is_auditorium) return tolerant_jsonify(room.to_api_json()) else: raise ResourceNotFoundError('No such room')
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_admin_approval(self): """Course is scheduled for recording if an admin user has approved.""" with test_approvals_workflow(app): section_id = 50005 term_id = app.config['CURRENT_TERM_ID'] course = SisSection.get_course(section_id=section_id, term_id=term_id) instructors = course['instructors'] assert len(instructors) == 2 # Verify that course is not scheduled assert Scheduled.get_scheduled(section_id=section_id, term_id=term_id) is None Approval.create( approved_by_uid=admin_uid, approver_type_='admin', course_display_name=course['label'], publish_type_='kaltura_my_media', recording_type_='presentation_audio', room_id=Room.find_room('Barker 101').id, section_id=section_id, term_id=term_id, ) KalturaJob(simply_yield).run() std_commit(allow_test_environment=True) # Admin approval is all we need. assert Scheduled.get_scheduled(section_id=section_id, term_id=term_id)
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 app_config(): term_id = app.config['CURRENT_TERM_ID'] return tolerant_jsonify({ 'canvasBaseUrl': app.config['CANVAS_BASE_URL'], 'courseCaptureExplainedUrl': app.config['COURSE_CAPTURE_EXPLAINED_URL'], 'courseCapturePoliciesUrl': app.config['COURSE_CAPTURE_POLICIES_URL'], 'currentTermId': term_id, 'currentTermName': term_name_for_sis_id(term_id), 'devAuthEnabled': app.config['DEVELOPER_AUTH_ENABLED'], 'diabloEnv': app.config['DIABLO_ENV'], 'ebEnvironment': app.config['EB_ENVIRONMENT'] if 'EB_ENVIRONMENT' in app.config else None, 'emailTemplateTypes': EmailTemplate.get_template_type_options(), 'publishTypeOptions': NAMES_PER_PUBLISH_TYPE, 'roomCapabilityOptions': Room.get_room_capability_options(), 'searchFilterOptions': get_search_filter_options(), 'searchItemsPerPage': app.config['SEARCH_ITEMS_PER_PAGE'], 'supportEmailAddress': app.config['EMAIL_DIABLO_SUPPORT'], 'timezone': app.config['TIMEZONE'], })
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 test_admin_approval(self): """Course is scheduled for recording if an admin user has approved.""" with test_approvals_workflow(app): section_id = 22287 term_id = app.config['CURRENT_TERM_ID'] course = SisSection.get_course(section_id=section_id, term_id=term_id) instructors = course['instructors'] assert len(instructors) == 2 # Verify that course is not scheduled assert Scheduled.get_scheduled(section_id=section_id, term_id=term_id) is None Approval.create( approved_by_uid=admin_uid, approver_type_='admin', cross_listed_section_ids=[], publish_type_='canvas', recording_type_='presentation_audio', room_id=Room.find_room('Barker 101').id, section_id=section_id, term_id=term_id, ) KalturaJob(app.app_context).run() std_commit(allow_test_environment=True) # Admin approval is all we need. assert Scheduled.get_scheduled(section_id=section_id, term_id=term_id)
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 test_admin_alert_multiple_meeting_patterns(self): """Emails admin if course is scheduled with weird start/end dates.""" with test_approvals_workflow(app): with enabled_job(job_key=AdminEmailsJob.key()): term_id = app.config['CURRENT_TERM_ID'] section_id = 50014 room_id = Room.find_room('Barker 101').id # The course has two instructors. instructor_uid = get_instructor_uids(section_id=section_id, term_id=term_id)[0] approval = Approval.create( approved_by_uid=instructor_uid, approver_type_='instructor', publish_type_='kaltura_my_media', recording_type_='presenter_audio', room_id=room_id, section_id=section_id, term_id=term_id, ) # Uh oh! Only one of them has been scheduled. meeting = get_eligible_meeting(section_id=section_id, term_id=term_id) Scheduled.create( instructor_uids=[instructor_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_=approval.publish_type, recording_type_=approval.recording_type, room_id=room_id, section_id=section_id, term_id=term_id, ) courses = SisSection.get_courses_scheduled_nonstandard_dates( term_id=term_id) course = next( (c for c in courses if c['sectionId'] == section_id), None) assert course # Message queued but not sent. admin_uid = app.config['EMAIL_DIABLO_ADMIN_UID'] AdminEmailsJob(simply_yield).run() queued_messages = QueuedEmail.query.filter_by( section_id=section_id).all() assert len(queued_messages) == 1 for queued_message in queued_messages: assert '2020-08-26 to 2020-10-02' in queued_message.message # Message sent. QueuedEmailsJob(simply_yield).run() emails_sent = SentEmail.get_emails_sent_to(uid=admin_uid) assert len(emails_sent) == 1 assert emails_sent[ 0].template_type == 'admin_alert_multiple_meeting_patterns' assert emails_sent[0].section_id == section_id
def _scheduled_locations_per_section_id(all_scheduled): locations_per_section_id = {} rooms = Room.get_rooms([s.room_id for s in all_scheduled]) locations_per_room_id = dict((room.id, room.location) for room in rooms) for section_id, room_id in dict( (s.section_id, s.room_id) for s in all_scheduled).items(): locations_per_section_id[section_id] = locations_per_room_id[room_id] return locations_per_section_id
def _schedule(): mock_scheduled( override_room_id=Room.find_room('Barker 101').id, section_id=section_id, term_id=term_id, ) course = SisSection.get_course(section_id=section_id, term_id=term_id) assert course['scheduled']['hasObsoleteRoom'] is True
def test_authorized(self, client, admin_session): """Admin user has access.""" room_id = 1 room = Room.get_room(room_id) capability = 'screencast_and_video' if room.capability == 'screencast' else 'screencast' room = self._api_update_capability(client, room_id, capability) assert len(room) assert room['capability'] == capability
def test_authorized(self, client, admin_session): """Admin user has access.""" room_id = 1 room = Room.get_room(room_id) is_auditorium = not room.is_auditorium room = self._api_set_auditorium(client, room_id, is_auditorium) assert len(room) assert room['isAuditorium'] is is_auditorium
def test_alert_admin_of_instructor_change(self): """Emails admin when a scheduled course gets a new instructor.""" with test_approvals_workflow(app): with enabled_job(job_key=AdminEmailsJob.key()): term_id = app.config['CURRENT_TERM_ID'] section_id = 50005 room_id = Room.find_room('Barker 101').id # The course has two instructors. instructor_1_uid, instructor_2_uid = get_instructor_uids( section_id=section_id, term_id=term_id) approval = Approval.create( approved_by_uid=instructor_1_uid, approver_type_='instructor', course_display_name= f'term_id:{term_id} section_id:{section_id}', publish_type_='kaltura_my_media', recording_type_='presenter_audio', room_id=room_id, section_id=section_id, term_id=term_id, ) # Uh oh! Only one of them has been scheduled. meeting = 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=[instructor_1_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_=approval.publish_type, recording_type_=approval.recording_type, room_id=room_id, section_id=section_id, term_id=term_id, ) admin_uid = app.config['EMAIL_DIABLO_ADMIN_UID'] email_count = _get_email_count(admin_uid) # Message queued but not sent. AdminEmailsJob(simply_yield).run() assert _get_email_count(admin_uid) == email_count queued_messages = QueuedEmail.query.filter_by( template_type='admin_alert_instructor_change').all() assert len(queued_messages) == 1 for snippet in [ 'LAW 23', 'Old instructor(s) Regan MacNeil', 'New instructor(s) Regan MacNeil, Burke Dennings' ]: assert snippet in queued_messages[0].message # Message sent. QueuedEmailsJob(simply_yield).run() assert _get_email_count(admin_uid) == email_count + 1
def approve(): term_id = app.config['CURRENT_TERM_ID'] term_name = term_name_for_sis_id(term_id) params = request.get_json() publish_type = params.get('publishType') recording_type = params.get('recordingType') section_id = params.get('sectionId') course = SisSection.get_course(term_id, section_id) if section_id else None if not course or publish_type not in get_all_publish_types() or recording_type not in get_all_recording_types(): raise BadRequestError('One or more required params are missing or invalid') if not current_user.is_admin and current_user.uid not in [i['uid'] for i in course['instructors']]: raise ForbiddenRequestError('Sorry, request unauthorized') if Approval.get_approval(approved_by_uid=current_user.uid, section_id=section_id, term_id=term_id): raise ForbiddenRequestError(f'You have already approved recording of {course["courseName"]}, {term_name}') meetings = course.get('meetings', {}).get('eligible', []) if len(meetings) != 1: raise BadRequestError('Unique eligible meeting pattern not found for course') meeting = meetings[0] location = meeting and meeting.get('location') room = Room.find_room(location=location) if not room: raise BadRequestError(f'{location} is not eligible for Course Capture.') previous_approvals = Approval.get_approvals_per_section_ids(section_ids=[section_id], term_id=term_id) approval = Approval.create( approved_by_uid=current_user.uid, approver_type_='admin' if current_user.is_admin else 'instructor', course_display_name=course['label'], publish_type_=publish_type, recording_type_=recording_type, room_id=room.id, section_id=section_id, term_id=term_id, ) if previous_approvals: # Compare the current approval with preferences submitted in previous approval previous_approval = previous_approvals[-1] if (approval.publish_type, approval.recording_type) != (previous_approval.publish_type, previous_approval.recording_type): notify_instructors_of_changes(course, approval, previous_approvals) all_approvals = previous_approvals + [approval] if len(course['instructors']) > len(all_approvals): approval_uids = [a.approved_by_uid for a in all_approvals] pending_instructors = [i for i in course['instructors'] if i['uid'] not in approval_uids] last_approver = next((i for i in course['instructors'] if i['uid'] == approval.approved_by_uid), None) if last_approver: notify_instructor_waiting_for_approval(course, last_approver, pending_instructors) return tolerant_jsonify(_after_approval(course=SisSection.get_course(term_id, section_id)))
def _set_room_capability(): for room in Room.all_rooms(): if room.location in ['Barrows 106', 'Barker 101']: Room.update_capability(room.id, 'screencast') elif room.location in ['Li Ka Shing 145']: Room.set_auditorium(room.id, True) Room.update_capability(room.id, 'screencast_and_video') std_commit(allow_test_environment=True)
def test_room_change_no_longer_eligible(self, db_session): section_id = 50004 term_id = app.config['CURRENT_TERM_ID'] def _move_course(meeting_location): db.session.execute( text( 'UPDATE sis_sections SET meeting_location = :meeting_location WHERE term_id = :term_id AND section_id = :section_id' ), { 'meeting_location': meeting_location, 'section_id': section_id, 'term_id': term_id, }, ) with enabled_job(job_key=InstructorEmailsJob.key()): with test_approvals_workflow(app): course = SisSection.get_course(section_id=section_id, term_id=term_id) eligible_meetings = course.get('meetings', {}).get('eligible', []) assert len(eligible_meetings) == 1 original_room = eligible_meetings[0]['room'] assert original_room['location'] == 'Li Ka Shing 145' # Schedule _schedule(original_room['id'], section_id) _run_instructor_emails_job() _assert_email_count(0, section_id, 'room_change_no_longer_eligible') # Move course to some other eligible room. _move_course('Barker 101') _run_instructor_emails_job() _assert_email_count(0, section_id, 'room_change_no_longer_eligible') # Move course to an ineligible room. ineligible_room = 'Wheeler 150' _move_course(ineligible_room) _run_instructor_emails_job() _assert_email_count(1, section_id, 'room_change_no_longer_eligible') # Move course back to its original location _move_course(original_room['location']) # Finally, let's pretend the course is scheduled to a room that was previously eligible. Scheduled.delete(section_id=section_id, term_id=term_id) _schedule(Room.find_room(ineligible_room).id, section_id) _run_instructor_emails_job() # Expect email. _assert_email_count(2, section_id, 'room_change_no_longer_eligible') Scheduled.delete(section_id=section_id, term_id=term_id)
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 get_room(room_id): room = Room.get_room(room_id) if room: api_json = room.to_api_json() api_json['courses'] = SisSection.get_courses_per_location( term_id=app.config['CURRENT_TERM_ID'], location=room.location, ) return tolerant_jsonify(api_json) else: raise ResourceNotFoundError('No such room')
def test_recording_type_options(self, client, admin_session): """Available recording types determined by values of capability and is_auditorium.""" expected = { 'Barker 101': ['presenter_presentation_audio'], 'Barrows 106': ['presentation_audio'], 'Li Ka Shing 145': ALL_RECORDING_TYPES.keys(), } for location, expected_types in expected.items(): room = Room.find_room(location=location) api_json = self._api_room(client, room.id) actual_types = api_json['recordingTypeOptions'].keys() assert list(actual_types) == list(expected_types)
def test_get_room(self, client, admin_session): """Admin user has access to room data.""" location = 'Barrows 106' room = next((r for r in Room.all_rooms() if r.location == location), None) assert room api_json = self._api_room(client, room.id) assert api_json['id'] == room.id assert api_json['isAuditorium'] is False assert api_json['location'] == location assert api_json['kalturaResourceId'] == 890 assert len(api_json['recordingTypeOptions']) == 1
def refresh_rooms(): locations = SisSection.get_distinct_meeting_locations() existing_locations = Room.get_all_locations() new_locations = [ location for location in locations if location not in existing_locations ] if new_locations: app.logger.info(f'Creating {len(new_locations)} new rooms') for location in new_locations: Room.create(location=location) def _normalize(room_location): return re.sub(r'[\W_]+', '', room_location).lower() kaltura_resource_ids_per_room = {} all_rooms = Room.all_rooms() for resource in Kaltura().get_schedule_resources(): location = _normalize(resource['name']) if location: for room in all_rooms: if _normalize(room.location) == location: kaltura_resource_ids_per_room[room.id] = resource['id'] break if kaltura_resource_ids_per_room: Room.update_kaltura_resource_mappings(kaltura_resource_ids_per_room)
def to_api_json(self, rooms_by_id=None): room_feed = None if self.room_id: if rooms_by_id: room_feed = rooms_by_id.get(self.room_id, None).to_api_json() else: room_feed = Room.get_room(self.room_id).to_api_json() formatted_days = format_days(self.meeting_days) return { 'id': self.id, 'alerts': self.alerts or [], 'createdAt': to_isoformat(self.created_at), 'instructorUids': self.instructor_uids, 'kalturaScheduleId': self.kaltura_schedule_id, 'meetingDays': formatted_days, 'meetingDaysNames': get_names_of_days(formatted_days), 'meetingEndDate': datetime.strftime(self.meeting_end_date, '%Y-%m-%d'), 'meetingEndTime': self.meeting_end_time, 'meetingEndTimeFormatted': format_time(self.meeting_end_time), 'meetingStartDate': datetime.strftime(self.meeting_start_date, '%Y-%m-%d'), 'meetingStartTime': self.meeting_start_time, 'meetingStartTimeFormatted': format_time(self.meeting_start_time), 'publishType': self.publish_type, 'publishTypeName': NAMES_PER_PUBLISH_TYPE[self.publish_type], 'recordingType': self.recording_type, 'recordingTypeName': NAMES_PER_RECORDING_TYPE[self.recording_type], 'room': room_feed, 'sectionId': self.section_id, 'termId': self.term_id, }
def to_api_json(self): return { 'approvedBy': get_calnet_user_for_uid(app, self.approved_by_uid), 'wasApprovedByAdmin': self.approver_type == 'admin', 'createdAt': to_isoformat(self.created_at), 'crossListedSectionIds': self.cross_listed_section_ids, 'publishType': self.publish_type, 'publishTypeName': NAMES_PER_PUBLISH_TYPE[self.publish_type], 'recordingType': self.recording_type, 'recordingTypeName': NAMES_PER_RECORDING_TYPE[self.recording_type], 'room': Room.get_room(self.room_id).to_api_json() if self.room_id else None, 'sectionId': self.section_id, 'termId': self.term_id, }
def test_screencast_and_video_auditorium(self, client, admin_session): """All recording types are available for Auditorium with 'screencast_and_video' capability.""" location = 'Li Ka Shing 145' room = Room.find_room(location=location) assert room api_json = self._api_room(client, room.id) assert api_json['id'] == room.id assert api_json['capabilityName'] == 'Screencast + Video' assert api_json['isAuditorium'] is True assert api_json['kalturaResourceId'] == 678 assert api_json['location'] == location assert api_json['recordingTypeOptions'] == ALL_RECORDING_TYPES # Feed includes courses but room-per-course would be redundant assert len(api_json['courses']) > 0 assert 'room' not in api_json['courses'][0]
def test_recording_type_options(self, client, admin_session): """Available recording types determined by values of capability and is_auditorium.""" expected = { 'Barker 101': ['presenter_presentation_audio'], "O'Brien 212": ['presentation_audio'], 'Li Ka Shing 145': [ 'presenter_presentation_audio_with_operator', 'presenter_presentation_audio', ], } for location, expected_options in expected.items(): room = Room.find_room(location=location) api_json = self._api_room(client, room.id) assert list( api_json['recordingTypeOptions'].keys()) == expected_options
def test_get_auditorium(self, client, admin_session): """Admin user has access to auditorium metadata.""" location = 'Li Ka Shing 145' room = next((r for r in Room.all_rooms() if r.location == location), None) assert room api_json = self._api_room(client, room.id) assert api_json['id'] == room.id assert api_json['isAuditorium'] is True assert api_json['kalturaResourceId'] == 678 assert api_json['location'] == location assert len(api_json['recordingTypeOptions']) == 3 # Feed includes courses but room-per-course would be redundant assert len(api_json['courses']) > 0 assert 'room' not in api_json['courses'][0]