def __init__(self, focused_update, **kwargs): og_data = { "type": "article", "url": make_event_url(c.liveupdate_event._id), "description": trunc_string( focused_update.body.strip(), MAX_DESCRIPTION_LENGTH), "image": static("liveupdate-logo.png"), "image:width": "300", "image:height": "300", "site_name": "reddit", } LiveUpdateEventPage.__init__( self, og_data=og_data, **kwargs )
def test_really_long_words(self): truncated = utils.trunc_string('ThisIsALongWord', 10) self.assertEqual(truncated, 'ThisIsA...')
def test_word_breaks(self): truncated = utils.trunc_string('two words', 6) self.assertEqual(truncated, 'two...')
def test_suffix(self): truncated = utils.trunc_string('two words', 6, '') self.assertEqual(truncated, 'two')
def test_empty_string(self): truncated = utils.trunc_string('', 80) self.assertEqual(truncated, '')
def test_short_enough(self): truncated = utils.trunc_string('short string', 80) self.assertEqual(truncated, 'short string')