def test_insertPreOrderWithRootAndLeftRightNodes(self):
     tree = AVLTree()
     tree.insert(4)
     tree.insert(3)
     tree.insert(5)
     nodes = tree.preorder_traversal()
     self.assertEqual(nodes, [4, 3, 5])
 def test_rightRotationOnRoot(self):
     tree = AVLTree()
     tree.insert(3)
     tree.insert(2)
     tree.insert(1)
     tree.root = tree.right_rotation(tree.root)
     nodes = tree.preorder_traversal()
     self.assertEqual(nodes, [2, 1, 3])
 def test_insertPreOrderWithRootAndLeftRightNodesWithLevel1Children(self):
     tree = AVLTree()
     tree.insert(4)
     tree.insert(3)
     tree.insert(1)
     tree.insert(2)
     tree.insert(5)
     nodes = tree.preorder_traversal()
     self.assertEqual(nodes, [4, 3, 1, 2, 5])
 def test_traversalWithNoRoot(self):
     tree = AVLTree()
     nodes = tree.preorder_traversal()
     self.assertEqual(nodes, [])
 def test_insertPreOrderTreeWithRootLetter(self):
     tree = AVLTree()
     tree.insert('a')
     nodes = tree.preorder_traversal()
     self.assertEqual(nodes, ['a'])
 def test_rightRotationNoRoot(self):
     tree = AVLTree()
     tree.right_rotation(tree.root)
     nodes = tree.preorder_traversal()
     self.assertEqual(nodes, [])
 def test_insertPreOrderTreeWithRoot(self):
     tree = AVLTree()
     tree.insert(4)
     nodes = tree.preorder_traversal()
     self.assertEqual(nodes, [4])