当前位置: 首页>>代码示例>>Python>>正文


Python factories.CourseOverviewFactory类代码示例

本文整理汇总了Python中openedx.core.djangoapps.content.course_overviews.tests.factories.CourseOverviewFactory的典型用法代码示例。如果您正苦于以下问题:Python CourseOverviewFactory类的具体用法?Python CourseOverviewFactory怎么用?Python CourseOverviewFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CourseOverviewFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_config_overrides

    def test_config_overrides(self, global_setting, site_setting, org_setting, course_setting, reverse_order):
        """
        Test that the stacked configuration overrides happen in the correct order and priority.

        This is tested by exhaustively setting each combination of contexts, and validating that only
        the lowest level context that is set to not-None is applied.
        """
        # Add a bunch of configuration outside the contexts that are being tested, to make sure
        # there are no leaks of configuration across contexts
        non_test_course_enabled = CourseOverviewFactory.create(org='non-test-org-enabled')
        non_test_course_disabled = CourseOverviewFactory.create(org='non-test-org-disabled')
        non_test_site_cfg_enabled = SiteConfigurationFactory.create(
            values={'course_org_filter': non_test_course_enabled.org}
        )
        non_test_site_cfg_disabled = SiteConfigurationFactory.create(
            values={'course_org_filter': non_test_course_disabled.org}
        )

        CourseDurationLimitConfig.objects.create(course=non_test_course_enabled, enabled=True)
        CourseDurationLimitConfig.objects.create(course=non_test_course_disabled, enabled=False)
        CourseDurationLimitConfig.objects.create(org=non_test_course_enabled.org, enabled=True)
        CourseDurationLimitConfig.objects.create(org=non_test_course_disabled.org, enabled=False)
        CourseDurationLimitConfig.objects.create(site=non_test_site_cfg_enabled.site, enabled=True)
        CourseDurationLimitConfig.objects.create(site=non_test_site_cfg_disabled.site, enabled=False)

        # Set up test objects
        test_course = CourseOverviewFactory.create(org='test-org')
        test_site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': test_course.org})

        if reverse_order:
            CourseDurationLimitConfig.objects.create(site=test_site_cfg.site, enabled=site_setting)
            CourseDurationLimitConfig.objects.create(org=test_course.org, enabled=org_setting)
            CourseDurationLimitConfig.objects.create(course=test_course, enabled=course_setting)
            CourseDurationLimitConfig.objects.create(enabled=global_setting)
        else:
            CourseDurationLimitConfig.objects.create(enabled=global_setting)
            CourseDurationLimitConfig.objects.create(course=test_course, enabled=course_setting)
            CourseDurationLimitConfig.objects.create(org=test_course.org, enabled=org_setting)
            CourseDurationLimitConfig.objects.create(site=test_site_cfg.site, enabled=site_setting)

        expected_global_setting = self._resolve_settings([global_setting])
        expected_site_setting = self._resolve_settings([global_setting, site_setting])
        expected_org_setting = self._resolve_settings([global_setting, site_setting, org_setting])
        expected_course_setting = self._resolve_settings([global_setting, site_setting, org_setting, course_setting])

        self.assertEqual(expected_global_setting, CourseDurationLimitConfig.current().enabled)
        self.assertEqual(expected_site_setting, CourseDurationLimitConfig.current(site=test_site_cfg.site).enabled)
        self.assertEqual(expected_org_setting, CourseDurationLimitConfig.current(org=test_course.org).enabled)
        self.assertEqual(expected_course_setting, CourseDurationLimitConfig.current(course_key=test_course.id).enabled)
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:49,代码来源:test_models.py

示例2: EligibleCertificateManagerTest

