Ejemplo n.º 1
0
def test_subreddit_page_construct(reddit, terminal, config, oauth):
    window = terminal.stdscr.subwin

    with terminal.loader():
        page = SubredditPage(reddit, terminal, config, oauth, "/r/python")
    assert terminal.loader.exception is None
    page.draw()

    # Title
    title = "/r/python".encode("utf-8")
    window.addstr.assert_any_call(0, 0, title)

    # Banner
    menu = ("[1]hot         " "[2]top         " "[3]rising         " "[4]new         " "[5]controversial").encode(
        "utf-8"
    )
    window.addstr.assert_any_call(0, 0, menu)

    # Submission
    text = page.content.get(0)["split_title"][0].encode("utf-8")
    window.subwin.addstr.assert_any_call(0, 1, text, 2097152)

    # Cursor should have been drawn
    assert window.subwin.chgat.called

    # Reload with a smaller terminal window
    terminal.stdscr.ncols = 20
    terminal.stdscr.nlines = 10
    with terminal.loader():
        page = SubredditPage(reddit, terminal, config, oauth, "/r/python")
    assert terminal.loader.exception is None
    page.draw()
Ejemplo n.º 2
0
def test_subreddit_page_construct(reddit, terminal, config, oauth):
    window = terminal.stdscr.subwin

    with terminal.loader():
        page = SubredditPage(reddit, terminal, config, oauth, '/r/python')
    assert terminal.loader.exception is None
    page.draw()

    # Title
    title = '/r/python'.encode('utf-8')
    window.addstr.assert_any_call(0, 0, title)

    # Banner
    menu = ('[1]hot         '
            '[2]top         '
            '[3]rising         '
            '[4]new         '
            '[5]controversial').encode('utf-8')
    window.addstr.assert_any_call(0, 0, menu)

    # Submission
    text = page.content.get(0)['split_title'][0].encode('utf-8')
    window.subwin.addstr.assert_any_call(0, 1, text, 2097152)

    # Cursor should have been drawn
    assert window.subwin.chgat.called

    # Reload with a smaller terminal window
    terminal.stdscr.ncols = 20
    terminal.stdscr.nlines = 10
    with terminal.loader():
        page = SubredditPage(reddit, terminal, config, oauth, '/r/python')
    assert terminal.loader.exception is None
    page.draw()
Ejemplo n.º 3
0
def test_subreddit_page_construct(reddit, terminal, config, oauth):
    window = terminal.stdscr.subwin

    with terminal.loader():
        page = SubredditPage(reddit, terminal, config, oauth, '/r/python')
    assert terminal.loader.exception is None
    page.draw()

    # Title
    title = '/r/python'.encode('utf-8')
    window.addstr.assert_any_call(0, 0, title)

    # Submission
    text = page.content.get(0)['split_title'][0].encode('utf-8')
    window.subwin.addstr.assert_any_call(0, 1, text, 2097152)

    # Cursor should have been drawn
    assert window.subwin.chgat.called

    # Reload with a smaller terminal window
    terminal.stdscr.ncols = 20
    terminal.stdscr.nlines = 10
    with terminal.loader():
        page = SubredditPage(reddit, terminal, config, oauth, '/r/python')
    assert terminal.loader.exception is None
    page.draw()
Ejemplo n.º 4
0
def subreddit_page(reddit, terminal, config, oauth):
    subreddit = '/r/python'

    with terminal.loader():
        page = SubredditPage(reddit, terminal, config, oauth, subreddit)
    assert not terminal.loader.exception
    page.draw()
    return page
Ejemplo n.º 5
0
def subreddit_page(reddit, terminal, config, oauth):
    subreddit = '/r/python'

    with terminal.loader():
        page = SubredditPage(reddit, terminal, config, oauth, subreddit)
    assert not terminal.loader.exception
    page.draw()
    return page