本文整理汇总了Python中udata.auth.login_user函数的典型用法代码示例。如果您正苦于以下问题:Python login_user函数的具体用法?Python login_user怎么用?Python login_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了login_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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
示例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
示例4: check_credentials
def check_credentials():
try:
with require_oauth.acquire() as token:
login_user(token.user)
return True
except (Unauthorized, AuthlibFlaskException):
return False
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)