本文整理汇总了Python中osf.models.OSFUser.create_confirmed方法的典型用法代码示例。如果您正苦于以下问题:Python OSFUser.create_confirmed方法的具体用法?Python OSFUser.create_confirmed怎么用?Python OSFUser.create_confirmed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osf.models.OSFUser
的用法示例。
在下文中一共展示了OSFUser.create_confirmed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
# 需要导入模块: from osf.models import OSFUser [as 别名]
# 或者: from osf.models.OSFUser import create_confirmed [as 别名]
def setUpClass(cls):
super(TestVarnish, cls).setUpClass()
username = uuid.uuid4()
cls.user = OSFUser.create_confirmed(
username='{}@mail.com'.format(str(username)),
password='password',
fullname='Mocha Test User')
cls.user.save()
cls.authorization = HTTPBasicAuth(cls.user.username, 'password')
small = 5
large = 10
components = [[[range(small, random.randint(small, large))
for x in range(small, random.randint(small, large))]
for y in range(small, random.randint(small, large))]
for z in range(small, random.randint(small, large))]
number_of_projects = random.randint(1, 11)
number_of_tags = random.randint(1, 11)
number_of_users = random.randint(1, 11)
for i in range(number_of_projects):
name = ''
create_fake_project(cls.user, number_of_users,
random.choice(['public', 'private']),
components, name, number_of_tags, None, False)
示例2: test_registered_user_csl
# 需要导入模块: from osf.models import OSFUser [as 别名]
# 或者: from osf.models.OSFUser import create_confirmed [as 别名]
def test_registered_user_csl(self):
# Tests the csl name for a registered user
user = OSFUser.create_confirmed(
username=fake_email(), password='foobar', fullname=fake.name()
)
if user.is_registered:
assert bool(
user.csl_name() ==
{
'given': user.csl_given_name,
'family': user.family_name,
}
)
示例3: get_or_create_user
# 需要导入模块: from osf.models import OSFUser [as 别名]
# 或者: from osf.models.OSFUser import create_confirmed [as 别名]
def get_or_create_user(fullname, address, reset_password=True, is_spam=False):
"""
Get or create user by fullname and email address.
:param str fullname: user full name
:param str address: user email address
:param boolean reset_password: ask user to reset their password
:param bool is_spam: user flagged as potential spam
:return: tuple of (user, created)
"""
from osf.models import OSFUser
user = get_user(email=address)
if user:
return user, False
else:
password = str(uuid.uuid4())
user = OSFUser.create_confirmed(address, password, fullname)
if reset_password:
user.verification_key_v2 = generate_verification_key(verification_type='password')
if is_spam:
user.save() # need to save in order to add a tag
user.add_system_tag('is_spam')
return user, True