

def test_content_subreddit_from_name(reddit, terminal):
    name = '/r/python'
    content = SubredditContent.from_name(reddit, name, terminal.loader)
    assert (content.name == '/r/python')
    assert (content.order is None)
    name = 'python/top/'
    content = SubredditContent.from_name(reddit, name, terminal.loader)
    assert (content.name == '/r/python')
    assert (content.order == 'top')
    name = '/r/python/top'
    content = SubredditContent.from_name(reddit, name, terminal.loader, order='new')
    assert (content.name == '/r/python')
    assert (content.order == 'new')
    name = '/r/python/fake'
    with terminal.loader():
        SubredditContent.from_name(reddit, name, terminal.loader)
    assert isinstance(terminal.loader.exception, exceptions.SubredditError)
    name = '/r/front/rising'
    content = SubredditContent.from_name(reddit, name, terminal.loader)
    assert (content.name == '/r/front')
    assert (content.order == 'rising')
    SubredditContent.from_name(reddit, 'front', terminal.loader, query='pea')
    SubredditContent.from_name(reddit, 'python', terminal.loader, query='pea')

dataset/ETHPy150Open michael-lazar/rtv/tests/test_content.py test_content_subreddit_from_name/original