• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python auth.login_user函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中udata.auth.login_user函数的典型用法代码示例。如果您正苦于以下问题:Python login_user函数的具体用法?Python login_user怎么用?Python login_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了login_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_with_valid_organization

    def test_with_valid_organization(self):
        Ownable, OwnableForm = self.factory()
        user = UserFactory()
        member = Member(user=user, role='editor')
        org = OrganizationFactory(members=[member])

        login_user(user)

        form = OwnableForm(MultiDict({
            'organization': str(org.id)
        }))

        self.assertEqual(form.owner.data, user)
        self.assertEqual(form.organization.data, org)

        form.validate()
        self.assertEqual(form.errors, {})

        self.assertIsNone(form.owner.data)
        self.assertEqual(form.organization.data, org)

        ownable = Ownable()
        form.populate_obj(ownable)
        self.assertIsNone(ownable.owner)
        self.assertEqual(ownable.organization, org)
开发者ID:anukat2015,项目名称:udata,代码行数:25,代码来源:test_publish_as_field.py


示例2: test_org_admin_can_accept_transfer

    def test_org_admin_can_accept_transfer(self):
        owner = UserFactory()
        admin = UserFactory()
        org = OrganizationFactory(members=[Member(user=admin, role='admin')])
        subject = VisibleDatasetFactory(owner=owner)
        transfer = TransferFactory(owner=owner,
                                   recipient=org,
                                   subject=subject)

        owner.reload()  # Needs updated metrics
        assert owner.metrics['datasets'] == 1

        org.reload()  # Needs updated metrics
        assert org.metrics['datasets'] == 0

        admin.reload()  # Needs updated metrics
        assert admin.metrics['datasets'] == 0

        login_user(admin)
        transfer = accept_transfer(transfer)

        assert transfer.status == 'accepted'

        subject.reload()
        assert subject.organization == org
        assert subject.owner is None

        org.reload()
        assert org.metrics['datasets'] == 1

        admin.reload()
        assert admin.metrics['datasets'] == 0

        owner.reload()
        assert owner.metrics['datasets'] == 0
开发者ID:odtvince,项目名称:udata,代码行数:35,代码来源:test_transfer.py


示例3: test_recipient_user_can_accept_transfer

    def test_recipient_user_can_accept_transfer(self):
        owner = UserFactory()
        recipient = UserFactory()
        subject = VisibleDatasetFactory(owner=owner)
        transfer = TransferFactory(owner=owner,
                                   recipient=recipient,
                                   subject=subject)

        owner.reload()  # Needs updated metrics
        assert owner.metrics['datasets'] == 1

        recipient.reload()  # Needs updated metrics
        assert recipient.metrics['datasets'] == 0

        login_user(recipient)
        transfer = accept_transfer(transfer)

        assert transfer.status == 'accepted'

        subject.reload()
        assert subject.owner == recipient

        recipient.reload()
        assert recipient.metrics['datasets'] == 1

        owner.reload()
        assert owner.metrics['datasets'] == 0
开发者ID:odtvince,项目名称:udata,代码行数:27,代码来源:test_transfer.py


示例4: check_credentials

def check_credentials():
    try:
        with require_oauth.acquire() as token:
            login_user(token.user)
        return True
    except (Unauthorized, AuthlibFlaskException):
        return False
开发者ID:odtvince,项目名称:udata,代码行数:7,代码来源:oauth2.py


示例5: test_request_transfer_owner_to_user

    def test_request_transfer_owner_to_user(self):
        user = UserFactory()
        dataset = VisibleDatasetFactory(owner=user)
        recipient = UserFactory()
        comment = faker.sentence()

        login_user(user)
        self.assert_transfer_started(dataset, user, recipient, comment)
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:test_transfer.py


示例6: test_request_transfer_user_to_organization

    def test_request_transfer_user_to_organization(self):
        user = UserFactory()
        dataset = DatasetFactory(owner=user)
        recipient = OrganizationFactory()
        comment = faker.sentence()

        login_user(user)
        self.assert_transfer_started(dataset, user, recipient, comment)
开发者ID:michelbl,项目名称:udata,代码行数:8,代码来源:test_transfer.py


示例7: test_request_transfer_to_self

    def test_request_transfer_to_self(self):
        user = UserFactory()
        dataset = DatasetFactory(owner=user)
        comment = faker.sentence()

        login_user(user)
        with self.assertRaises(ValueError):
            self.assert_transfer_started(dataset, user, user, comment)
开发者ID:michelbl,项目名称:udata,代码行数:8,代码来源:test_transfer.py


示例8: test_request_transfer_not_authorized_not_owner

    def test_request_transfer_not_authorized_not_owner(self):
        user = UserFactory()
        dataset = DatasetFactory(owner=UserFactory())
        recipient = UserFactory()
        comment = faker.sentence()

        login_user(user)
        with self.assertRaises(PermissionDenied):
            request_transfer(dataset, recipient, comment)
开发者ID:michelbl,项目名称:udata,代码行数:9,代码来源:test_transfer.py


示例9: test_initial_value

    def test_initial_value(self):
        Ownable, OwnableForm = self.factory()
        user = UserFactory()

        login_user(user)
        ownable = Ownable(owner=user)

        form = OwnableForm(None, obj=ownable)
        self.assertEqual(form.owner.data, user)
开发者ID:odtvince,项目名称:udata,代码行数:9,代码来源:test_current_user_field.py


示例10: test_request_transfer_organization_to_user

    def test_request_transfer_organization_to_user(self):
        user = UserFactory()
        member = Member(user=user, role='admin')
        org = OrganizationFactory(members=[member])
        dataset = DatasetFactory(owner=user, organization=org)
        recipient = UserFactory()
        comment = faker.sentence()

        login_user(user)
        self.assert_transfer_started(dataset, org, recipient, comment)
