本文整理汇总了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)
示例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)
示例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()))