本文整理汇总了Python中osf_tests.factories.UserFactory.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.set_password方法的具体用法?Python UserFactory.set_password怎么用?Python UserFactory.set_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osf_tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.set_password方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_fake_user
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import set_password [as 别名]
def create_fake_user():
email = fake_email()
name = fake.name()
user = UserFactory(username=email, fullname=name,
is_registered=True, emails=[email],
date_registered=fake.date_time(tzinfo=pytz.UTC),
)
user.set_password('faker123')
user.save()
logger.info('Created user: {0} <{1}>'.format(user.fullname, user.username))
return user
示例2: TestDisabledUser
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import set_password [as 别名]
class TestDisabledUser(OsfTestCase):
def setUp(self):
super(TestDisabledUser, self).setUp()
self.user = UserFactory()
self.user.set_password('Korben Dallas')
self.user.is_disabled = True
self.user.save()
def test_profile_disabled_returns_401(self):
res = self.app.get(self.user.url, expect_errors=True)
assert_equal(res.status_code, 410)
示例3: test_password_change_sends_email
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import set_password [as 别名]
def test_password_change_sends_email(self, mock_mail):
user = UserFactory()
user.set_password('killerqueen')
user.save()
assert_equal(len(mock_mail.call_args_list), 1)
empty, kwargs = mock_mail.call_args
kwargs['user'].reload()
assert_equal(empty, ())
assert_equal(kwargs, {
'user': user,
'mimetype': 'plain',
'mail': mails.PASSWORD_RESET,
'to_addr': user.username,
})
示例4: test_password_change_sends_email
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import set_password [as 别名]
def test_password_change_sends_email(self, mock_mail):
user = UserFactory()
user.set_password('killerqueen')
user.save()
assert_equal(len(mock_mail.call_args_list), 1)
empty, kwargs = mock_mail.call_args
kwargs['user'].reload()
assert_equal(empty, ())
assert_equal(kwargs, {
'user': user,
'mimetype': 'html',
'mail': mails.PASSWORD_RESET,
'to_addr': user.username,
'can_change_preferences': False,
'osf_contact_email': settings.OSF_CONTACT_EMAIL,
})
示例5: SessionUtilsTestCase
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import set_password [as 别名]
class SessionUtilsTestCase(DbTestCase):
def setUp(self, *args, **kwargs):
super(SessionUtilsTestCase, self).setUp(*args, **kwargs)
self.user = UserFactory()
# Ensure usable password
self.user.set_password('usablepassword')
def tearDown(self, *args, **kwargs):
super(SessionUtilsTestCase, self).tearDown(*args, **kwargs)
User.remove()
Session.remove()
def test_remove_session_for_user(self):
SessionFactory(user=self.user)
# sanity check
assert Session.find().count() == 1
utils.remove_sessions_for_user(self.user)
assert Session.find().count() == 0
SessionFactory()
SessionFactory(user=self.user)
# sanity check
assert Session.find().count() == 2
utils.remove_sessions_for_user(self.user)
assert Session.find().count() == 1
def test_password_change_clears_sessions(self):
SessionFactory(user=self.user)
SessionFactory(user=self.user)
SessionFactory(user=self.user)
assert Session.find().count() == 3
self.user.set_password('killerqueen')
assert Session.find().count() == 0
def test_remove_session(self):
session = SessionFactory(user=self.user)
assert Session.find().count() == 1
utils.remove_session(session)
assert Session.find().count() == 0
示例6: user_one
# 需要导入模块: from osf_tests.factories import UserFactory [as 别名]
# 或者: from osf_tests.factories.UserFactory import set_password [as 别名]
def user_one(self):
user = UserFactory()
user.set_password('password1')
user.auth = (user.username, 'password1')
user.save()
return user