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)])
def test_has_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) test_list = [1, 2, 3, 4, 5] for k in test_list: if k == 1 or k == 5: self.assertEqual(node.has_src(k), False) else: self.assertEqual(node.has_src(k), True)
def test_remove_src(self): pos = (1, 2, 3) node = NodeData(1, pos, 3.4) node.add_src(2, 3.2) node.add_src(3, 4.5) node.add_src(4, 1.3) node.add_src(5, 3.4) node.add_src(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_src(int(k)), True) node.remove_src(3) node.remove_src(5) for k, v in test_dict.items(): self.assertEqual(node.has_src(int(k)), v) self.assertEqual(node.remove_src(1), False)