def test_pass_through(self): cases = ['short', 'a' * 63, 'b' * 64] for name in cases: self.assertLessEqual(len(name), 64, "Sanity check for test input") expected = name actual = _truncated_unique_name(name) self.assertEqual(expected, actual)
def test_shorten(self): cases = [ 'spam_ham_eggs_foo_bar_boo_raboof_fubar_fnord_lorem_ipsum_dolor_sit', 'a'*65, ] for name in cases: self.assertGreater(len(name), 64, "Sanity check for test input") results = [] for _ in range(20): shortened = _truncated_unique_name(name) self.assertEqual(len(shortened), 64) self.assertEqual(shortened[:32], name[:32]) results.append(shortened) self.assertEqual(len(results), len(set(results)), "Expected unique names")