Beispiel #1
0
    def test_authorized_unschedule_scheduled(self, client, admin_session):
        with test_approvals_workflow(app):
            api_approve(
                client,
                publish_type='kaltura_my_media',
                recording_type='presentation_audio',
                section_id=section_1_id,
            )
            mock_scheduled(
                section_id=section_1_id,
                term_id=self.term_id,
            )

            course = api_get_course(client, term_id=self.term_id, section_id=section_1_id)
            assert len(course['approvals']) == 1
            assert course['scheduled'] is not None
            assert course['hasNecessaryApprovals'] is True
            assert course['hasOptedOut'] is False
            assert course['schedulingStatus'] == 'Scheduled'

            response = self._api_unschedule(
                client,
                term_id=self.term_id,
                section_id=section_1_id,
            )
            assert len(response['approvals']) == 0
            assert response['scheduled'] is None
            assert response['hasNecessaryApprovals'] is False
            assert response['hasOptedOut'] is True
            assert response['schedulingStatus'] == 'Not Scheduled'
Beispiel #2
0
 def _assert_schedule_is_obsolete(
         self,
         expect_obsolete_dates,
         expect_obsolete_times,
         meeting,
         override_days=None,
         override_end_date=None,
         override_end_time=None,
         override_start_date=None,
         override_start_time=None,
 ):
     with test_approvals_workflow(app):
         with override_config(app, 'CURRENT_TERM_RECORDINGS_BEGIN', meeting['startDate']):
             with override_config(app, 'CURRENT_TERM_RECORDINGS_END', meeting['endDate']):
                 mock_scheduled(
                     meeting=meeting,
                     override_days=override_days,
                     override_end_date=override_end_date,
                     override_end_time=override_end_time,
                     override_start_date=override_start_date,
                     override_start_time=override_start_time,
                     section_id=self.section_id,
                     term_id=self.term_id,
                 )
                 course = SisSection.get_course(section_id=self.section_id, term_id=self.term_id)
                 scheduled = course['scheduled']
                 assert are_scheduled_dates_obsolete(meeting=meeting, scheduled=scheduled) is expect_obsolete_dates
                 assert are_scheduled_times_obsolete(meeting=meeting, scheduled=scheduled) is expect_obsolete_times
Beispiel #3
0
    def test_scheduled_filter(self, client, admin_session):
        """Scheduled filter: Courses with recordings scheduled."""
        with test_approvals_workflow(app):
            # Send invites
            for section_id in [section_1_id, section_6_id]:
                self._send_invitation_email(section_id)
                self._create_approval(section_id)

            # Feed will only include courses that were scheduled.
            mock_scheduled(
                section_id=section_1_id,
                term_id=self.term_id,
            )
            # Deleted records will be ignored
            mock_scheduled(
                section_id=section_2_id,
                term_id=self.term_id,
            )
            Scheduled.delete(section_id=section_2_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
            course = _find_course(api_json=api_json, section_id=section_1_id)
            assert course['approvalStatus'] == 'Partially Approved'
            assert course['schedulingStatus'] == 'Scheduled'
            assert not _find_course(api_json=api_json, section_id=section_6_id)
def _schedule(room_id, section_id):
    term_id = app.config['CURRENT_TERM_ID']
    mock_scheduled(
        override_room_id=room_id,
        section_id=section_id,
        term_id=term_id,
    )
Beispiel #5
0
 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
Beispiel #6
0
 def _schedule():
     mock_scheduled(
         meeting=meeting,
         override_end_time='16:59',
         override_start_time='08:00',
         section_id=section_id,
         term_id=term_id,
     )
     course = SisSection.get_course(
         section_id=section_id, term_id=term_id)
     scheduled = course['scheduled']
     assert are_scheduled_dates_obsolete(
         meeting=meeting, scheduled=scheduled) is False
     assert are_scheduled_times_obsolete(
         meeting=meeting, scheduled=scheduled) is True
Beispiel #7
0
 def test_all_filter(self, client, admin_session):
     """The 'all' filter returns all courses in eligible rooms."""
     with test_approvals_workflow(app):
         # Put courses in a few different states.
         for section_id in [section_1_id, section_6_id]:
             self._send_invitation_email(section_id)
             self._create_approval(section_id)
         mock_scheduled(
             section_id=section_1_id,
             term_id=self.term_id,
         )
         std_commit(allow_test_environment=True)
         # We gotta catch 'em all.
         api_json = self._api_courses(client, term_id=self.term_id, filter_='All')
         assert len(api_json) == 11
         for section_id in [section_1_id, section_3_id, section_4_id, section_5_id, section_6_id]:
             assert _find_course(api_json=api_json, section_id=section_id)
         assert not _find_course(api_json=api_json, section_id=section_in_ineligible_room)
Beispiel #8
0
    def test_has_obsolete_room(self, client, admin_session):
        """Admins can see room changes that might disrupt scheduled recordings."""
        course = SisSection.get_course(term_id=self.term_id, section_id=section_2_id)
        actual_room_id = course['meetings']['ineligible'][0]['room']['id']
        obsolete_room = Room.find_room('Barker 101')

        assert obsolete_room
        assert actual_room_id != obsolete_room.id

        mock_scheduled(
            section_id=section_2_id,
            term_id=self.term_id,
            override_room_id=obsolete_room.id,
        )
        api_json = self._api_course_changes(client, term_id=self.term_id)
        course = _find_course(api_json=api_json, section_id=section_2_id)
        assert course
        assert course['scheduled']['hasObsoleteRoom'] is True
        assert course['scheduled']['hasObsoleteDates'] is False
        assert course['scheduled']['hasObsoleteTimes'] is False
        assert course['scheduled']['hasObsoleteInstructors'] is False
Beispiel #9
0
    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_are_scheduled_dates_obsolete_handles_nulls(self):
        with test_approvals_workflow(app):
            meeting = _create_meeting(
                days='MO',
                end_date=_format(datetime.now() + timedelta(days=100)),
                end_time='10:59',
                start_date=_format(datetime.now() - timedelta(days=100)),
                start_time='10:00',
            )
            with override_config(app, 'CURRENT_TERM_RECORDINGS_BEGIN', meeting['startDate']):
                with override_config(app, 'CURRENT_TERM_RECORDINGS_END', meeting['endDate']):
                    mock_scheduled(meeting=meeting, section_id=self.section_id, term_id=self.term_id)
                    course = SisSection.get_course(section_id=self.section_id, term_id=self.term_id)
                    scheduled = course['scheduled']

                    meeting = _create_meeting(
                        days=None,
                        end_date=None,
                        end_time=None,
                        start_date=None,
                        start_time=None,
                    )
            assert are_scheduled_dates_obsolete(meeting, scheduled) is True
Beispiel #11
0
    def test_do_not_email_filter(self, client, 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
                    self._send_invitation_email(section_id)

            # If course has approvals but not scheduled then it will show up in the feed.
            self._create_approval(section_4_id)
            # Feed will exclude scheduled.
            mock_scheduled(
                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')

            # Opted-out courses are in the feed, whether approved or not
            course_1 = _find_course(api_json=api_json, section_id=section_1_id)
            assert course_1['approvalStatus'] == 'Invited'
            assert course_1['schedulingStatus'] == 'Not Scheduled'
            course_4 = _find_course(api_json=api_json, section_id=section_4_id)
            assert course_4['approvalStatus'] == 'Approved'
            assert course_4['schedulingStatus'] == 'Queued for Scheduling'

            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)