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


Python factories.SiteFactory类代码示例

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


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

示例1: test_site_config

    def test_site_config(self, org_list, exclude_orgs, expected_message_count, mock_schedule_send, mock_ace):
        filtered_org = 'filtered_org'
        unfiltered_org = 'unfiltered_org'
        site1 = SiteFactory.create(domain='foo1.bar', name='foo1.bar')
        limited_config = SiteConfigurationFactory.create(values={'course_org_filter': [filtered_org]}, site=site1)
        site2 = SiteFactory.create(domain='foo2.bar', name='foo2.bar')
        unlimited_config = SiteConfigurationFactory.create(values={'course_org_filter': []}, site=site2)

        for config in (limited_config, unlimited_config):
            ScheduleConfigFactory.create(site=config.site)

        ScheduleFactory.create(
            start=datetime.datetime(2017, 8, 2, 17, 44, 30, tzinfo=pytz.UTC),
            enrollment__course__org=filtered_org,
        )
        for _ in range(2):
            ScheduleFactory.create(
                start=datetime.datetime(2017, 8, 2, 17, 44, 30, tzinfo=pytz.UTC),
                enrollment__course__org=unfiltered_org,
            )

        test_time_str = serialize(datetime.datetime(2017, 8, 2, 17, tzinfo=pytz.UTC))
        with self.assertNumQueries(2):
            tasks.recurring_nudge_schedule_hour(
                limited_config.site.id, 3, test_time_str, org_list=org_list, exclude_orgs=exclude_orgs,
            )

        self.assertEqual(mock_schedule_send.apply_async.call_count, expected_message_count)
        self.assertFalse(mock_ace.send.called)
开发者ID:francishan,项目名称:edx-platform,代码行数:29,代码来源:test_send_recurring_nudge.py

示例2: setUp

    def setUp(self):
        super(SiteMixin, self).setUp()

        self.site = SiteFactory.create()
        self.site_configuration = SiteConfigurationFactory.create(
            site=self.site,
            values={
                "SITE_NAME": self.site.domain,
                "course_email_from_addr": "[email protected]",
                "course_email_template_name": "fake_email_template",
                "course_org_filter": "fakeX"
            }
        )

        self.site_other = SiteFactory.create(
            domain='testserver.fakeother',
            name='testserver.fakeother'
        )
        self.site_configuration_other = SiteConfigurationFactory.create(
            site=self.site_other,
            values={
                "SITE_NAME": self.site_other.domain,
                "SESSION_COOKIE_DOMAIN": self.site_other.domain,
                "course_org_filter": "fakeOtherX",
                "ENABLE_MKTG_SITE": True,
                "SHOW_ECOMMERCE_REPORTS": True,
                "MKTG_URLS": {
                    "ROOT": "https://marketing.fakeother",
                    "ABOUT": "/fake-about"
                }
            }
        )

        # Initialize client with default site domain
        self.use_site(self.site)
开发者ID:edx,项目名称:edx-platform,代码行数:35,代码来源:mixins.py

示例3: setUp

    def setUp(self):
        super(VerifiedUpgradeToolTest, self).setUp()

        self.course_verified_mode = CourseModeFactory(
            course_id=self.course.id,
            mode_slug=CourseMode.VERIFIED,
            expiration_datetime=self.now + datetime.timedelta(days=30),
        )

        patcher = patch('openedx.core.djangoapps.schedules.signals.get_current_site')
        mock_get_current_site = patcher.start()
        self.addCleanup(patcher.stop)
        mock_get_current_site.return_value = SiteFactory.create()

        DynamicUpgradeDeadlineConfiguration.objects.create(enabled=True)

        ScheduleConfigFactory.create(
            site=mock_get_current_site.return_value,
            create_schedules=True
        )

        self.enrollment = CourseEnrollmentFactory(
            course_id=self.course.id,
            mode=CourseMode.AUDIT,
            course=self.course_overview,
        )
        self.request = RequestFactory().request()
        self.request.user = self.enrollment.user
        crum.set_current_request(self.request)
开发者ID:lduarte1991,项目名称:edx-platform,代码行数:29,代码来源:test_course_tools.py

