本文整理汇总了Python中tests.factories.AuthUserFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python AuthUserFactory.build方法的具体用法?Python AuthUserFactory.build怎么用?Python AuthUserFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.AuthUserFactory
的用法示例。
在下文中一共展示了AuthUserFactory.build方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_user_can_log_in_with_a_different_account
# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import build [as 别名]
def test_user_can_log_in_with_a_different_account(self, mock_session):
# Assume that the unregistered user data is already stored in the session
mock_session.data = {
'unreg_user': {
'uid': self.user._primary_key,
'pid': self.project._primary_key,
'token': self.user.get_unclaimed_record(
self.project._primary_key)['token']
}
}
right_user = AuthUserFactory.build(fullname="Right User")
right_user.set_password('science')
right_user.save()
# User goes to the claim page, but a different user (lab_user) is logged in
lab_user = AuthUserFactory(fullname="Lab Comp")
url = self.user.get_claim_url(self.project._primary_key)
res = self.app.get(url, auth=lab_user.auth).follow(auth=lab_user.auth)
# verify that the "Claim Account" form is returned
assert_in('Claim Contributor', res.body)
# Clicks "I am not Lab Comp"
# Taken to login/register page
res2 = res.click(linkid='signOutLink', auth=lab_user.auth)
# Fills in log in form
form = res2.forms['signinForm']
form['username'] = right_user.username
form['password'] = 'science'
# submits
res3 = form.submit().follow()
# Back at claim contributor page
assert_in('Claim Contributor', res3)
# Verifies their password
form = res3.forms['claimContributorForm']
form['password'] = 'science'
form.submit()
self.project.reload()
right_user.reload()
self.user.reload()
# user is now a contributor to self.project
assert_in(right_user._primary_key, self.project.contributors)
# lab user is not a contributor
assert_not_in(lab_user._primary_key, self.project.contributors)
示例2: test_user_config_get
# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import build [as 别名]
def test_user_config_get(self):
url = api_url_for('dataverse_user_config_get')
new_user = AuthUserFactory.build()
res = self.app.get(url, auth=new_user.auth)
result = res.json.get('result')
assert_false(result['userHasAuth'])
assert_in('hosts', result)
assert_in('create', result['urls'])
# userHasAuth is true with external accounts
new_user.external_accounts.add(create_external_account())
new_user.save()
res = self.app.get(url, auth=self.user.auth)
result = res.json.get('result')
assert_true(result['userHasAuth'])
示例3: setUp
# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import build [as 别名]
def setUp(self):
super(TestUserUpdate, self).setUp()
self.user_one = AuthUserFactory.build(
fullname='Martin Luther King Jr.',
given_name='Martin',
family_name='King',
suffix='Jr.',
social=dict(
github='userOneGithub',
scholar='userOneScholar',
personal='http://www.useronepersonalwebsite.com',
twitter='userOneTwitter',
linkedIn='userOneLinkedIn',
impactStory='userOneImpactStory',
orcid='userOneOrcid',
researcherId='userOneResearcherId'
)
)
self.user_one.save()
self.user_one_url = "/v2/users/{}/".format(self.user_one._id)
self.user_two = AuthUserFactory()
self.user_two.save()
self.new_user_one_data = {
'id': self.user_one._id,
'fullname': 'el-Hajj Malik el-Shabazz',
'given_name': 'Malcolm',
'middle_names': 'Malik el-Shabazz',
'family_name': 'X',
'suffix': 'Sr.',
'gitHub': 'newGitHub',
'scholar': 'newScholar',
'personal_website': 'http://www.newpersonalwebsite.com',
'twitter': 'http://www.newpersonalwebsite.com',
'linkedIn': 'newLinkedIn',
'impactStory': 'newImpactStory',
'orcid': 'newOrcid',
'researcherId': 'newResearcherId',
}
示例4: setUp
# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import build [as 别名]
def setUp(self):
super(TestExceptionFormatting, self).setUp()
self.user = AuthUserFactory.build(
fullname="Martin Luther King Jr.",
given_name="Martin",
family_name="King",
suffix="Jr.",
social=dict(
github="userOneGithub",
scholar="userOneScholar",
personal="http://www.useronepersonalwebsite.com",
twitter="userOneTwitter",
linkedIn="userOneLinkedIn",
impactStory="userOneImpactStory",
orcid="userOneOrcid",
researcherId="userOneResearcherId",
),
)
self.url = "/{}users/{}/".format(API_BASE, self.user._id)
self.user_two = AuthUserFactory()
示例5: setUp
# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import build [as 别名]
def setUp(self):
super(TestExceptionFormatting, self).setUp()
self.user = AuthUserFactory.build(
fullname='Martin Luther King Jr.',
given_name='Martin',
family_name='King',
suffix='Jr.',
social=dict(
github='userOneGithub',
scholar='userOneScholar',
personal='http://www.useronepersonalwebsite.com',
twitter='userOneTwitter',
linkedIn='userOneLinkedIn',
impactStory='userOneImpactStory',
orcid='userOneOrcid',
researcherId='userOneResearcherId'
)
)
self.url = '/{}users/{}/'.format(API_BASE, self.user._id)
self.user_two = AuthUserFactory()
示例6: create_user
# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import build [as 别名]
def create_user(self):
return AuthUserFactory.build()