def test_new_node(self): pos = (1, 2, 3) node1 = NodeData(1, pos, 3.4) self.assertEqual(node1.get_key(), 1) self.assertEqual(node1.get_pos(), (1, 2, 3)) self.assertEqual(node1.get_weight(), 3.4) self.assertEqual(node1.get_info(), "f") self.assertEqual(node1.get_tag(), 0) self.assertEqual(node1.get_dest(), {}) self.assertEqual(node1.get_src(), {}) node2 = NodeData(2) self.assertEqual(node2.get_key(), 2) self.assertEqual(node2.get_pos(), None) self.assertEqual(node2.get_weight(), 0.0) self.assertEqual(node2.get_info(), "f") self.assertEqual(node2.get_tag(), 0) self.assertEqual(node2.get_dest(), {}) self.assertEqual(node2.get_src(), {})
def test_add_src(self): pos = (1, 2, 3) node = NodeData(1, pos, 3.4) node.add_src(1, 3.2) node.add_src(2, 3.2) node.add_src(3, 4.5) node.add_src(4, 1.3) node_dict = node.get_src() 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)])