当前位置: 首页>>代码示例>>Python>>正文


Python SubredditContent.from_name方法代码示例

本文整理汇总了Python中rtv.content.SubredditContent.from_name方法的典型用法代码示例。如果您正苦于以下问题:Python SubredditContent.from_name方法的具体用法?Python SubredditContent.from_name怎么用?Python SubredditContent.from_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rtv.content.SubredditContent的用法示例。


在下文中一共展示了SubredditContent.from_name方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_content_subreddit_from_name

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
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

    # Can submit without the /r/ and with the order in the name
    name = 'python/top/'
    content = SubredditContent.from_name(reddit, name, terminal.loader)
    assert content.name == '/r/python'
    assert content.order == 'top'

    # Explicit order trumps implicit
    name = '/r/python/top'
    content = SubredditContent.from_name(
        reddit, name, terminal.loader, order='new')
    assert content.name == '/r/python'
    assert content.order == 'new'

    # Invalid order raises an exception
    name = '/r/python/fake'
    with terminal.loader():
        SubredditContent.from_name(reddit, name, terminal.loader)
    assert isinstance(terminal.loader.exception, exceptions.SubredditError)

    # Front page alias
    name = '/r/front/rising'
    content = SubredditContent.from_name(reddit, name, terminal.loader)
    assert content.name == '/r/front'
    assert content.order == 'rising'

    # Queries
    SubredditContent.from_name(reddit, 'front', terminal.loader, query='pea')
    SubredditContent.from_name(reddit, 'python', terminal.loader, query='pea')
开发者ID:rpesche,项目名称:rtv,代码行数:37,代码来源:test_content.py

示例2: test_content_subreddit_from_name_invalid

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_from_name_invalid(prompt, reddit, terminal):

    with terminal.loader():
        SubredditContent.from_name(reddit, prompt, terminal.loader)
    assert isinstance(terminal.loader.exception, praw.errors.InvalidSubreddit)
    # Must always have an argument because it gets displayed
    assert terminal.loader.exception.args[0]
开发者ID:mardiqwop,项目名称:rtv,代码行数:9,代码来源:test_content.py

示例3: test_content_subreddit_multireddit

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_multireddit(reddit, terminal):

    name = '/r/python+linux'
    content = SubredditContent.from_name(reddit, name, terminal.loader)
    assert content.name == '/r/python+linux'

    # Invalid multireddit
    name = '/r/a+b'
    with terminal.loader():
        SubredditContent.from_name(reddit, name, terminal.loader)
    assert isinstance(terminal.loader.exception, praw.errors.NotFound)
开发者ID:prabhath6,项目名称:rtv,代码行数:13,代码来源:test_content.py

示例4: test_content_subreddit_saved

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_saved(reddit, oauth, refresh_token, terminal):

    # Not logged in
    with terminal.loader():
        SubredditContent.from_name(reddit, '/u/saved', terminal.loader)
    assert isinstance(terminal.loader.exception, exceptions.AccountError)

    # Logged in
    oauth.config.refresh_token = refresh_token
    oauth.authorize()
    with terminal.loader():
        SubredditContent.from_name(reddit, '/u/saved', terminal.loader)
开发者ID:prabhath6,项目名称:rtv,代码行数:14,代码来源:test_content.py

示例5: test_content_subreddit_from_name_authenticated

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_from_name_authenticated(
        prompt, name, order, reddit, terminal, oauth, refresh_token):

    with pytest.raises(exceptions.AccountError):
        SubredditContent.from_name(reddit, prompt, terminal.loader)

    # Login and try again
    oauth.config.refresh_token = refresh_token
    oauth.authorize()

    content = SubredditContent.from_name(reddit, prompt, terminal.loader)
    assert content.name == name
    assert content.order == order
开发者ID:prabhath6,项目名称:rtv,代码行数:15,代码来源:test_content.py

示例6: test_content_subreddit_me

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_me(reddit, oauth, refresh_token, terminal):

    # Not logged in
    with terminal.loader():
        SubredditContent.from_name(reddit, '/u/me', terminal.loader)
    assert isinstance(terminal.loader.exception, exceptions.AccountError)

    # Logged in
    oauth.config.refresh_token = refresh_token
    oauth.authorize()
    with terminal.loader():
        SubredditContent.from_name(reddit, '/u/me', terminal.loader)

    # If there is no submitted content, an error should be raised
    if terminal.loader.exception:
        assert isinstance(terminal.loader.exception, exceptions.SubredditError)
开发者ID:prabhath6,项目名称:rtv,代码行数:18,代码来源:test_content.py

示例7: test_content_subreddit_from_name_order

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_from_name_order(reddit, terminal):

    # Explicit order trumps implicit
    name = '/r/python/top'
    content = SubredditContent.from_name(
        reddit, name, terminal.loader, order='new')
    assert content.name == '/r/python'
    assert content.order == 'new'
开发者ID:prabhath6,项目名称:rtv,代码行数:10,代码来源:test_content.py

示例8: test_content_subreddit_random

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_random(reddit, terminal):

    name = '/r/random'
    content = SubredditContent.from_name(reddit, name, terminal.loader)
    assert content.name.startswith('/r/')
    assert content.name != name
开发者ID:prabhath6,项目名称:rtv,代码行数:8,代码来源:test_content.py

示例9: test_content_subreddit_from_name_query

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_from_name_query(prompt, query, reddit, terminal):

    SubredditContent.from_name(reddit, prompt, terminal.loader, query=query)
开发者ID:prabhath6,项目名称:rtv,代码行数:5,代码来源:test_content.py

示例10: test_content_subreddit_from_name_invalid

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_from_name_invalid(prompt, reddit, terminal):

    with terminal.loader():
        SubredditContent.from_name(reddit, prompt, terminal.loader)
    assert isinstance(terminal.loader.exception, praw.errors.InvalidSubreddit)
开发者ID:prabhath6,项目名称:rtv,代码行数:7,代码来源:test_content.py

示例11: test_content_subreddit_from_name

# 需要导入模块: from rtv.content import SubredditContent [as 别名]
# 或者: from rtv.content.SubredditContent import from_name [as 别名]
def test_content_subreddit_from_name(prompt, name, order, reddit, terminal):

    content = SubredditContent.from_name(reddit, prompt, terminal.loader)
    assert content.name == name
    assert content.order == order
开发者ID:prabhath6,项目名称:rtv,代码行数:7,代码来源:test_content.py


注:本文中的rtv.content.SubredditContent.from_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。