Esempio n. 1
0
    def setUp(self):
        super(CreateCoursesTests, self).setUp()

        transcript_languages = LanguageTag.objects.all()[:2]
        self.subjects = SubjectFactory.create_batch(3)
        self.course = CourseFactory(subjects=self.subjects)

        self.command_name = 'import_metadata_courses'
        self.command_args = ['--start_id={}'.format(self.course.id), '--end_id={}'.format(self.course.id)]

        # create multiple course-runs against course.
        course_runs = CourseRunFactory.create_batch(
            3, course=self.course, transcript_languages=transcript_languages,
            language=transcript_languages[0],
            short_description_override='Testing description'
        )

        canonical_course_run = course_runs[0]
        for seat_type in ['honor', 'credit', 'verified']:  # to avoid same type seat creation.
            SeatFactory(course_run=canonical_course_run, type=seat_type)

        staff = PersonFactory.create_batch(2)
        canonical_course_run.staff.add(*staff)

        self.course.canonical_course_run = canonical_course_run
        self.course.save()

        # create org and assign to the course-metadata
        self.forganization_extension = factories.OrganizationExtensionFactory()
        self.organization = self.forganization_extension.organization
        self.course.authoring_organizations.add(self.organization)
Esempio n. 2
0
    def test_publish_with_staff_removed(self, mock_access_token):
        """
        Test that the publish button adds and removes staff from discovery_course_run
        """
        publisher_course_run = self._create_course_run_for_publication()

        partner = publisher_course_run.course.organizations.first().partner
        self._set_test_client_domain_and_login(partner)

        self._mock_studio_api_success(publisher_course_run)
        self._mock_ecommerce_api(publisher_course_run)

        publish_url = reverse('publisher:api:v1:course_run-publish',
                              kwargs={'pk': publisher_course_run.pk})
        response = self.client.post(publish_url, {})
        assert response.status_code == 200
        discovery_course_run = CourseRun.objects.get(
            key=publisher_course_run.lms_course_id)
        assert discovery_course_run.staff.all().count() == 2

        publisher_course_run.staff.clear()
        publisher_course_run.staff = PersonFactory.create_batch(1)
        response = self.client.post(publish_url, {})
        assert response.status_code == 200
        discovery_course_run = CourseRun.objects.get(
            key=publisher_course_run.lms_course_id)
        assert discovery_course_run.staff.all().count() == 1
Esempio n. 3
0
    def test_sanity_check_success(self):
        """ Verify the command does not raise a CommandError error if the new index passes the sanity check. """
        CourseRunFactory.create_batch(59)
        ProgramFactory.create_batch(59)
        PersonFactory.create_batch(59)
        record_count = 60

        # Ensure that no error is raised and the sanity check passes the second time
        with mock.patch(
                'course_discovery.apps.core.utils.ElasticsearchUtils.set_alias',
                return_value=True):
            with mock.patch(
                    'course_discovery.apps.edx_elasticsearch_dsl_extensions.management.commands.'
                    'update_index.Command.get_record_count',
                    return_value=record_count):
                call_command('update_index')
Esempio n. 4
0
 def _create_course_run_for_publication(self):
     organization = OrganizationFactory()
     transcript_languages = [LanguageTag.objects.first()]
     mock_image_file = make_image_file('test_image.jpg')
     return CourseRunFactory(course__organizations=[organization],
                             course__tertiary_subject=None,
                             course__image__from_file=mock_image_file,
                             lms_course_id='a/b/c',
                             transcript_languages=transcript_languages,
                             staff=PersonFactory.create_batch(2))
Esempio n. 5
0
    def create_program(self):
        organizations = [OrganizationFactory(partner=self.partner)]
        person = PersonFactory()

        course = CourseFactory(partner=self.partner)
        CourseRunFactory(course=course, staff=[person])

        program = ProgramFactory(
            courses=[course],
            authoring_organizations=organizations,
            credit_backing_organizations=organizations,
            corporate_endorsements=CorporateEndorsementFactory.create_batch(1),
            individual_endorsements=EndorsementFactory.create_batch(1),
            expected_learning_items=ExpectedLearningItemFactory.create_batch(
                1),
            job_outlook_items=JobOutlookItemFactory.create_batch(1),
            instructor_ordering=PersonFactory.create_batch(1),
            banner_image=make_image_file('test_banner.jpg'),
            video=VideoFactory(),
            partner=self.partner)
        return program