class EligibleCertificateManagerTest(SharedModuleStoreTestCase):
    """
    Test the GeneratedCertificate model's object manager for filtering
    out ineligible certs.
    """

    def setUp(self):
        super(EligibleCertificateManagerTest, self).setUp()
        self.user = UserFactory()

        self.course1 = CourseOverviewFactory()
        self.course2 = CourseOverviewFactory(
            id=CourseKey.from_string('{}a'.format(self.course1.id))
        )

        self.eligible_cert = GeneratedCertificateFactory.create(
            status=CertificateStatuses.downloadable,
            user=self.user,
            course_id=self.course1.id
        )
        self.ineligible_cert = GeneratedCertificateFactory.create(
            status=CertificateStatuses.audit_passing,
            user=self.user,
            course_id=self.course2.id
        )

    def test_filter_ineligible_certificates(self):
        """
        Verify that the EligibleAvailableCertificateManager filters out
        certificates marked as ineligible, and that the default object
        manager for GeneratedCertificate does not filter them out.
        """
        self.assertEqual(list(
            GeneratedCertificate.eligible_available_certificates.filter(user=self.user)), [self.eligible_cert]
        )
        self.assertEqual(
            list(GeneratedCertificate.objects.filter(user=self.user)),
            [self.eligible_cert, self.ineligible_cert]
        )

    def test_filter_certificates_for_nonexistent_courses(self):
        """
        Verify that the EligibleAvailableCertificateManager filters out
        certificates for courses with no CourseOverview.
        """
        self.course1.delete()
        self.assertFalse(GeneratedCertificate.eligible_available_certificates.filter(
            user=self.user)
        )
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:49,代码来源:test_models.py

示例3: setUpClass

    def setUpClass(cls):
        super(TaskTestCase, cls).setUpClass()
        cls.discussion_id = 'dummy_discussion_id'
        cls.course = CourseOverviewFactory.create(language='fr')

        # Patch the comment client user save method so it does not try
        # to create a new cc user when creating a django user
        with mock.patch('student.models.cc.User.save'):
            cls.thread_author = UserFactory(
                username='thread_author',
                password='password',
                email='email'
            )
            cls.comment_author = UserFactory(
                username='comment_author',
                password='password',
                email='email'
            )

            CourseEnrollmentFactory(
                user=cls.thread_author,
                course_id=cls.course.id
            )
            CourseEnrollmentFactory(
                user=cls.comment_author,
                course_id=cls.course.id
            )

        config = ForumsConfig.current()
        config.enabled = True
        config.save()

        cls.create_thread_and_comments()
开发者ID:jolyonb,项目名称:edx-platform,代码行数:33,代码来源:test_tasks.py

示例4: test_unpublished_sessions_for_entitlement_when_enrolled

    def test_unpublished_sessions_for_entitlement_when_enrolled(self, mock_get_edx_api_data):
        """
        Test unpublished course runs are part of visible session entitlements when the user
        is enrolled.
        """
        catalog_course_run = CourseRunFactory.create(status=COURSE_UNPUBLISHED)
        catalog_course = CourseFactory(course_runs=[catalog_course_run])
        mock_get_edx_api_data.return_value = catalog_course
        course_key = CourseKey.from_string(catalog_course_run.get('key'))
        course_overview = CourseOverviewFactory.create(id=course_key, start=self.tomorrow)
        CourseModeFactory.create(
            mode_slug=CourseMode.VERIFIED,
            min_price=100,
            course_id=course_overview.id,
            expiration_datetime=now() - timedelta(days=1)
        )
        course_enrollment = CourseEnrollmentFactory(
            user=self.user, course_id=unicode(course_overview.id), mode=CourseMode.VERIFIED
        )
        entitlement = CourseEntitlementFactory(
            user=self.user, enrollment_course_run=course_enrollment, mode=CourseMode.VERIFIED
        )

        session_entitlements = get_visible_sessions_for_entitlement(entitlement)
        self.assertEqual(session_entitlements, [catalog_course_run])
开发者ID:mitocw,项目名称:edx-platform,代码行数:25,代码来源:test_utils.py

