def test_errMsg(self): """DupChecker errMsg should return useful error message""" d = DupChecker(lwu, 'Test') self.assertEqual(d.errMsg(['a', 'b', 'c']), '') self.assertEqual( d.errMsg(['a', 'A', 'b']), "DupChecker 'Test' found the following possible duplicates. If these metadata should have the same name, please correct.:\nGroup\tOriginal names\na\ta, A\n" )
def test_call(self): """DupChecker call should report dups""" d = DupChecker(lwu) self.assertEqual(d(['a', 'b', 'c']), {}) self.assertEqual(d(['a', 'a', 'b']), {'a': ['a', 'a']}) self.assertEqual(d(['a', 'A', 'b']), {'a': ['a', 'A']}) self.assertEqual(d(['AA', 'A_a', 'b']), {'aa': ['AA', 'A_a']}) d2 = DupChecker() self.assertEqual(d2(['a', 'b']), {}) self.assertEqual(d2(['a', 'A']), {}) self.assertEqual(d2(['a', 'a']), {'a': ['a', 'a']}) d3 = DupChecker(lwu, allow_exact_dup=True) self.assertEqual(d3(['a', 'b', 'c']), {}) self.assertEqual(d3(['a', 'a', 'b']), {}) self.assertEqual(d3(['a', 'A', 'b']), {'a': ['a', 'A']}) self.assertEqual(d3(['AA', 'A_a', 'b']), {'aa': ['AA', 'A_a']})
def test_dupIndices(self): """DupChecker dupIndices should report dup indices""" d = DupChecker(lwu) self.assertEqual(d.dupIndices(['a', 'b', 'c']), {}) self.assertEqual(d.dupIndices(['a', 'a', 'b']), {'a': [0, 1]}) self.assertEqual(d.dupIndices(['a', 'A', 'b']), {'a': [0, 1]}) self.assertEqual(d.dupIndices(['AA', 'A_a', 'b']), {'aa': [0, 1]}) d2 = DupChecker() self.assertEqual(d2.dupIndices(['a', 'b']), {}) self.assertEqual(d2.dupIndices(['a', 'A']), {}) self.assertEqual(d2.dupIndices(['a', 'a']), {'a': [0, 1]}) d3 = DupChecker(lwu, allow_exact_dup=True) self.assertEqual(d3.dupIndices(['a', 'b', 'c']), {}) self.assertEqual(d3.dupIndices(['a', 'a', 'b']), {}) self.assertEqual(d3.dupIndices(['a', 'A', 'b']), {'a': [0, 1]}) self.assertEqual(d3.dupIndices(['AA', 'A_a', 'b']), {'aa': [0, 1]})
def test_init(self): """DupChecker init should occur without errors""" d = DupChecker(lwu) self.assertEqual(d.Name, None) self.assertEqual(d.CanonicalF, lwu)
def test_dupIndices(self): """DupChecker dupIndices should report dup indices""" d = DupChecker(lwu) self.assertEqual(d.dupIndices(['a','b','c']), {}) self.assertEqual(d.dupIndices(['a','a','b']), {'a':[0,1]}) self.assertEqual(d.dupIndices(['a','A','b']), {'a':[0,1]}) self.assertEqual(d.dupIndices(['AA','A_a','b']), {'aa':[0,1]}) d2 = DupChecker() self.assertEqual(d2.dupIndices(['a','b']),{}) self.assertEqual(d2.dupIndices(['a','A']),{}) self.assertEqual(d2.dupIndices(['a','a']),{'a':[0,1]}) d3 = DupChecker(lwu, allow_exact_dup=True) self.assertEqual(d3.dupIndices(['a','b','c']), {}) self.assertEqual(d3.dupIndices(['a','a','b']), {}) self.assertEqual(d3.dupIndices(['a','A','b']), {'a':[0,1]}) self.assertEqual(d3.dupIndices(['AA','A_a','b']), {'aa':[0,1]})
def test_errMsg(self): """DupChecker errMsg should return useful error message""" d = DupChecker(lwu, 'Test') self.assertEqual(d.errMsg(['a','b','c']), '') self.assertEqual(d.errMsg(['a','A','b']), "DupChecker 'Test' found the following possible duplicates. If these metadata should have the same name, please correct.:\nGroup\tOriginal names\na\ta, A\n")