Example #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'
Example #2
0
    def test_approval_by_instructors(self, app, client, fake_auth):
        """Instructor can submit approval if s/he is teaching the requested course."""
        with test_approvals_workflow(app):
            instructor_uids = get_instructor_uids(section_id=section_1_id, term_id=self.term_id)
            fake_auth.login(instructor_uids[0])
            api_approve(
                client,
                publish_type='kaltura_my_media',
                recording_type='presentation_audio',
                section_id=section_1_id,
            )
            std_commit(allow_test_environment=True)

            fake_auth.login(instructor_uids[1])
            api_approve(
                client,
                publish_type='kaltura_media_gallery',
                recording_type='presentation_audio',
                section_id=section_1_id,
            )
            std_commit(allow_test_environment=True)

            QueuedEmailsJob(app.app_context).run()

            # First instructor was notified 1) that second instructor needed to approve; 2) that second instructor made changes.
            emails_sent = SentEmail.get_emails_sent_to(instructor_uids[0])
            assert len(emails_sent) == 2
            for email in emails_sent:
                assert email.section_id == section_1_id
                assert email.term_id == self.term_id
            assert emails_sent[0].template_type == 'waiting_for_approval'
            assert emails_sent[1].template_type == 'notify_instructor_of_changes'

            # Second instructor received no notifications.
            assert len(SentEmail.get_emails_sent_to(instructor_uids[1])) == 0

            fake_auth.login(admin_uid)
            api_json = api_get_course(
                client,
                term_id=self.term_id,
                section_id=section_1_id,
            )
            assert api_json['meetings']['eligible'][0]['room']['location'] == 'Barrows 106'
            instructor_uids = [i['uid'] for i in api_json['instructors']]
            assert instructor_uids == instructor_uids
            approvals_ = api_json['approvals']
            assert len(approvals_) == 2

            assert approvals_[0]['approvedBy']['uid'] == instructor_uids[0]
            assert approvals_[0]['publishType'] == 'kaltura_my_media'

            assert approvals_[1]['approvedBy']['uid'] == instructor_uids[1]
            assert approvals_[1]['publishType'] == 'kaltura_media_gallery'
            assert approvals_[1]['recordingType'] == 'presentation_audio'
            assert approvals_[1]['recordingTypeName'] == 'Presentation and Audio'

            assert api_json['hasNecessaryApprovals'] is True
            assert api_json['scheduled'] is None
Example #3
0
 def test_invalid_publish_type(self, client, admin_session):
     """Reject invalid publish types."""
     api_approve(
         client,
         publish_type='youtube',
         recording_type='presentation_audio',
         section_id=section_1_id,
         expected_status_code=400,
     )
Example #4
0
 def test_not_authenticated(self, client):
     """Deny anonymous access."""
     api_approve(
         client,
         publish_type='kaltura_my_media',
         recording_type='presentation_audio',
         section_id=section_1_id,
         expected_status_code=401,
     )
