Example #1
0
def get_timeline(api):
    return Timeline(
        list(reversed(list(
            Tweet(tw.user.screen_name, tw.text, tw.id)
            for tw in api.get_timeline(100)
          )))
    )
def test_it_renders_single_line_tweets():
    tweet = Tweet(
        'fooser',
        'this is a tweet',
    )

    expected = ('         ' + colored('fooser', 'green') + ' this is a tweet')
    assert expected == TweetRenderer.render(tweet)
def test_it_renders_multiline_tweets():
    tweet = Tweet(
        'fooser',
        'this is a tweet\nwith two lines',
    )

    expected = ('         ' + colored('fooser', 'green') + ' this is a tweet\n'
                '                with two lines')
    assert expected == TweetRenderer.render(tweet)
def test_it_renders_single_line_tweets():
    tweet = Tweet(
        'fooser',
        'this is a tweet',
    )

    expected = Text(
        '         ',
        Green(),
        'fooser',
        Default(),
        ' ',
        'this is a tweet',
        '\n',
    )
    assert expected == CursesTweetRenderer.render(tweet)
def test_it_underlines_selected_tweets():
    tweet = Tweet(
        'fooser',
        'this is a tweet',
    )

    expected = Text(
        '         ',
        Green(),
        'fooser',
        Default(),
        ' ',
        Default([curses.A_UNDERLINE]),
        'this is a tweet',
        Default(),
        '\n',
    )
    assert expected == CursesTweetRenderer.render(tweet, selected=True)
def test_renders_with_limited_screen_width():
    tweet_text = (
        'This is a long tweet, its 68 characters long. ZzZzZzZzZzZzZzZzZzZzZz')
    assert 68 == len(tweet_text)
    tweet = Tweet(
        'fooser',
        tweet_text,
    )
    expected = Text(
        '         ',
        Green(),
        'fooser',
        Default(),
        ' ',
        'This is a long tweet, its 68 characters long. ',
        '\n                ',
        Blue(),
        '| ',
        Default(),
        'ZzZzZzZzZzZzZzZzZzZzZz',
        '\n',
    )
    assert expected == CursesTweetRenderer.render(tweet, max_width=62)
Example #7
0
def test_it_has_text_and_author():
    tweet = Tweet('gary', 'some text', 'id')
    assert tweet.author == 'gary'
    assert tweet.text == 'some text'
    assert tweet.id == 'id'