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


Python CourseFactory.has_started方法代码示例

本文整理汇总了Python中xmodule.modulestore.tests.factories.CourseFactory.has_started方法的典型用法代码示例。如果您正苦于以下问题:Python CourseFactory.has_started方法的具体用法?Python CourseFactory.has_started怎么用?Python CourseFactory.has_started使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmodule.modulestore.tests.factories.CourseFactory的用法示例。


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

示例1: TestBetatesterAccess

# 需要导入模块: from xmodule.modulestore.tests.factories import CourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.CourseFactory import has_started [as 别名]
class TestBetatesterAccess(ModuleStoreTestCase, CourseAccessTestMixin):
    """
    Tests for the beta tester feature
    """
    def setUp(self):
        super(TestBetatesterAccess, self).setUp()

        now = datetime.datetime.now(pytz.UTC)
        tomorrow = now + datetime.timedelta(days=1)

        self.course = CourseFactory(days_early_for_beta=2, start=tomorrow)
        self.content = ItemFactory(parent=self.course)

        self.normal_student = UserFactory()
        self.beta_tester = BetaTesterFactory(course_key=self.course.id)

    @patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
    def test_course_beta_period(self):
        """
        Check that beta-test access works for courses.
        """
        self.assertFalse(self.course.has_started())
        self.assertCannotAccessCourse(self.normal_student, 'load', self.course)
        self.assertCanAccessCourse(self.beta_tester, 'load', self.course)

    @patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
    def test_content_beta_period(self):
        """
        Check that beta-test access works for content.
        """
        # student user shouldn't see it
        self.assertFalse(has_access(self.normal_student, 'load', self.content, self.course.id))

        # now the student should see it
        self.assertTrue(has_access(self.beta_tester, 'load', self.content, self.course.id))
开发者ID:shevious,项目名称:edx-platform,代码行数:37,代码来源:test_view_authentication.py

示例2: TestBetatesterAccess

# 需要导入模块: from xmodule.modulestore.tests.factories import CourseFactory [as 别名]
# 或者: from xmodule.modulestore.tests.factories.CourseFactory import has_started [as 别名]
class TestBetatesterAccess(ModuleStoreTestCase):
    def setUp(self):

        now = datetime.datetime.now(pytz.UTC)
        tomorrow = now + datetime.timedelta(days=1)

        self.course = CourseFactory(days_early_for_beta=2, start=tomorrow)
        self.content = ItemFactory(parent=self.course)

        self.normal_student = UserFactory()
        self.beta_tester = BetaTesterFactory(course=self.course.location)

    @patch.dict("courseware.access.settings.FEATURES", {"DISABLE_START_DATES": False})
    def test_course_beta_period(self):
        """
        Check that beta-test access works for courses.
        """
        self.assertFalse(self.course.has_started())

        # student user shouldn't see it
        self.assertFalse(has_access(self.normal_student, self.course, "load"))

        # now the student should see it
        self.assertTrue(has_access(self.beta_tester, self.course, "load"))

    @patch.dict("courseware.access.settings.FEATURES", {"DISABLE_START_DATES": False})
    def test_content_beta_period(self):
        """
        Check that beta-test access works for content.
        """
        # student user shouldn't see it
        self.assertFalse(has_access(self.normal_student, self.content, "load", self.course.id))

        # now the student should see it
        self.assertTrue(has_access(self.beta_tester, self.content, "load", self.course.id))
开发者ID:XiaodunServerGroup,项目名称:medicalmooc,代码行数:37,代码来源:test_view_authentication.py


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