當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。