本文整理匯總了Python中muntjac.data.util.indexed_container.IndexedContainer.lastItemId方法的典型用法代碼示例。如果您正苦於以下問題:Python IndexedContainer.lastItemId方法的具體用法?Python IndexedContainer.lastItemId怎麽用?Python IndexedContainer.lastItemId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類muntjac.data.util.indexed_container.IndexedContainer
的用法示例。
在下文中一共展示了IndexedContainer.lastItemId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testAddItemAfterLastPerformance
# 需要導入模塊: from muntjac.data.util.indexed_container import IndexedContainer [as 別名]
# 或者: from muntjac.data.util.indexed_container.IndexedContainer import lastItemId [as 別名]
def testAddItemAfterLastPerformance(self):
# TODO running with less items because slow otherwise
times = list()
for _ in range(self._REPEATS):
c = IndexedContainer()
c.addItem()
start = 1000 * time.time()
for _ in range(self._ITEMS):
c.addItemAfter(c.lastItemId())
times.append((1000 * time.time()) - start)
self.checkMedian(self._ITEMS / 3, times,
'IndexedContainer.addItemAfter(lastId)',
self._ADD_ITEM_AFTER_LAST_FAIL_THRESHOLD)
示例2: testItemSetChangeListeners
# 需要導入模塊: from muntjac.data.util.indexed_container import IndexedContainer [as 別名]
# 或者: from muntjac.data.util.indexed_container.IndexedContainer import lastItemId [as 別名]
def testItemSetChangeListeners(self):
container = IndexedContainer()
counter = ItemSetChangeCounter()
container.addListener(counter)
id1 = 'id1'
id2 = 'id2'
id3 = 'id3'
self.initializeContainer(container)
counter.reset()
container.addItem()
counter.assertOnce()
container.addItem(id1)
counter.assertOnce()
self.initializeContainer(container)
counter.reset()
container.addItemAt(0)
counter.assertOnce()
container.addItemAt(0, id1)
counter.assertOnce()
container.addItemAt(0, id2)
counter.assertOnce()
container.addItemAt(len(container), id3)
counter.assertOnce()
# no notification if already in container
container.addItemAt(0, id1)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
container.addItemAfter(None)
counter.assertOnce()
container.addItemAfter(None, id1)
counter.assertOnce()
container.addItemAfter(id1)
counter.assertOnce()
container.addItemAfter(id1, id2)
counter.assertOnce()
container.addItemAfter(container.firstItemId())
counter.assertOnce()
container.addItemAfter(container.lastItemId())
counter.assertOnce()
container.addItemAfter(container.lastItemId(), id3)
counter.assertOnce()
# no notification if already in container
container.addItemAfter(0, id1)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
container.removeItem(self.sampleData[0])
counter.assertOnce()
self.initializeContainer(container)
counter.reset()
# no notification for removing a non-existing item
container.removeItem(id1)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
container.removeAllItems()
counter.assertOnce()
# already empty
container.removeAllItems()
counter.assertNone()
示例3: testItemSetChangeListenersFiltering
# 需要導入模塊: from muntjac.data.util.indexed_container import IndexedContainer [as 別名]
# 或者: from muntjac.data.util.indexed_container.IndexedContainer import lastItemId [as 別名]
def testItemSetChangeListenersFiltering(self):
container = IndexedContainer()
counter = ItemSetChangeCounter()
container.addListener(counter)
counter.reset()
container.addContainerFilter(self.FULLY_QUALIFIED_NAME, 'Test', True, False)
# no real change, so no notification required
counter.assertNone()
id1 = 'com.example.Test1'
id2 = 'com.example.Test2'
id3 = 'com.example.Other'
# perform operations while filtering container
self.initializeContainer(container)
counter.reset()
# passes filter
item = container.addItem(id1)
# no event if filtered out
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id1)
counter.assertOnce()
# passes filter but already in the container
item = container.addItem(id1)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
# passes filter after change
item = container.addItemAt(0, id1)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id1)
counter.assertOnce()
item = container.addItemAt(len(container), id2)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id2)
counter.assertOnce()
# passes filter but already in the container
item = container.addItemAt(0, id1)
counter.assertNone()
item = container.addItemAt(len(container), id2)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
# passes filter
item = container.addItemAfter(None, id1)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id1)
counter.assertOnce()
item = container.addItemAfter(container.lastItemId(), id2)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id2)
counter.assertOnce()
# passes filter but already in the container
item = container.addItemAfter(None, id1)
counter.assertNone()
item = container.addItemAfter(container.lastItemId(), id2)
counter.assertNone()
# does not pass filter
# TODO implement rest
self.initializeContainer(container)
counter.reset()
item = container.addItemAfter(None, id3)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
item = container.addItemAfter(container.firstItemId(), id3)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
item = container.addItemAfter(container.lastItemId(), id3)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
item = container.addItemAt(0, id3)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
counter.assertNone()
self.initializeContainer(container)
counter.reset()
item = container.addItemAt(1, id3)
counter.assertNone()
item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
counter.assertNone()
#.........這裏部分代碼省略.........