本文整理汇总了Python中MaKaC.rb_factory.Factory.newRoomBlocking方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.newRoomBlocking方法的具体用法?Python Factory.newRoomBlocking怎么用?Python Factory.newRoomBlocking使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.rb_factory.Factory
的用法示例。
在下文中一共展示了Factory.newRoomBlocking方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testIndexes
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def testIndexes(self):
block = self._createTestBlocking()
block2 = Factory.newRoomBlocking()()
block2.startDate = date(2011, 1, 1)
block2.endDate = date(2011, 1, 10)
block2.createdByUser = self._avatar3
block2.message = 'Testing 2'
self._blockRoom(block2, self._room1)
block2.insert()
# Test if all indexes work properly
self.assertEqual(frozenset(RoomBlockingBase.getAll()), frozenset((block, block2)))
self.assertTrue(RoomBlockingBase.getById(0) is None)
self.assertEqual(RoomBlockingBase.getById(1), block)
self.assertEqual(RoomBlockingBase.getById(2), block2)
self.assertTrue(not RoomBlockingBase.getByOwner(self._dummy))
self.assertTrue(not RoomBlockingBase.getByOwner(self._avatar1))
self.assertEqual(frozenset(RoomBlockingBase.getByOwner(self._avatar2)), frozenset((block,)))
self.assertEqual(frozenset(RoomBlockingBase.getByOwner(self._avatar3)), frozenset((block2,)))
self.assertTrue(not RoomBlockingBase.getByRoom(self._room5))
self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room1)),
frozenset((block.getBlockedRoom(self._room1), block2.getBlockedRoom(self._room1))))
self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room2)),
frozenset((block.getBlockedRoom(self._room2),)))
self.assertTrue(block2.getBlockedRoom(self._room2) is None)
self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2010, 12, 31))), frozenset((block,)))
self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2011, 1, 1))), frozenset((block, block2)))
self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2011, 1, 2))), frozenset((block2,)))
self.assertEqual(frozenset(RoomBlockingBase.getByDateSpan(date(2011, 1, 1), date(2011, 1, 2))),
frozenset((block, block2)))
self.assertEqual(frozenset(RoomBlockingBase.getByDateSpan(date(2011, 1, 2), date(2011, 2, 1))),
frozenset((block2,)))
self.assertTrue(not RoomBlockingBase.getByDateSpan(date(2011, 2, 1), date(2012, 1, 1)))
# Remove a block
block.remove()
self.assertEqual(len(RoomBlockingBase.getAll()), 1)
self.assertTrue(RoomBlockingBase.getById(block.id) is None)
self.assertTrue(not RoomBlockingBase.getByOwner(self._avatar2))
self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room1)),
frozenset((block2.getBlockedRoom(self._room1),)))
self.assertTrue(not RoomBlockingBase.getByRoom(self._room2))
self.assertTrue(not RoomBlockingBase.getByDate(date(2010, 12, 31)))
self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2011, 1, 1))), frozenset((block2,)))
self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2011, 1, 2))), frozenset((block2,)))
# Add a blocked room
br = self._blockRoom(block2, self._room2)
block2.addBlockedRoom(br)
# When adding a blocked room, update() may be (and is) required for it to beindexed
block2.update()
self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room2)),
frozenset((block2.getBlockedRoom(self._room2),)))
self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room1)),
frozenset((block2.getBlockedRoom(self._room1),)))
block2.delBlockedRoom(block2.getBlockedRoom(self._room1))
# Deletion has to update indexes immediately as the object will no longer be reachable from its parent block
self.assertTrue(not RoomBlockingBase.getByRoom(self._room1))
block2.update()
self.assertTrue(not RoomBlockingBase.getByRoom(self._room1))
示例2: _createTestBlocking
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def _createTestBlocking(self):
block = Factory.newRoomBlocking()()
block.startDate = date(2010, 12, 31)
block.endDate = date(2011, 1, 1)
block.createdByUser = self._avatar2
block.addAllowed(self._avatar4)
block.message = 'Testing'
self._blockRoom(block, self._room1)
self._blockRoom(block, self._room2)
self._blockRoom(block, self._room3)
self._blockRoom(block, self._room4)
self._blockRoom(block, self._room6)
block.insert()
return block
示例3: getByDateSpan
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def getByDateSpan(begin, end):
return Factory.newRoomBlocking().getByDateSpan(begin, end)
示例4: getByDate
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def getByDate(date):
return Factory.newRoomBlocking().getByDate(date)
示例5: getByRoom
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def getByRoom(room, active=-1):
return Factory.newRoomBlocking().getByRoom(room, active)
示例6: getByOwner
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def getByOwner(owner):
return Factory.newRoomBlocking().getByOwner(owner)
示例7: getById
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def getById(id):
return Factory.newRoomBlocking().getById(id)
示例8: getAll
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def getAll():
return Factory.newRoomBlocking().getAll()
示例9: getTotalCount
# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import newRoomBlocking [as 别名]
def getTotalCount():
return Factory.newRoomBlocking().getTotalCount()