Beispiel #1
0
    def test_update(self):
        """
        Verify that we can update course-run workflow state name and preview_accepted with serializer.
        """
        CourseUserRoleFactory(course=self.course_run.course,
                              role=PublisherUserRole.Publisher,
                              user=UserFactory())

        self.assertNotEqual(self.run_state, CourseRunStateChoices.Review)

        self.course_run.lms_course_id = 'course-v1:edX+DemoX+Demo_Course'
        serializer = self.serializer_class(self.run_state,
                                           context={'request': self.request})
        data = {'name': CourseRunStateChoices.Review}
        serializer.update(self.run_state, data)

        self.assertEqual(self.run_state.name, CourseRunStateChoices.Review)
        self.assertEqual(len(mail.outbox), 1)

        course_key = CourseKey.from_string(self.course_run.lms_course_id)
        subject = 'Review requested: {course_name} {run_name}'.format(
            course_name=self.course_run.course.title, run_name=course_key.run)
        self.assertIn(subject, str(mail.outbox[0].subject))

        self.assertFalse(self.run_state.preview_accepted)
        serializer.update(self.run_state, {'preview_accepted': True})

        self.assertEqual(len(mail.outbox), 2)
        subject = 'Publication requested: {course_name} {run_name}'.format(
            course_name=self.course_run.course.title, run_name=course_key.run)
        self.assertIn(subject, str(mail.outbox[1].subject))
Beispiel #2
0
 def setUp(self):
     super(CourseUserRoleSerializerTests, self).setUp()
     self.request = RequestFactory()
     self.course_user_role = CourseUserRoleFactory(
         role=PublisherUserRole.MarketingReviewer)
     self.request.user = self.course_user_role.user
     self.request.site = self.site
    def setUp(self):
        super(CourseStateSerializerTests, self).setUp()
        self.course_state = CourseStateFactory(name=CourseStateChoices.Draft)
        self.user = UserFactory()
        self.request.user = self.user

        CourseUserRoleFactory(course=self.course_state.course,
                              role=PublisherUserRole.CourseTeam,
                              user=self.user)
Beispiel #4
0
    def test_with_internal_user(self):
        """ Verify course search only lets an internal user access courses with a role for them. """
        self.user.groups.add(Group.objects.get(name=INTERNAL_USER_GROUP_NAME))

        # Confirm that internal users aren't granted blanket access
        self.assertFalse(self._check_form())

        # But it *will* work if we add a role for this user
        CourseUserRoleFactory(course=self.course, user=self.user, role=PublisherUserRole.MarketingReviewer)
        self.assertTrue(self._check_form())
def test_generate_data_for_studio_api():
    course_run = CourseRunFactory(course__organizations=[OrganizationFactory()])
    course = course_run.course
    role = CourseUserRoleFactory(course=course, role=PublisherUserRole.CourseTeam)
    team = [
        {
            'user': role.user.username,
            'role': 'instructor',
        },
    ]
    assert_data_generated_correctly(course_run, team)
Beispiel #6
0
 def test_clean_with_valid_owner_role(self):
     """
     Test that 'clean' does not raise 'ValidationError' if the user role that has been assigned owner does exist
     """
     course = CourseFactory()
     user = UserFactory()
     CourseUserRoleFactory(course=course, user=user, role=PublisherUserRole.CourseTeam)
     course_state_form = CourseStateAdminForm()
     course_state_form.cleaned_data = {
         'owner_role': PublisherUserRole.CourseTeam,
         'course': course
     }
     self.assertEqual(course_state_form.clean(), course_state_form.cleaned_data)
Beispiel #7
0
    def setUp(self):
        super(CourseRunStateSerializerTests, self).setUp()
        self.run_state = CourseRunStateFactory(name=CourseRunStateChoices.Draft)
        self.course_run = self.run_state.course_run
        self.request = RequestFactory()
        self.user = UserFactory()
        self.request.user = self.user
        CourseStateFactory(name=CourseStateChoices.Approved, course=self.course_run.course)

        SeatFactory(course_run=self.course_run, type=Seat.AUDIT)
        language_tag = LanguageTag(code='te-st', name='Test Language')
        language_tag.save()
        self.course_run.transcript_languages.add(language_tag)
        self.course_run.language = language_tag
        self.course_run.save()
        self.course_run.staff.add(PersonFactory())

        toggle_switch('enable_publisher_email_notifications', True)
        CourseUserRoleFactory(
            course=self.course_run.course, role=PublisherUserRole.CourseTeam, user=self.user
        )
        CourseUserRoleFactory(
            course=self.course_run.course, role=PublisherUserRole.ProjectCoordinator, user=UserFactory()
        )
Beispiel #8
0
    def test_update(self):
        """
        Verify that we can update course-run workflow state name and preview_accepted with serializer.
        """
        CourseUserRoleFactory(
            course=self.course_run.course, role=PublisherUserRole.Publisher, user=UserFactory()
        )

        self.assertNotEqual(self.run_state, CourseRunStateChoices.Review)
        serializer = self.serializer_class(self.run_state, context={'request': self.request})
        data = {'name': CourseRunStateChoices.Review}
        serializer.update(self.run_state, data)

        self.assertEqual(self.run_state.name, CourseRunStateChoices.Review)

        self.assertFalse(self.run_state.preview_accepted)
        serializer.update(self.run_state, {'preview_accepted': True})

        self.assertTrue(CourseRun.objects.get(id=self.course_run.id).preview_url)
        self.assertEqual(len(mail.outbox), 1)
        subject = 'Preview for {run_name}'.format(
            run_name=self.course_run.get_pacing_type_display()
        )
        self.assertIn(subject, str(mail.outbox[0].subject))
Beispiel #9
0
 def setUp(self):
     super(CourseUserRoleSerializerTests, self).setUp()
     self.request = RequestFactory()
     self.course_user_role = CourseUserRoleFactory()
     self.request.user = self.course_user_role.user