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


Python UserFactory.set_password方法代码示例

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

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

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

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

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

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


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