def test_add_neighbor(self): print('Test: test_add_neighbor') n, n1 = Node(0), Node(1) print('Test: Invalid input') self.assertRaises(ValueError, n.add_neighbor, None) self.assertRaises(ValueError, n.add_neighbor, n) print('Test: general case') n.add_neighbor(n1) self.assertEqual(n.neighbors[0][0].key, n1.key) print('Success: test_add_neighbor')
def test_remove_neighbor(self): print('Test: test_remove_neighbor') n, n1 = Node(0), Node(1) print('Test: remove a non-existent node') self.assertRaises(ValueError, n.remove_neighbor, 1) print('Test: general case') n.add_neighbor(n1) self.assertEqual(n.neighbors[0][0].key, n1.key) n.remove_neighbor(1) self.assertEqual(len(n.neighbors), 0) print('Success: test_remove_neighbor')