本文整理汇总了Python中osf_tests.factories.UserFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.build方法的具体用法?Python UserFactory.build怎么用?Python UserFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osf_tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.build方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import build [as 别名]
def setUp(self):
super(TestMergingAccounts, self).setUp()
self.user = UserFactory.build()
self.user.fullname = "tess' test string"
self.user.set_password('science')
self.user.save()
self.dupe = UserFactory.build()
self.dupe.set_password('example')
self.dupe.save()
示例2: test_build_create_user_time_conflict
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import build [as 别名]
def test_build_create_user_time_conflict(self):
# Test that build and create user factories do not create conflicting usernames
# because they occured quickly
user_email_one = fake_email()
user_email_two = fake_email()
assert user_email_one != user_email_two
user_one_build = UserFactory.build()
user_two_build = UserFactory.build()
assert user_one_build.username != user_two_build.username
user_one_create = UserFactory()
user_two_create = UserFactory()
assert user_one_create.username != user_two_create.username
示例3: generate_external_user_with_resp
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import build [as 别名]
def generate_external_user_with_resp(service_url, user=True, release=True):
"""
Generate mock user, external credential and cas response for tests.
:param service_url: the service url
:param user: set to `False` if user does not exists
:param release: set to `False` if attributes are not released due to privacy settings
:return: existing user object or new user, valid external credential, valid cas response
"""
cas_resp = make_external_response(release=release)
validated_credentials = cas.validate_external_credential(cas_resp.user)
if user:
user = UserFactory.build()
user.external_identity = {
validated_credentials['provider']: {
validated_credentials['id']: 'VERIFIED'
}
}
user.save()
return user, validated_credentials, cas_resp
else:
user = {
'external_id_provider': validated_credentials['provider'],
'external_id': validated_credentials['id'],
'fullname': '',
'access_token': cas_resp.attributes['accessToken'],
'service_url': service_url,
}
return user, validated_credentials, cas_resp
示例4: test_get_user_with_wrong_password_returns_false
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import build [as 别名]
def test_get_user_with_wrong_password_returns_false(self):
user = UserFactory.build()
user.set_password('killerqueen')
assert_false(
auth.get_user(email=user.username, password='wrong')
)