def test_shortener_non_nice_custom_suffix(self): sh = Shortener() s = 'loremipsumdolorsitamet' length = 12 suffix = 'the_suffix' self.assertEqual( sh.filter('loremipsumdolorsitamet', length=length, suffix=suffix), '%s%s' % (s[:12], suffix))
def __init__(self, corparch, max_attr_list_size, empty_val_placeholder, max_attr_visible_chars): self.corparch = corparch self.max_attr_list_size = max_attr_list_size self.empty_val_placeholder = empty_val_placeholder self.databases = {} self.shorten_value = partial(Shortener().filter, nice=True) self._max_attr_visible_chars = max_attr_visible_chars
def test_shortener_non_nice_no_shortening_expected(self): sh = Shortener() s = 'lorem ipsum dolor sit amet' length = 100 self.assertEqual(sh.filter(s, length=length, nice=False), s)
def test_shortener_nice_unsplittable_string(self): sh = Shortener() s = 'loremipsumdolorsitamet' length = 12 self.assertEqual(sh.filter(s, length=length, nice=True), '%s...' % s[:length])
def test_shortener_nice_zero_length(self): sh = Shortener() s = 'lorem ipsum dolor sit amet' length = 0 self.assertEqual(sh.filter(s, length=length, nice=True), '...')
def test_shortener_non_nice(self): sh = Shortener() s = 'loremipsumdolorsitamet' length = 12 self.assertEqual(sh.filter('loremipsumdolorsitamet', length=length), '%s...' % s[:12])
def test_shortener_non_nice_custom_suffix(self): sh = Shortener() s = 'loremipsumdolorsitamet' length = 12 suffix = 'the_suffix' self.assertEqual(sh.filter('loremipsumdolorsitamet', length=length, suffix=suffix), '%s%s' % (s[:12], suffix))