Example #5
0
 def test_unauthorized(self, client, fake_auth):
     """Deny access if the instructor is not teaching the requested course."""
     fake_auth.login('10006')
     api_approve(
         client,
         publish_type='kaltura_my_media',
         recording_type='presentation_audio',
         section_id=section_2_id,
         expected_status_code=403,
     )
 def test_unauthorized(self, client, db, fake_auth):
     """Deny access if the instructor is not teaching the requested course."""
     instructor_uids = _get_instructor_uids(section_id=section_1_id, term_id=self.term_id)
     fake_auth.login(instructor_uids[0])
     api_approve(
         client,
         publish_type='canvas',
         recording_type='presentation_audio',
         section_id=section_2_id,
         expected_status_code=403,
     )
    def test_instructor_already_approved(self, client, db, fake_auth):
        """Instructor can submit his/her approval only once."""
        instructor_uids = _get_instructor_uids(section_id=section_1_id, term_id=self.term_id)
        fake_auth.login(instructor_uids[0])

        for expected_status_code in [200, 403]:
            api_approve(
                client,
                publish_type='canvas',
                recording_type='presentation_audio',
                section_id=section_1_id,
                expected_status_code=expected_status_code,
            )
    def test_approval_by_instructors(self, client, db, fake_auth):
        """Instructor can submit approval if s/he is teaching the requested course."""
        instructor_uids = _get_instructor_uids(section_id=section_1_id, term_id=self.term_id)
        fake_auth.login(instructor_uids[0])
        api_approve(
            client,
            publish_type='canvas',
            recording_type='presentation_audio',
            section_id=section_1_id,
        )
        std_commit(allow_test_environment=True)

        fake_auth.login(instructor_uids[1])
        api_approve(
            client,
            publish_type='kaltura_media_gallery',
            recording_type='presentation_audio',
            section_id=section_1_id,
        )
        std_commit(allow_test_environment=True)

        for uid in ('234567', '8765432'):
            emails_sent = SentEmail.get_emails_sent_to(uid)
            assert len(emails_sent) > 0
            most_recent = emails_sent[-1]
            assert most_recent.section_id == section_1_id
            assert most_recent.template_type == 'notify_instructor_of_changes'
            assert most_recent.term_id == self.term_id

        fake_auth.login(admin_uid)
        api_json = api_get_course(
            client,
            term_id=self.term_id,
            section_id=section_1_id,
        )
        assert api_json['room']['location'] == 'Barrows 106'
        instructor_uids = [i['uid'] for i in api_json['instructors']]
        assert instructor_uids == instructor_uids
        approvals_ = api_json['approvals']
        assert len(approvals_) == 2

        assert approvals_[0]['approvedBy']['uid'] == instructor_uids[0]
        assert approvals_[0]['publishType'] == 'canvas'

        assert approvals_[1]['approvedBy']['uid'] == instructor_uids[1]
        assert approvals_[1]['publishType'] == 'kaltura_media_gallery'
        assert approvals_[1]['recordingType'] == 'presentation_audio'
        assert approvals_[1]['recordingTypeName'] == 'Presentation and Audio'

        assert api_json['hasNecessaryApprovals'] is True
        assert api_json['scheduled'] is None
Example #9
0
    def test_instructor_already_approved(self, client, fake_auth):
        """Instructor can submit his/her approval only once."""
        with test_approvals_workflow(app):
            instructor_uids = get_instructor_uids(section_id=section_1_id, term_id=self.term_id)
            fake_auth.login(instructor_uids[0])

            for expected_status_code in [200, 403]:
                api_approve(
                    client,
                    publish_type='kaltura_my_media',
                    recording_type='presentation_audio',
                    section_id=section_1_id,
                    expected_status_code=expected_status_code,
                )
Example #10
0
 def _approve(instructor_uid, expected_has_necessary):
     fake_auth.login(instructor_uid)
     api_json = api_approve(
         client,
         publish_type='kaltura_my_media',
         recording_type='presentation_audio',
         section_id=50012,
     )
     std_commit(allow_test_environment=True)
     assert api_json['hasNecessaryApprovals'] is expected_has_necessary, f'instructor_uid: {instructor_uid}'
 def test_approval_by_admin(self, client, db, admin_session):
     """Admins can schedule recordings on behalf of any eligible course."""
     api_json = api_approve(
         client,
         publish_type='canvas',
         recording_type='presentation_audio',
         section_id=section_1_id,
     )
     std_commit(allow_test_environment=True)
     assert api_json['hasNecessaryApprovals'] is True
     assert api_json['scheduled'] is None
Example #12
0
    def test_scheduling_removes_opt_out(self, client, admin_session):
        with test_approvals_workflow(app):
            self._api_opt_out_update(
                client,
                term_id=self.term_id,
                section_id=section_1_id,
                opt_out=True,
            )
            api_json = api_get_course(client, section_id=section_1_id, term_id=self.term_id)
            assert api_json['schedulingStatus'] == 'Not Scheduled'
            assert api_json['hasOptedOut'] is True

            api_approve(
                client,
                publish_type='kaltura_my_media',
                recording_type='presentation_audio',
                section_id=section_1_id,
            )
            api_json = api_get_course(client, section_id=section_1_id, term_id=self.term_id)
            assert api_json['schedulingStatus'] == 'Queued for Scheduling'
            assert api_json['hasOptedOut'] is False