示例4: test_set_policy_site_and_mode_specific

    def test_set_policy_site_and_mode_specific(self):
        """
        Verify that, when there exists a policy matching both the mode and site of the a given course entitlement,
        it is selected over appropriate site- and mode-specific (mode- and site-agnostic) policies and the default
        policy for assignment to the entitlement.
        """
        course_uuid = uuid.uuid4()
        entitlement_data = self._get_data_set(self.user, str(course_uuid))
        entitlement_data['mode'] = CourseMode.PROFESSIONAL

        self.client.post(
            self.entitlements_list_url,
            data=json.dumps(entitlement_data),
            content_type='application/json',
        )
        course_entitlement = CourseEntitlement.objects.get(
            user=self.user,
            course_uuid=course_uuid
        )

        policy_site = SiteFactory.create()
        policy = CourseEntitlementPolicy.objects.create(mode=entitlement_data['mode'], site=policy_site)
        CourseEntitlementPolicy.objects.create(mode=entitlement_data['mode'], site=None)
        CourseEntitlementPolicy.objects.create(mode=None, site=policy_site)

        set_entitlement_policy(course_entitlement, policy_site)
        assert course_entitlement.policy == policy
开发者ID:eduNEXT,项目名称:edunext-platform,代码行数:27,代码来源:test_views.py

示例5: test_set_policy_match_site_over_mode

    def test_set_policy_match_site_over_mode(self):
        """
        Verify that, when both a mode-agnostic policy matching the site of a created entitlement and a site-agnostic
        policy matching the mode of a created entitlement exist but no policy matching both the site and mode of the
        created entitlement exists, the site-specific (mode-agnostic) policy matching the entitlement is selected over
        the mode-specific (site-agnostic) policy.
        """
        course_uuid = uuid.uuid4()
        entitlement_data = self._get_data_set(self.user, str(course_uuid))

        self.client.post(
            self.entitlements_list_url,
            data=json.dumps(entitlement_data),
            content_type='application/json',
        )
        course_entitlement = CourseEntitlement.objects.get(
            user=self.user,
            course_uuid=course_uuid
        )

        policy_site = SiteFactory.create()
        policy = CourseEntitlementPolicy.objects.create(mode=None, site=policy_site)
        CourseEntitlementPolicy.objects.create(mode=entitlement_data['mode'], site=None)

        set_entitlement_policy(course_entitlement, policy_site)
        assert course_entitlement.policy == policy
开发者ID:eduNEXT,项目名称:edunext-platform,代码行数:26,代码来源:test_views.py

示例6: setUp

    def setUp(self):
        self.sender = mock.Mock()
        self.user = mock.Mock()
        self.post = mock.Mock()
        self.post.thread.course_id = 'course-v1:edX+DemoX+Demo_Course'

        self.site = SiteFactory.create()
开发者ID:lduarte1991,项目名称:edx-platform,代码行数:7,代码来源:test_signals.py

示例7: test_context

    def test_context(self, mock_get_enterprise_customer_for_learner):
        self.request.site = SiteFactory.create()
        mock_get_enterprise_customer_for_learner.return_value = {}
        context = account_settings_context(self.request)

        user_accounts_api_url = reverse("accounts_api", kwargs={'username': self.user.username})
        self.assertEqual(context['user_accounts_api_url'], user_accounts_api_url)

        user_preferences_api_url = reverse('preferences_api', kwargs={'username': self.user.username})
        self.assertEqual(context['user_preferences_api_url'], user_preferences_api_url)

        for attribute in self.FIELDS:
            self.assertIn(attribute, context['fields'])

        self.assertEqual(
            context['user_accounts_api_url'], reverse("accounts_api", kwargs={'username': self.user.username})
        )
        self.assertEqual(
            context['user_preferences_api_url'], reverse('preferences_api', kwargs={'username': self.user.username})
        )

        self.assertEqual(context['duplicate_provider'], 'facebook')
        self.assertEqual(context['auth']['providers'][0]['name'], 'Facebook')
        self.assertEqual(context['auth']['providers'][1]['name'], 'Google')

        self.assertEqual(context['sync_learner_profile_data'], False)
        self.assertEqual(context['edx_support_url'], settings.SUPPORT_SITE_LINK)
        self.assertEqual(context['enterprise_name'], None)
        self.assertEqual(
            context['enterprise_readonly_account_fields'], {'fields': settings.ENTERPRISE_READONLY_ACCOUNT_FIELDS}
        )
开发者ID:cmscom,项目名称:edx-platform,代码行数:31,代码来源:test_views.py

示例8: test_schedule_config_creation_enabled_instructor_paced

 def test_schedule_config_creation_enabled_instructor_paced(self, mock_get_current_site):
     site = SiteFactory.create()
     mock_get_current_site.return_value = site
     ScheduleConfigFactory.create(site=site, enabled=True, create_schedules=True)
     course = _create_course_run(self_paced=False)
     enrollment = CourseEnrollmentFactory(course_id=course.id, mode=CourseMode.AUDIT)
     with self.assertRaises(Schedule.DoesNotExist):
         enrollment.schedule
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:8,代码来源:test_signals.py

