def test_new_left(self): root = Node() root.set_root() left = root.new_left() self.assertTrue(root.has_left()) self.assertFalse(root.has_right()) self.assertEqual(root.left, left) self.assertEqual(left.parent, root) self.assertFalse(root.is_leaf()) self.assertFalse(left.is_root()) self.assertTrue(left.is_leaf()) self.assertEqual('left', left.position)
def test_new_right(self): root = Node() root.set_root() right = root.new_right() self.assertTrue(root.has_right()) self.assertFalse(root.has_left()) self.assertEqual(root.right, right) self.assertEqual(right.parent, root) self.assertFalse(root.is_leaf()) self.assertFalse(right.is_root()) self.assertTrue(right.is_leaf()) self.assertEqual('right', right.position)