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


Python Course.create方法代码示例

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


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

示例1: test_creation

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import create [as 别名]
 def test_creation(self):
     self.assertIsNotNone(
         Course.create(self.teacher, '', ''),
         'Empty course name'
     )
     self.assertIsNone(
         Course.create(self.teacher, 'pub', ''),
         'Create public course'
     )
     self.assertIsNotNone(
         Course.create(self.teacher, 'Pub', ''),
         'Recreate public course (bad)'
     )
     self.assertIsNone(
         Course.create(self.teacher, 'Pub2', None),
         'Create public course'
     )
     self.assertIsNone(
         Course.create(self.teacher, 'pvt', 'on'),
         'Create private course'
     )
     for name, private in [('Pvt', True), ('Pub', False), ('Pub2', False)]:
         course = Course.all().filter('name =', name).get()
         self.assertIsNotNone(course)
         if private:
             self.assertIsNotNone(course.code)
         else:
             self.assertIsNone(course.code)
         self.assertEqual(course.teacher.email, self.teacher.email)
开发者ID:matts1,项目名称:MajorWork-appengine,代码行数:31,代码来源:courses.py

示例2: setUp

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import create [as 别名]
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()

        # should all return None, because this is simply creating data and is all meant to be correct
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'teacher', 't'))
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'teachertwo', 'ttwo'))
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'student', 's'))

        self.teacher = User.all().filter('email =', '[email protected]').get()
        self.teacher2 = User.all().filter('email =', '[email protected]').get()
        self.student = User.all().filter('email =', '[email protected]' ).get()

        self.assertIsNotNone(self.teacher)
        self.assertIsNone(self.teacher.make_teacher())
        self.assertIsNotNone(self.teacher2)
        self.assertIsNone(self.teacher2.make_teacher())

        self.assertIsNone(Course.create(self.teacher, 'public', ''))
        self.public = Course.all().filter('name =', 'Public').get()
        self.assertIsNotNone(self.public)
        self.assertIsNone(Course.create(self.teacher, 'private', 'on'))
        self.private = Course.all().filter('name =', 'Private').get()
        self.assertIsNotNone(self.private)
开发者ID:matts1,项目名称:MajorWork-appengine,代码行数:27,代码来源:basetest.py

示例3: mypost

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import create [as 别名]
 def mypost(self):
     course = self.adderr(Course.create(
         self.user,
         self.request.get('name'),
         self.request.get('mode'),
     ))
     if not self.err:
         self.redirect(OPEN_COURSE_URL + str(course.key().id()))
开发者ID:matts1,项目名称:MajorWork-appengine,代码行数:10,代码来源:create.py


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