示例5: test_caching_org

    def test_caching_org(self):
        course = CourseOverviewFactory.create(org='test-org')
        site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': course.org})
        org_config = ContentTypeGatingConfig(org=course.org, enabled=True, enabled_as_of=datetime(2018, 1, 1))
        org_config.save()

        # Check that the org value is not retrieved from cache after save
        with self.assertNumQueries(2):
            self.assertTrue(ContentTypeGatingConfig.current(org=course.org).enabled)

        # Check that the org value can be retrieved from cache after read
        with self.assertNumQueries(0):
            self.assertTrue(ContentTypeGatingConfig.current(org=course.org).enabled)

        org_config.enabled = False
        org_config.save()

        # Check that the org value in cache was deleted on save
        with self.assertNumQueries(2):
            self.assertFalse(ContentTypeGatingConfig.current(org=course.org).enabled)

        global_config = ContentTypeGatingConfig(enabled=True, enabled_as_of=datetime(2018, 1, 1))
        global_config.save()

        # Check that the org value is not updated in cache by changing the global value
        with self.assertNumQueries(0):
            self.assertFalse(ContentTypeGatingConfig.current(org=course.org).enabled)

        site_config = ContentTypeGatingConfig(site=site_cfg.site, enabled=True, enabled_as_of=datetime(2018, 1, 1))
        site_config.save()

        # Check that the org value is not updated in cache by changing the site value
        with self.assertNumQueries(0):
            self.assertFalse(ContentTypeGatingConfig.current(org=course.org).enabled)
开发者ID:mitocw,项目名称:edx-platform,代码行数:34,代码来源:test_models.py

示例6: setUp

 def setUp(self):
     super(TestModels, self).setUp()
     self.course = CourseOverviewFactory.create(
         start=now()
     )
     self.enrollment = CourseEnrollmentFactory.create(course_id=self.course.id)
     self.user = UserFactory()
     self.client.login(username=self.user.username, password=TEST_PASSWORD)
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:8,代码来源:test_models.py

示例7: test_all_current_course_configs

    def test_all_current_course_configs(self):
        # Set up test objects
        for global_setting in (True, False, None):
            CourseDurationLimitConfig.objects.create(enabled=global_setting, enabled_as_of=datetime(2018, 1, 1))
            for site_setting in (True, False, None):
                test_site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': []})
                CourseDurationLimitConfig.objects.create(
                    site=test_site_cfg.site, enabled=site_setting, enabled_as_of=datetime(2018, 1, 1)
                )

                for org_setting in (True, False, None):
                    test_org = "{}-{}".format(test_site_cfg.id, org_setting)
                    test_site_cfg.values['course_org_filter'].append(test_org)
                    test_site_cfg.save()

                    CourseDurationLimitConfig.objects.create(
                        org=test_org, enabled=org_setting, enabled_as_of=datetime(2018, 1, 1)
                    )

                    for course_setting in (True, False, None):
                        test_course = CourseOverviewFactory.create(
                            org=test_org,
                            id=CourseLocator(test_org, 'test_course', 'run-{}'.format(course_setting))
                        )
                        CourseDurationLimitConfig.objects.create(
                            course=test_course, enabled=course_setting, enabled_as_of=datetime(2018, 1, 1)
                        )

            with self.assertNumQueries(4):
                all_configs = CourseDurationLimitConfig.all_current_course_configs()

        # Deliberatly using the last all_configs that was checked after the 3rd pass through the global_settings loop
        # We should be creating 3^4 courses (3 global values * 3 site values * 3 org values * 3 course values)
        # Plus 1 for the edX/toy/2012_Fall course
        self.assertEqual(len(all_configs), 3**4 + 1)

        # Point-test some of the final configurations
        self.assertEqual(
            all_configs[CourseLocator('7-True', 'test_course', 'run-None')],
            {
                'enabled': (True, Provenance.org),
                'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run),
            }
        )
        self.assertEqual(
            all_configs[CourseLocator('7-True', 'test_course', 'run-False')],
            {
                'enabled': (False, Provenance.run),
                'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run),
            }
        )
        self.assertEqual(
            all_configs[CourseLocator('7-None', 'test_course', 'run-None')],
            {
                'enabled': (True, Provenance.site),
                'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run),
            }
        )
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:58,代码来源:test_models.py

