当前位置: 首页>>代码示例>>Python>>正文


Python UserFactory.build方法代码示例

本文整理汇总了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()
开发者ID:erinspace,项目名称:osf.io,代码行数:11,代码来源:test_webtests.py

示例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
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:16,代码来源:test_utils.py

示例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
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:31,代码来源:test_cas_authentication.py

示例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')
     )
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:8,代码来源:test_auth.py


注:本文中的osf_tests.factories.UserFactory.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。