开发者ID:michelbl,项目名称:udata,代码行数:10,代码来源:test_transfer.py


示例11: test_request_transfer_to_same_organization

    def test_request_transfer_to_same_organization(self):
        user = UserFactory()
        member = Member(user=user, role='admin')
        org = OrganizationFactory(members=[member])
        dataset = DatasetFactory(owner=user, organization=org)
        comment = faker.sentence()

        login_user(user)

        with self.assertRaises(ValueError):
            self.assert_transfer_started(dataset, org, org, comment)
开发者ID:michelbl,项目名称:udata,代码行数:11,代码来源:test_transfer.py


示例12: test_with_initial_organization_and_user_logged

    def test_with_initial_organization_and_user_logged(self):
        Ownable, OwnableForm = self.factory()
        user = UserFactory()
        org = OrganizationFactory()
        ownable = Ownable(organization=org)

        login_user(user)

        form = OwnableForm(None, ownable)
        self.assertIsNone(form.owner.data)
        self.assertEqual(form.organization.data, org)
开发者ID:anukat2015,项目名称:udata,代码行数:11,代码来源:test_publish_as_field.py


示例13: test_request_transfer_not_authorized_not_admin

    def test_request_transfer_not_authorized_not_admin(self):
        user = UserFactory()
        member = Member(user=user, role='editor')
        org = OrganizationFactory(members=[member])
        dataset = DatasetFactory(owner=user, organization=org)
        recipient = UserFactory()
        comment = faker.sentence()

        login_user(user)
        with self.assertRaises(PermissionDenied):
            request_transfer(dataset, recipient, comment)
开发者ID:michelbl,项目名称:udata,代码行数:11,代码来源:test_transfer.py


示例14: test_org_editor_cant_accept_transfer

    def test_org_editor_cant_accept_transfer(self):
        owner = UserFactory()
        editor = UserFactory()
        org = OrganizationFactory(members=[Member(user=editor, role='editor')])
        subject = VisibleDatasetFactory(organization=org)
        transfer = TransferFactory(owner=owner,
                                   recipient=org,
                                   subject=subject)

        login_user(editor)
        with pytest.raises(PermissionDenied):
            accept_transfer(transfer)
开发者ID:odtvince,项目名称:udata,代码行数:12,代码来源:test_transfer.py


示例15: test_empty_values

    def test_empty_values(self):
        Ownable, OwnableForm = self.factory()
        user = UserFactory()

        login_user(user)

        form = OwnableForm()
        self.assertEqual(form.owner.data, user)

        ownable = Ownable()
        form.populate_obj(ownable)
        self.assertEqual(ownable.owner, user)
开发者ID:odtvince,项目名称:udata,代码行数:12,代码来源:test_current_user_field.py


示例16: test_with_user_not_found

    def test_with_user_not_found(self):
        Ownable, OwnableForm = self.factory()
        user = UserFactory()

        login_user(user)

        form = OwnableForm(MultiDict({
            'owner': str(ObjectId())
        }))

        form.validate()
        self.assertIn('owner', form.errors)
        self.assertEqual(len(form.errors['owner']), 1)
开发者ID:odtvince,项目名称:udata,代码行数:13,代码来源:test_current_user_field.py


示例17: test_with_invalid_data

    def test_with_invalid_data(self):
        Ownable, OwnableForm = self.factory()
        user = UserFactory()

        login_user(user)

        form = OwnableForm(MultiDict({
            'owner': str('wrongwith12c')
        }))

        form.validate()
        self.assertIn('owner', form.errors)
        self.assertEqual(len(form.errors['owner']), 1)
开发者ID:odtvince,项目名称:udata,代码行数:13,代码来源:test_current_user_field.py


示例18: test_class_shortcut

    def test_class_shortcut(self):
        '''It should emit a signal on new activity'''
        self.emitted = False
        self.login()
        with self.app.app_context():
            login_user(self.user)
            with FakeActivity.on_new.connected_to(self.check_emitted):
                FakeActivity.emit(self.fake)

        self.assertTrue(self.emitted)

        self.assertEqual(Activity.objects(related_to=self.fake).count(), 1)
        self.assertEqual(Activity.objects(actor=self.user).count(), 1)
开发者ID:guillo-w,项目名称:udata,代码行数:13,代码来源:test_activity.py


示例19: test_add_badge_with_logged_user

    def test_add_badge_with_logged_user(self):
        '''It should track the user that add a badge'''
        user = UserFactory()
        fake = Fake.objects.create()

        login_user(user)
        result = fake.add_badge(TEST)

        self.assertEqual(len(fake.badges), 1)
        badge = fake.badges[0]
        self.assertEqual(result, badge)
        self.assertEqual(badge.kind, TEST)
        self.assertIsNotNone(badge.created)
        self.assertEqual(badge.created_by, user)
开发者ID:odtvince,项目名称:udata,代码行数:14,代码来源:test_model.py


示例20: test_empty_values_logged

    def test_empty_values_logged(self):
        Ownable, OwnableForm = self.factory()
        user = UserFactory()

        login_user(user)

        form = OwnableForm()

        self.assertEqual(form.owner.data, user)
        self.assertIsNone(form.organization.data)

        ownable = Ownable()
        form.populate_obj(ownable)
        self.assertEqual(ownable.owner, user)
        self.assertIsNone(ownable.organization)
开发者ID:anukat2015,项目名称:udata,代码行数:15,代码来源:test_publish_as_field.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python current_user._get_current_object函数代码示例发布时间:2022-05-27
下一篇:
Python api.validate函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap