本文整理汇总了Python中flaskbb.forum.models.Category.get_forums方法的典型用法代码示例。如果您正苦于以下问题:Python Category.get_forums方法的具体用法?Python Category.get_forums怎么用?Python Category.get_forums使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flaskbb.forum.models.Category
的用法示例。
在下文中一共展示了Category.get_forums方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_category_get_forums
# 需要导入模块: from flaskbb.forum.models import Category [as 别名]
# 或者: from flaskbb.forum.models.Category import get_forums [as 别名]
def test_category_get_forums(forum, user):
category = forum.category
with current_app.test_request_context():
# Test with logged in user
login_user(user)
assert current_user.is_authenticated
cat, forums = Category.get_forums(category.id, current_user)
# Check if it is a list because in a category there are normally more
# than one forum in it (not in these tests)
assert isinstance(forums, list) is True
assert forums == [(forum, None)]
assert cat == category
# Test the same thing with a logged out user
logout_user()
assert not current_user.is_authenticated
cat, forums = Category.get_forums(category.id, current_user)
# Check if it is a list because in a category there are normally more
# than one forum in it (not in these tests)
assert isinstance(forums, list) is True
assert forums == [(forum, None)]
assert cat == category
示例2: get
# 需要导入模块: from flaskbb.forum.models import Category [as 别名]
# 或者: from flaskbb.forum.models.Category import get_forums [as 别名]
def get(self, category_id, slug=None):
category, forums = Category.get_forums(
category_id=category_id, user=real(current_user)
)
return render_template(
"forum/category.html", forums=forums, category=category
)