本文整理汇总了Python中base.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base.User
的用法示例。
在下文中一共展示了User.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_not_used_invitation
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import get [as 别名]
def test_delete_not_used_invitation(self):
recipient = User(self.random_email())
recipient.invite()
sender = User(self.random_email())
sender.create()
invite = Invite(sender.email, recipient.email)
res1 = invite.create()
invite_id = res1.json()["invite"]["id"]
# create a group in minion that includes the recipient (bug#175)
group = Group(self.group_name, users=[recipient.email])
group.create()
# ensure now the recipient is part of the new group
res2 = recipient.get()
self.assertEqual(res2.json()['user']['groups'], [group.group_name])
# also, this user is still marked as "invited"
self.assertEqual(res2.json()['user']['status'], 'invited')
# admin deletes this invitation off minion
res3 = invite.delete(invite_id)
self.assertEqual(res3.json()["success"], True)
# since invitation is gone, user should be gone too
res4 = recipient.get()
self.assertEqual(res4.json()['success'], False)
self.assertEqual(res4.json()['reason'], 'no-such-user')
# recipient is also gone from any group association
res5 = group.get()
self.assertEqual(res5.json()['group']['users'], [])
示例2: test_decline_invite
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import get [as 别名]
def test_decline_invite(self):
recipient = User(self.random_email())
recipient.invite()
sender = User(self.random_email())
sender.create()
invite = Invite(sender.email, recipient.email)
res1 = invite.create()
invite_id = res1.json()["invite"]["id"]
# create a group in minion that includes the recipient (bug#175)
group = Group(self.group_name, users=[recipient.email])
group.create()
# ensure now the recipient is part of the new group
res2 = recipient.get()
self.assertEqual(res2.json()['user']['groups'], [group.group_name])
# recipient has declined the invitation
res3 = invite.update(invite_id, "decline", login=recipient.email)
self.assertEqual(res3.json()['invite']['status'], 'declined')
# when recipient declined, user account is deleted (bug #175)
res4 = recipient.get()
self.assertEqual(res4.json()['success'], False)
self.assertEqual(res4.json()['reason'], 'no-such-user')
# when recipient declined, user is also not part of a group anymore (bug #175)
res5 = group.get()
self.assertEqual(res5.json()['group']['users'], [])
示例3: test_accept_invite_with_a_different_login_email
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import get [as 别名]
def test_accept_invite_with_a_different_login_email(self):
# we allow recipient to login with a different email address.
recipient = User(self.random_email())
recipient.invite()
sender = User(self.random_email())
sender.create()
invite = Invite(sender.email, recipient.email)
res1 = invite.create()
invite_id = res1.json()["invite"]["id"]
# create a group and a site and add the recipient to the group
site = Site(self.target_url)
res2 = site.create()
# create a group in minion
group = Group(self.group_name, sites=[site.url], users=[recipient.email])
group.create()
# ensure user and site are in this new group
res3 = group.get()
self.assertEqual(res3.json()["group"]["sites"], [site.url])
self.assertEqual(res3.json()["group"]["users"], [recipient.email])
# user should have access to the group and the site
res4 = recipient.get()
self.assertEqual(res4.json()["user"]["sites"], [site.url])
self.assertEqual(res4.json()["user"]["groups"], [group.group_name])
# recipient accepts the invitation with a different login email address
actual_login = self.random_email()
recipient_2 = User(actual_login)
res5 = invite.update(invite_id, "accept", login=recipient_2.email)
self.assertEqual(res5.json()["success"], True)
# upon invitation acceptance, user status changed to active
res6 = recipient_2.get()
self.assertEqual(res6.json()['user']['email'], recipient_2.email)
self.assertEqual(res6.json()['user']['status'], 'active')
# the new email address has access to the group and site
self.assertEqual(res6.json()["user"]["groups"], [group.group_name])
self.assertEqual(res6.json()["user"]["sites"], [site.url])
# if we query the old recipient email, it should not be found
res7 = recipient.get()
self.assertEqual(res7.json()["success"], False)
self.assertEqual(res7.json()["reason"], "no-such-user")
# group should agree that user and site are still member of the group
res8 = group.get()
self.assertEqual(res8.json()["group"]["sites"], [site.url])
self.assertEqual(res8.json()["group"]["users"], [recipient_2.email])
示例4: test_update_user
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import get [as 别名]
def test_update_user(self):
group1 = Group("group1")
group2 = Group("group2")
group1.create()
group2.create()
# Create a user
bob = User(self.email, name="Bob", role="user", groups=[group1.group_name])
res2 = bob.create()
self.assertEqual(res2.json()['user']['email'], bob.email)
self.assertEqual(res2.json()['user']['groups'], [group1.group_name])
self.assertEqual(res2.json()["user"]["role"], "user")
# Update the user
res3 = bob.update(name="Bobby", role="administrator", groups=[group2.group_name])
self.assertEqual(res3.json()["success"], True)
self.assertEqual(res3.json()['user']['email'], bob.email)
self.assertEqual(res3.json()['user']['name'], bob.name)
self.assertEqual(res3.json()['user']['groups'], [group2.group_name])
self.assertEqual(res3.json()["user"]["role"], "administrator")
# Make sure the user stored in the db is correct
res4 = bob.get()
self.assertEqual(res4.json()['success'], True)
self.assertEqual(res4.json()['user']['email'], bob.email)
self.assertEqual(res4.json()['user']['name'], bob.name)
self.assertEqual(res4.json()['user']['groups'], [group2.group_name])
self.assertEqual(res4.json()['user']['role'], "administrator")
示例5: test_send_invite_with_groups_and_sites
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import get [as 别名]
def test_send_invite_with_groups_and_sites(self):
sender = User(self.email, name="Bob")
sender.create()
recipient = User(self.random_email(), name="Alice")
recipient.invite()
# create the invitation
invite = Invite(sender.email, recipient.email)
res = invite.create()
invite_id = res.json()['invite']['id']
# create a site in minion
site = Site(self.target_url)
res2 = site.create()
site_id = res2.json()["site"]["id"]
# Uncomment the following checks when #297 is resolved.
# create a group in minion
group = Group(self.group_name, sites=[site.url], users=[recipient.email])
res3 = group.create()
# site should exists in group and recipient should also be in the same group
res4 = group.get()
self.assertEqual(res4.json()['group']['users'], [recipient.email,])
res5 = site.get(site_id)
self.assertEqual(res5.json()["site"]["groups"], [group.group_name])
# finally, if we query recipient's user object, user should be in
# the group and have access to a site.
res6 = recipient.get()
self.assertEqual(res6.json()["user"]["sites"], [site.url])
self.assertEqual(res6.json()["user"]["groups"], [group.group_name])
示例6: test_delete_invite_does_not_delete_accepted_user
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import get [as 别名]
def test_delete_invite_does_not_delete_accepted_user(self):
# Delete recipient's invite does not delete the user if
# recipient has already accepted the invitation.
recipient = User(self.random_email())
recipient.invite()
sender = User(self.random_email())
sender.create()
invite = Invite(sender.email, recipient.email)
res1 = invite.create()
invite_id = res1.json()["invite"]["id"]
# accept the invitation with the same invitation email
res2 = invite.update(invite_id, "accept", login=recipient.email)
self.assertEqual(res2.json()["success"], True)
# upon invitation acceptance, user status changed to active
res3 = recipient.get()
self.assertEqual(res3.json()['user']['email'], recipient.email)
self.assertEqual(res3.json()['user']['status'], 'active')
# now admin chooses to delete the invitation
res4 = invite.delete(invite_id)
self.assertEqual(res4.json()["success"], True)
# check invitation is gone
res5 = invite.get(invite_id)
self.assertEqual(res5.json()['success'], False)
self.assertEqual(res5.json()['reason'], 'invitation-does-not-exist')
# yet, the user is still present
res6 = recipient.get()
self.assertEqual(res6.json()['success'], True)
self.assertEqual(res6.json()['user']['email'], recipient.email)
self.assertEqual(res6.json()['user']['status'], 'active')