本文整理汇总了Python中pybossa.model.user.User.dictize方法的典型用法代码示例。如果您正苦于以下问题:Python User.dictize方法的具体用法?Python User.dictize怎么用?Python User.dictize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybossa.model.user.User
的用法示例。
在下文中一共展示了User.dictize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_user_public_attributes
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import dictize [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
示例2: test_domain_object_error
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import dictize [as 别名]
def test_domain_object_error(self):
"""Test DomainObject errors work."""
user = User()
user.name = "John"
d = user.dictize()
user.undictize(d)