コード例 #1
0
ファイル: testUnordered.py プロジェクト: bastianh/Eos
 def testClear(self):
     container = self.container
     fitMock = self.fitMock
     holder1 = Holder()
     holder2 = Holder()
     container.add(holder1)
     container.add(holder2)
     self.assertEqual(len(fitMock.mock_calls), 2)
     container.clear()
     self.assertEqual(len(fitMock.mock_calls), 4)
     newCalls = fitMock.method_calls[2:4]
     self.assertIn(call._removeHolder(holder1), newCalls)
     self.assertIn(call._removeHolder(holder2), newCalls)
     self.assertEqual(len(container), 0)
     self.assertBuffersEmpty(container)
コード例 #2
0
ファイル: testPlace.py プロジェクト: haart/Eos
 def testHolderOntoHolderFailure(self):
     container = self.container
     fitMock = self.fitMock
     holder1 = Holder()
     holder2 = Holder()
     # Function which raises error only when holder2 is passed,
     # in the rest of cases processing is done as usual
     def raiseOnHolder2(holder):
         if holder is holder2:
             raise HolderAddError(holder)
         else:
             self.assertIn(holder, self.container)
     container.append(holder1)
     self.assertIs(container[0], holder1)
     self.assertEqual(len(container), 1)
     self.assertEqual(len(fitMock.mock_calls), 1)
     fitMock._addHolder.side_effect = raiseOnHolder2
     self.assertRaises(ValueError, container.place, 0, holder2)
     # Make sure old holder is still there
     self.assertEqual(len(fitMock.mock_calls), 4)
     self.assertEqual(fitMock.method_calls[1], call._removeHolder(holder1))
     self.assertEqual(fitMock.method_calls[2], call._addHolder(holder2))
     self.assertEqual(fitMock.method_calls[3], call._addHolder(holder1))
     self.assertEqual(len(container), 1)
     self.assertIs(container[0], holder1)
     container.remove(holder1)
     self.assertBuffersEmpty(container)
コード例 #3
0
ファイル: testUnordered.py プロジェクト: haart/Eos
 def testAddRemoveHolder(self):
     container = self.container
     fitMock = self.fitMock
     holder1 = Holder()
     holder2 = Holder()
     self.assertEqual(len(fitMock.mock_calls), 0)
     container.add(holder1)
     self.assertEqual(len(fitMock.mock_calls), 1)
     self.assertEqual(fitMock.method_calls[0], call._addHolder(holder1))
     container.add(holder2)
     self.assertEqual(len(fitMock.mock_calls), 2)
     self.assertEqual(fitMock.method_calls[1], call._addHolder(holder2))
     container.remove(holder1)
     self.assertEqual(len(fitMock.mock_calls), 3)
     self.assertEqual(fitMock.method_calls[2], call._removeHolder(holder1))
     container.remove(holder2)
     self.assertEqual(len(fitMock.mock_calls), 4)
     self.assertEqual(fitMock.method_calls[3], call._removeHolder(holder2))
     self.assertBuffersEmpty(container)
コード例 #4
0
ファイル: testRemove.py プロジェクト: bastianh/Eos
 def testHolder(self):
     container = self.container
     fitMock = self.fitMock
     holder1 = Holder()
     holder2 = Holder()
     container.append(holder1)
     container.append(holder2)
     self.assertEqual(len(container), 2)
     self.assertEqual(len(fitMock.mock_calls), 2)
     container.remove(holder1)
     self.assertEqual(len(fitMock.mock_calls), 3)
     self.assertEqual(fitMock.method_calls[2], call._removeHolder(holder1))
     self.assertEqual(len(container), 1)
     self.assertIs(container[0], holder2)
     container.remove(holder2)
     self.assertEqual(len(fitMock.mock_calls), 4)
     self.assertEqual(fitMock.method_calls[3], call._removeHolder(holder2))
     self.assertEqual(len(container), 0)
     self.assertBuffersEmpty(container)
コード例 #5
0
ファイル: testFree.py プロジェクト: bastianh/Eos
 def testHolderAfterNones(self):
     container = self.container
     fitMock = self.fitMock
     holder1 = Holder()
     holder2 = Holder()
     holder3 = Holder()
     container.append(holder1)
     container.place(3, holder2)
     container.place(6, holder3)
     self.assertEqual(len(container), 7)
     self.assertIs(container[0], holder1)
     self.assertIsNone(container[1])
     self.assertIsNone(container[2])
     self.assertIs(container[3], holder2)
     self.assertIsNone(container[4])
     self.assertIsNone(container[5])
     self.assertIs(container[6], holder3)
     self.assertEqual(len(fitMock.mock_calls), 3)
     container.free(holder2)
     self.assertEqual(len(fitMock.mock_calls), 4)
     self.assertEqual(fitMock.method_calls[3], call._removeHolder(holder2))
     self.assertEqual(len(container), 7)
     self.assertIs(container[0], holder1)
     self.assertIsNone(container[1])
     self.assertIsNone(container[2])
     self.assertIsNone(container[3])
     self.assertIsNone(container[4])
     self.assertIsNone(container[5])
     self.assertIs(container[6], holder3)
     self.assertEqual(len(fitMock.mock_calls), 4)
     container.free(holder3)
     self.assertEqual(len(fitMock.mock_calls), 5)
     self.assertEqual(fitMock.method_calls[4], call._removeHolder(holder3))
     self.assertEqual(len(container), 1)
     self.assertIs(container[0], holder1)
     container.free(holder1)
     self.assertBuffersEmpty(container)