def test_add_dest(self): pos = (1, 2, 3) node = NodeData(1, pos, 3.4) node.add_dest(1, 3.2) node.add_dest(2, 3.2) node.add_dest(3, 4.5) node.add_dest(4, 1.3) node_dict = node.get_dest() self.assertEqual(1 in node_dict, False) test_dict = {'2': 3.2, '3': 4.5, '4': 1.3} for k, v in node_dict.items(): self.assertEqual(v, test_dict[str(k)])
def test_has_dest(self): pos = (1, 2, 3) node = NodeData(1, pos, 3.4) node.add_dest(1, 3.2) node.add_dest(2, 3.2) node.add_dest(3, 4.5) node.add_dest(4, 1.3) test_list = [1, 2, 3, 4, 5] for k in test_list: if k == 1 or k == 5: self.assertEqual(node.has_dest(k), False) else: self.assertEqual(node.has_dest(k), True)
def test_get_edge_weight(self): pos = (1, 2, 3) node = NodeData(1, pos, 3.4) node.add_dest(1, 3.2) node.add_dest(2, 3.2) node.add_dest(3, 4.5) node.add_dest(4, 1.3) node.add_dest(5, 3.4) node.add_dest(6, 2.3) test_dict = {'1': None, '2': 3.2, '3': 4.5, '4': 1.3, '5': 3.4, '6': 2.3} for k, v in test_dict.items(): self.assertEqual(node.getWeight(int(k)), v)
def test_remove_dest(self): pos = (1, 2, 3) node = NodeData(1, pos, 3.4) node.add_dest(2, 3.2) node.add_dest(3, 4.5) node.add_dest(4, 1.3) node.add_dest(5, 3.4) node.add_dest(6, 2.3) test_dict = {'2': True, '3': False, '4': True, '5': False, '6': True} for k in test_dict.keys(): self.assertEqual(node.has_dest(int(k)), True) node.remove_dest(3) node.remove_dest(5) for k, v in test_dict.items(): self.assertEqual(node.has_dest(int(k)), v) self.assertEqual(node.remove_dest(1), False)