def testInsertWithManyChilds(self): node = Node() self.assertEqual(len(node.getNormalChilds()), 0) for i in range(0, 200): node.append(Node()) insertNode = Node() self.assertEqual(len(node.getNormalChilds()), 200) self.assertEqual(len(insertNode.getNormalChilds()), 0) node.insert(insertNode) self.assertEqual(len(node.getNormalChilds()), 1) self.assertEqual(len(insertNode.getNormalChilds()), 200)
def testInsert(self): node = Node() self.assertEqual(len(node.getNormalChilds()), 0) childNode1 = Node() node.insert(childNode1) self.assertIn(childNode1, node.getNormalChilds()) self.assertEqual(childNode1.getParent(), node) self.assertEqual(len(node.getNormalChilds()), 1) childNode2 = Node() node.insert(childNode2) self.assertIn(childNode1, childNode2.getNormalChilds()) self.assertNotIn(childNode1, node.getNormalChilds()) self.assertIn(childNode2, node.getNormalChilds()) self.assertEqual(childNode1.getParent(), childNode2) self.assertEqual(childNode2.getParent(), node) self.assertEqual(len(node.getNormalChilds()), 1) self.assertEqual(len(childNode1.getNormalChilds()), 0) self.assertEqual(len(childNode2.getNormalChilds()), 1)