示例8: test_unfulfilled_entitlement

    def test_unfulfilled_entitlement(self, mock_course_overview, mock_pseudo_session,
                                     mock_course_runs, mock_get_programs):
        """
        When a learner has an unfulfilled entitlement, their course dashboard should have:
            - a hidden 'View Course' button
            - the text 'In order to view the course you must select a session:'
            - an unhidden course-entitlement-selection-container
            - a related programs message
        """
        program = ProgramFactory()
        CourseEntitlementFactory.create(user=self.user, course_uuid=program['courses'][0]['uuid'])
        mock_get_programs.return_value = [program]
        course_key = CourseKey.from_string('course-v1:FAKE+FA1-MA1.X+3T2017')
        mock_course_overview.return_value = CourseOverviewFactory.create(start=self.TOMORROW, id=course_key)
        mock_course_runs.return_value = [
            {
                'key': six.text_type(course_key),
                'enrollment_end': str(self.TOMORROW),
                'pacing_type': 'instructor_paced',
                'type': 'verified',
                'status': 'published'
            }
        ]
        mock_pseudo_session.return_value = {
            'key': six.text_type(course_key),
            'type': 'verified'
        }
        response = self.client.get(self.path)
        self.assertIn('class="course-target-link enter-course hidden"', response.content)
        self.assertIn('You must select a session to access the course.', response.content)
        self.assertIn('<div class="course-entitlement-selection-container ">', response.content)
        self.assertIn('Related Programs:', response.content)

        # If an entitlement has already been redeemed by the user for a course run, do not let the run be selectable
        enrollment = CourseEnrollmentFactory(
            user=self.user, course_id=six.text_type(mock_course_overview.return_value.id), mode=CourseMode.VERIFIED
        )
        CourseEntitlementFactory.create(
            user=self.user, course_uuid=program['courses'][0]['uuid'], enrollment_course_run=enrollment
        )

        mock_course_runs.return_value = [
            {
                'key': 'course-v1:edX+toy+2012_Fall',
                'enrollment_end': str(self.TOMORROW),
                'pacing_type': 'instructor_paced',
                'type': 'verified',
                'status': 'published'
            }
        ]
        response = self.client.get(self.path)
        # There should be two entitlements on the course page, one prompting for a mandatory session, but no
        # select option for the courses as there is only the single course run which has already been redeemed
        self.assertEqual(response.content.count('<li class="course-item">'), 2)
        self.assertIn('You must select a session to access the course.', response.content)
        self.assertNotIn('To access the course, select a session.', response.content)
开发者ID:cpennington,项目名称:edx-platform,代码行数:56,代码来源:test_views.py

示例9: setUp

 def setUp(self):
     self.student = UserFactory.create(username='test-student')
     self.course = CourseOverviewFactory.create(
         self_paced=True  # Any option to allow the certificate to be viewable for the course
     )
     self.certificate = GeneratedCertificateFactory(
         user=self.student,
         mode='verified',
         course_id=self.course.id,
         status='downloadable'
     )
开发者ID:mreyk,项目名称:edx-platform,代码行数:11,代码来源:test_tasks.py

示例10: setUpClass

    def setUpClass(cls):
        super(ListViewTestMixin, cls).setUpClass()
        cls.program_uuid = '00000000-1111-2222-3333-444444444444'
        cls.curriculum_uuid = 'aaaaaaaa-1111-2222-3333-444444444444'
        cls.other_curriculum_uuid = 'bbbbbbbb-1111-2222-3333-444444444444'

        cls.course_id = CourseKey.from_string('course-v1:edX+ToyX+Toy_Course')
        _ = CourseOverviewFactory.create(id=cls.course_id)

        cls.password = 'password'
        cls.student = UserFactory.create(username='student', password=cls.password)
        cls.global_staff = GlobalStaffFactory.create(username='global-staff', password=cls.password)
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:12,代码来源:test_views.py

