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


Python Shift.create方法代码示例

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


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

示例1: testPagingFeatures

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testPagingFeatures(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift1 = Shift.create(json)
     newShift2 = Shift.create(json)
     newShift3 = Shift.create(json)
     fav1 = Favorite.create(self.fakejohn.id, newShift1.id)
     fav2 = Favorite.create(self.fakejohn.id, newShift2.id)
     fav3 = Favorite.create(self.fakejohn.id, newShift3.id)
     favorites = self.fakejohn.favorites(limit=2)
     self.assertEqual(len(favorites), 2)
     fav1.delete()
     fav2.delete()
     fav3.delete()
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:16,代码来源:favorite_model_test.py

示例2: testSubscribe

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testSubscribe(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.publish({"private":False})
     # make a comment
     newComment = Comment.create(
         self.fakejohn.id,
         newShift.id,
         "1st comment!",
         subscribe=True
         )
     # check that shift author is subscribed
     subscribers = newShift.subscribers()
     self.assertTrue(self.fakemary.id in subscribers)
     # check that commenter is subscribed
     self.assertTrue(self.fakejohn.id in subscribers)
     # check that there is a message in shift author message db
     messages = self.fakemary.messages()
     self.assertEqual(len(messages), 1)
     self.assertEqual(messages[0].text, "fakejohn just commented on your shift!")
     # check that there is _not_ a message in commenters message db
     messages = self.fakejohn.messages()
     self.assertEqual(len(messages), 0)
     newShift.deleteThread()
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:27,代码来源:comment_model_test.py

示例3: testCanModify

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testCanModify(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     self.assertTrue(self.fakemary.canModify(newShift))
     self.assertTrue(not self.fakejohn.canModify(newShift))
     self.assertTrue(self.root.canModify(newShift))
开发者ID:xncroft,项目名称:shiftspace,代码行数:9,代码来源:shift_model_test.py

示例4: testDelete

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testDelete(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     self.assertNotEqual(newShift, None)
     newShift.delete()
     theShift = Shift.read(newShift.id, self.fakemary.id)
     self.assertEqual(theShift, None)
开发者ID:xncroft,项目名称:shiftspace,代码行数:10,代码来源:shift_model_test.py

示例5: testUpdate

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testUpdate(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.update({"summary":"changed!"})
     theShift = Shift.read(newShift.id, self.fakemary.id)
     self.assertEqual(theShift.summary, "changed!")
     db = core.connect(SSUser.privateDb(self.fakemary.id))
     del db[theShift.id]
开发者ID:xncroft,项目名称:shiftspace,代码行数:11,代码来源:shift_model_test.py

示例6: testRead

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testRead(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     theShift = Shift.read(newShift.id, self.fakemary.id)
     self.assertEqual(theShift.source.server, newShift.source.server)
     self.assertEqual(theShift.source.database, newShift.source.database)
     self.assertEqual(theShift.createdBy, self.fakemary.id)
     db = core.connect(SSUser.privateDb(self.fakemary.id))
     del db[theShift.id]
开发者ID:xncroft,项目名称:shiftspace,代码行数:12,代码来源:shift_model_test.py

示例7: create

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def create(self):
     loggedInUser = helper.getLoggedInUser()
     jsonData = helper.getRequestBody()
     if jsonData != "":
         theData = json.loads(jsonData)
         id = loggedInUser
         theData['createdBy'] = id
         return data(Shift.create(theData))
     else:
         return error("No data for shift.", NoDataError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:12,代码来源:shift.py

示例8: testPublishToUser

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testPublishToUser(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     publishData = {
         "dbs": [SSUser.db(self.fakejohn.id)]
         }
     newShift.publish(publishData)
     # should exist in user feed
     # TODO: in inbox if peer - David 11/18/09
     theShift = Shift.load(core.connect("shiftspace/shared"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
开发者ID:xncroft,项目名称:shiftspace,代码行数:14,代码来源:shift_model_test.py

示例9: testCreate

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testCreate(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     theShift = Shift.create(json)
     self.assertEqual(theShift.type, "shift")
     self.assertEqual(theShift.createdBy, self.fakemary.id)
     self.assertNotEqual(theShift.created, None)
     self.assertEqual(type(theShift.created), datetime.datetime)
     self.assertNotEqual(theShift.modified, None)
     self.assertEqual(type(theShift.modified), datetime.datetime)
     self.assertEqual(theShift.domain, "http://google.com")
     db = core.connect(SSUser.privateDb(self.fakemary.id))
     del db[theShift.id]
开发者ID:xncroft,项目名称:shiftspace,代码行数:15,代码来源:shift_model_test.py

示例10: testPublishToFollowers

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testPublishToFollowers(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     self.fakejohn.follow(self.fakemary)
     fakejohn = SSUser.read(self.fakejohn.id)
     # should be in the list of people fakejohn is following
     self.assertTrue(self.fakemary.id in fakejohn.following())
     # should be in the list of fakemary's followers
     followers = self.fakemary.followers()
     self.assertTrue(self.fakejohn.id in followers)
     newShift.publish({"private":False})
     # should exist in shiftspace/shared db
     theShift = Shift.load(core.connect("shiftspace/shared"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
开发者ID:xncroft,项目名称:shiftspace,代码行数:17,代码来源:shift_model_test.py

示例11: testBasicPublish

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testBasicPublish(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.publish({"private":False})
     # should exist in user/public db
     theShift = Shift.load(core.connect(SSUser.publicDb(self.fakemary.id)), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     # should exist in master/public db 
     theShift = Shift.load(core.connect("shiftspace/public"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     # should exist in shiftspace/shared db
     theShift = Shift.load(core.connect("shiftspace/shared"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     # should _not_ exist in user/private db
     theShift = Shift.load(core.connect(SSUser.privateDb(self.fakemary.id)), newShift.id)
     self.assertEqual(theShift, None)
开发者ID:xncroft,项目名称:shiftspace,代码行数:19,代码来源:shift_model_test.py

示例12: testUnfavorite

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testUnfavorite(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newFavorite = Favorite.create(self.fakejohn.id, newShift.id)
     favorites = self.fakejohn.favorites()
     # user should have 1 favorite
     self.assertEqual(len(favorites), 1)
     # favorite count for that shift should be 1
     count = newShift.favoriteCount()
     self.assertEqual(count, 1)
     newFavorite.delete()
     # user should have 0 favorites
     favorites = self.fakejohn.favorites()
     self.assertEqual(len(favorites), 0)
     # favorite count for that shift should be 0
     count = newShift.favoriteCount()
     self.assertEqual(count, 0)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:20,代码来源:favorite_model_test.py

示例13: testUnsubscribe

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testUnsubscribe(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.publish({"private":False})
     # another user makes a comment
     newComment = Comment.create(
         self.fakebob.id,
         newShift.id,
         "1st comment!",
         subscribe=True
         )
     # subscribe fakejohn
     self.fakejohn.subscribe(newShift)
     # another user makes another comment
     newComment = Comment.create(
         self.fakebob.id,
         newShift.id,
         "2nd comment!"
         )
     # check that fakejohn has one message
     messages = self.fakejohn.messages()
     self.assertEqual(len(messages), 1)
     self.assertEqual(messages[0].text, "fakebob just commented on fakemary's shift!")
     # unsubscribe fakejohn
     self.fakejohn.unsubscribe(newShift)
     newComment = Comment.create(
         self.fakebob.id,
         newShift.id,
         "3rd comment!"
         )
     # check that fakejohn still only has one message
     messages = self.fakejohn.messages()
     self.assertEqual(len(messages), 1)
     # check that fakemary has two messages
     messages = self.fakemary.messages()
     self.assertEqual(len(messages), 3)
     # check that fakebob has no messages
     messages = self.fakebob.messages()
     self.assertEqual(len(messages), 0)
     newShift.deleteThread()
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:43,代码来源:comment_model_test.py

示例14: testPublishToGroupAndUser

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testPublishToGroupAndUser(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     json = groupJson()
     json["createdBy"] = self.fakemary.id
     newGroup = Group.create(json)
     newPerm = Permission.create("shiftspace", newGroup.id, self.fakejohn.id, level=1)
     publishData = {
         "dbs": [Group.db(newGroup.id), SSUser.db(self.fakebob.id)]
         }
     newShift.publish(publishData)
     # should exist in subscriber's feed
     db = core.connect("shiftspace/shared")
     theShift = Shift.load(db, newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     newGroup.delete()
     # should exist in shiftspace/shared
     # TODO: inbox if user is peer - David 11/18/09
     theShift = Shift.load(core.connect("shiftspace/shared"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
开发者ID:xncroft,项目名称:shiftspace,代码行数:23,代码来源:shift_model_test.py

示例15: testCreate

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import create [as 别名]
 def testCreate(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.publish({"private":False})
     # create new comment
     newComment = Comment.create(self.fakejohn.id, newShift.id, "1st comment!")
     # shift comment db should now exist
     self.assertNotEqual(core.connect(Comment.db(newShift.id)), None)
     # shift should have thread
     self.assertTrue(newShift.hasThread())
     # should be a comment count of 1 for shift
     count = newShift.commentCount()
     self.assertEqual(count, 1)
     # should be one message in fakemary's inbox from fakejohn
     messages = self.fakemary.messages()
     self.assertEqual(len(messages), 1)
     # delete the comment
     # TODO: separate fixture - David
     newComment.delete()
     # delete the thread
     newShift.deleteThread()
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:24,代码来源:comment_model_test.py


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