示例9: setUp

    def setUp(self):
        super(TestScheduleOverrides, self).setUp()

        patcher = patch('openedx.core.djangoapps.schedules.signals.get_current_site')
        mock_get_current_site = patcher.start()
        self.addCleanup(patcher.stop)

        mock_get_current_site.return_value = SiteFactory.create()
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:8,代码来源:test_date_summary.py

示例10: setUp

    def setUp(self):
        ScheduleFactory.create(start=datetime.datetime(2017, 8, 1, 15, 44, 30, tzinfo=pytz.UTC))
        ScheduleFactory.create(start=datetime.datetime(2017, 8, 1, 17, 34, 30, tzinfo=pytz.UTC))
        ScheduleFactory.create(start=datetime.datetime(2017, 8, 2, 15, 34, 30, tzinfo=pytz.UTC))

        site = SiteFactory.create()
        self.site_config = SiteConfigurationFactory.create(site=site)
        ScheduleConfigFactory.create(site=self.site_config.site)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:8,代码来源:test_send_recurring_nudge.py

示例11: test_create_schedule_error

 def test_create_schedule_error(self, mock_create_schedule, mock_log, mock_get_current_site):
     site = SiteFactory.create()
     mock_get_current_site.return_value = site
     ScheduleConfigFactory.create(site=site)
     mock_create_schedule.side_effect = ValueError('Fake error')
     self.assert_schedule_not_created()
     mock_log.assert_called_once()
     assert 'Encountered error in creating a Schedule for CourseEnrollment' in mock_log.call_args[0][0]
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:8,代码来源:test_signals.py

示例12: setUp

    def setUp(self):
        super(TestSendRecurringNudge, self).setUp()

        ScheduleFactory.create(start=datetime.datetime(2017, 8, 1, 15, 44, 30, tzinfo=pytz.UTC))
        ScheduleFactory.create(start=datetime.datetime(2017, 8, 1, 17, 34, 30, tzinfo=pytz.UTC))
        ScheduleFactory.create(start=datetime.datetime(2017, 8, 2, 15, 34, 30, tzinfo=pytz.UTC))

        site = SiteFactory.create()
        self.site_config = SiteConfigurationFactory.create(site=site)
        ScheduleConfigFactory.create(site=self.site_config.site)
开发者ID:francishan,项目名称:edx-platform,代码行数:10,代码来源:test_send_recurring_nudge.py

示例13: test_get_course_org_filter_exclude

 def test_get_course_org_filter_exclude(self, course_org_filter, expected_org_list):
     resolver = self.setup_resolver()
     self.other_site = SiteFactory.create()
     self.other_site_config = SiteConfigurationFactory.create(
         site=self.other_site,
         values={'course_org_filter': course_org_filter},
     )
     exclude_orgs, org_list = resolver.get_course_org_filter()
     assert exclude_orgs
     self.assertItemsEqual(org_list, expected_org_list)
开发者ID:mattpe,项目名称:edx-platform,代码行数:10,代码来源:test_resolvers.py

示例14: setUp

    def setUp(self):
        super(ScheduleSendEmailTestMixin, self).setUp()

        site = SiteFactory.create()
        self.site_config = SiteConfigurationFactory.create(site=site)
        ScheduleConfigFactory.create(site=self.site_config.site)

        DynamicUpgradeDeadlineConfiguration.objects.create(enabled=True)
        CommerceConfiguration.objects.create(checkout_on_ecommerce_service=True)

        self._courses_with_verified_modes = set()
开发者ID:mitocw,项目名称:edx-platform,代码行数:11,代码来源:send_email_base.py

示例15: setUp

    def setUp(self):
        super(TestSendRecurringNudge, self).setUp()

        ScheduleFactory.create(start=datetime.datetime(2017, 8, 1, 15, 44, 30, tzinfo=pytz.UTC))
        ScheduleFactory.create(start=datetime.datetime(2017, 8, 1, 17, 34, 30, tzinfo=pytz.UTC))
        ScheduleFactory.create(start=datetime.datetime(2017, 8, 2, 15, 34, 30, tzinfo=pytz.UTC))

        site = SiteFactory.create()
        self.site_config = SiteConfigurationFactory.create(site=site)
        ScheduleConfigFactory.create(site=self.site_config.site)

        DynamicUpgradeDeadlineConfiguration.objects.create(enabled=True)
开发者ID:mattpe,项目名称:edx-platform,代码行数:12,代码来源:test_send_recurring_nudge.py


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