示例11: setUpClass

 def setUpClass(cls):
     super(CertificatesListRestApiTest, cls).setUpClass()
     cls.course = CourseFactory.create(
         org='edx',
         number='verified',
         display_name='Verified Course',
         self_paced=True,
     )
     cls.course_overview = CourseOverviewFactory.create(
         id=cls.course.id,
         display_org_with_default='edx',
         display_name='Verified Course',
         cert_html_view_enabled=True,
         self_paced=True,
     )
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:15,代码来源:test_views.py

示例12: setUpClass

 def setUpClass(cls):
     cls.course_key = CourseKey.from_string('course-v1:edX+DemoX+Demo_Course')
     cls.course = CourseOverviewFactory.create(id=cls.course_key)
     cls.audit_mode = CourseModeFactory.create(
         course_id=cls.course_key,
         mode_slug='audit',
         mode_display_name='Audit',
         min_price=0,
     )
     cls.verified_mode = CourseModeFactory.create(
         course_id=cls.course_key,
         mode_slug='verified',
         mode_display_name='Verified',
         min_price=25,
     )
     # use these to make sure we don't fetch data for other courses
     cls.other_course_key = CourseKey.from_string('course-v1:edX+DemoX+Other_Course')
     cls.other_course = CourseOverviewFactory.create(id=cls.other_course_key)
     cls.other_mode = CourseModeFactory.create(
         course_id=cls.other_course_key,
         mode_slug='other-audit',
         mode_display_name='Other Audit',
         min_price=0,
     )
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:24,代码来源:test_views.py

示例13: setUp

 def setUp(self):
     super(CertificatesApiTestCase, self).setUp()
     self.course = CourseOverviewFactory.create(
         start=datetime(2017, 1, 1, tzinfo=pytz.UTC),
         end=datetime(2017, 1, 31, tzinfo=pytz.UTC),
         certificate_available_date=None
     )
     self.user = UserFactory.create()
     self.enrollment = CourseEnrollmentFactory(
         user=self.user,
         course_id=self.course.id,
         is_active=True,
         mode='audit',
     )
     self.certificate = MockGeneratedCertificate(
         user=self.user,
         course_id=self.course.id
     )
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:18,代码来源:test_api.py

示例14: setUp

    def setUp(self):
        super(EligibleCertificateManagerTest, self).setUp()
        self.user = UserFactory()

        self.course1 = CourseOverviewFactory()
        self.course2 = CourseOverviewFactory(
            id=CourseKey.from_string('{}a'.format(self.course1.id))
        )

        self.eligible_cert = GeneratedCertificateFactory.create(
            status=CertificateStatuses.downloadable,
            user=self.user,
            course_id=self.course1.id
        )
        self.ineligible_cert = GeneratedCertificateFactory.create(
            status=CertificateStatuses.audit_passing,
            user=self.user,
            course_id=self.course2.id
        )
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:19,代码来源:test_models.py

示例15: test_get_visible_sessions_for_entitlement

    def test_get_visible_sessions_for_entitlement(self, mock_get_edx_api_data):
        """
        Test retrieval of visible session entitlements.
        """
        catalog_course_run = CourseRunFactory.create()
        catalog_course = CourseFactory(course_runs=[catalog_course_run])
        mock_get_edx_api_data.return_value = catalog_course
        course_key = CourseKey.from_string(catalog_course_run.get('key'))
        course_overview = CourseOverviewFactory.create(id=course_key, start=self.tomorrow)
        CourseModeFactory.create(mode_slug=CourseMode.VERIFIED, min_price=100, course_id=course_overview.id)
        course_enrollment = CourseEnrollmentFactory(
            user=self.user, course_id=unicode(course_overview.id), mode=CourseMode.VERIFIED
        )
        entitlement = CourseEntitlementFactory(
            user=self.user, enrollment_course_run=course_enrollment, mode=CourseMode.VERIFIED
        )

        session_entitlements = get_visible_sessions_for_entitlement(entitlement)
        self.assertEqual(session_entitlements, [catalog_course_run])
开发者ID:mitocw,项目名称:edx-platform,代码行数:19,代码来源:test_utils.py


注:本文中的openedx.core.djangoapps.content.course_overviews.tests.factories.CourseOverviewFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。