本文整理汇总了Python中pybossa.model.user.User.public_attributes方法的典型用法代码示例。如果您正苦于以下问题:Python User.public_attributes方法的具体用法?Python User.public_attributes怎么用?Python User.public_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybossa.model.user.User
的用法示例。
在下文中一共展示了User.public_attributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_users_page_returns_fields
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import public_attributes [as 别名]
def test_get_users_page_returns_fields(self):
user = UserFactory.create()
TaskRunFactory.create(user=user)
fields = User.public_attributes()
users = cached_users.get_users_page(1)
for field in fields:
assert field in users[0].keys(), field
assert len(users[0].keys()) == len(fields)
示例2: test_get_leaderboard_returns_fields
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import public_attributes [as 别名]
def test_get_leaderboard_returns_fields(self):
"""Test CACHE USERS get_leaderboard returns user fields"""
user = UserFactory.create()
TaskRunFactory.create(user=user)
fields = User.public_attributes()
update_leaderboard()
leaderboard = cached_users.get_leaderboard(1)
for field in fields:
assert field in leaderboard[0].keys(), field
assert len(leaderboard[0].keys()) == len(fields)
示例3: test_user_public_attributes
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import public_attributes [as 别名]
def test_user_public_attributes(self):
"""Test public attributes works."""
user = User(
email_addr="[email protected]",
name="johndoe",
pro=1,
fullname="John Doe",
locale="en")
public_attributes = ['created', 'name', 'fullname', 'locale', 'info',
'task_runs', 'registered_ago', 'rank', 'score']
user.set_password("juandiso")
assert public_attributes.sort() == user.public_attributes().sort()
data = user.to_public_json()
err_msg = "There are some keys that should not be public"
assert data.keys().sort() == public_attributes.sort(), err_msg
all_attributes = user.dictize().keys()
s = set(public_attributes)
private_attributes = [x for x in all_attributes if x not in s]
for attr in private_attributes:
err_msg = "This attribute should be private %s" % attr
assert data.get(attr) is None, err_msg