本文整理汇总了Python中base.User.create方法的典型用法代码示例。如果您正苦于以下问题:Python User.create方法的具体用法?Python User.create怎么用?Python User.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base.User
的用法示例。
在下文中一共展示了User.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_send_invite_with_groups_and_sites
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [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])
示例2: test_get_all_groups
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_get_all_groups(self):
bob = User(self.email)
bob.create()
group = Group(self.group_name)
res1 = group.create()
res2 = Groups().get()
self.assertEqual(res2.json()['groups'][0], res1.json()['group'])
示例3: test_delete_group
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_delete_group(self):
bob = User(self.email)
bob.create()
group = Group(self.group_name)
group.create()
res = group.delete()
self.assertEqual(res.json()['success'], True)
示例4: test_patch_group_remove_user
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_patch_group_remove_user(self):
bob = User(self.email)
bob.create()
group = Group(self.group_name, users=[bob.email])
res1 = group.create()
res2 = group.update(remove_users=[bob.email])
self.assertEqual(res2.json()['group']['users'], [])
示例5: test_delete_not_used_invitation
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [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'], [])
示例6: test_decline_invite
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [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'], [])
示例7: test_post_invite
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_post_invite(self):
sender = User(self.email, name="Bob")
sender.create()
recipient = User(self.random_email(), name="Alice")
recipient.invite()
invite = Invite(sender.email, recipient.email)
res = invite.create()
self.assertEqual(res.json()["success"], True)
expected_inner_keys = ("id", "recipient", "sender", "sent_on", \
"accepted_on", "sender_name", "recipient_name", \
"status", "expire_on", "max_time_allowed", "notify_when")
self.assertEqual(set(res.json()['invite'].keys()),
set(expected_inner_keys))
self.assertEqual(res.json()['invite']['recipient'], recipient.email)
self.assertEqual(res.json()['invite']['sender'], sender.email)
self.assertEqual(res.json()['invite']['recipient_name'], recipient.name)
self.assertEqual(res.json()['invite']['sender_name'], sender.name)
self.assertEqual(True, res.json()['invite']['accepted_on'] is None)
self.assertEqual(True, res.json()['invite']['sent_on'] is not None)
self.assertEqual(True, res.json()['invite']['id'] is not None)
# issue 172
self.assertEqual(res.json()['invite']['status'], 'pending')
示例8: test_patch_group_add_site
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_patch_group_add_site(self):
bob = User(self.email)
bob.create()
group = Group(self.group_name)
res1 = group.create()
res2 = group.update(add_sites=[self.target_url])
self.assertEqual(res2.json()['group']['sites'][0], self.target_url)
示例9: test_get_all_invites
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_get_all_invites(self):
# create a couple invitations and GET /invites should
# return all the invitations in the system
recipient1 = User(self.random_email())
recipient1.invite()
recipient2 = User(self.random_email())
recipient2.invite()
recipient3 = User(self.random_email())
recipient3.invite()
sender = User(self.random_email())
sender.create()
invite1 = Invite(sender.email, recipient1.email)
invite1.create()
invite2 = Invite(sender.email, recipient2.email)
invite2.create()
invite3 = Invite(sender.email, recipient3.email)
invite3.create()
res = Invites().get()
self.assertEqual(len(res.json()['invites']), 3)
self.assertEqual(res.json()['invites'][0]['recipient'], recipient1.email)
self.assertEqual(res.json()['invites'][1]['recipient'], recipient2.email)
self.assertEqual(res.json()['invites'][2]['recipient'], recipient3.email)
示例10: test_get_group
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_get_group(self):
bob = User(self.email)
bob.create()
group = Group(self.group_name)
group.create()
res = group.get()
self.assertEqual(res.json()['group']['name'], group.group_name)
self.assertEqual(res.json()['group']['description'], group.description)
示例11: test_create_duplicate_group
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_create_duplicate_group(self):
bob = User(self.email)
bob.create()
group = Group(self.group_name)
group.create()
res = group.create()
self.assertEqual(res.json()['success'], False)
self.assertEqual(res.json()['reason'], 'group-already-exists')
示例12: test_get_all_users
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_get_all_users(self):
bob = User(self.email)
bob.create()
res = Users().get()
_expected = list(self.expected_inner_keys) + ["sites"]
self.assertEqual(set(res.json()['users'][0].keys()),
set(_expected))
self.assertEqual(1, len(res.json()['users']))
示例13: test_create_group
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_create_group(self):
bob = User(self.email)
bob.create()
group = Group(self.group_name, description=self.group_description)
res = group.create()
self.assertEqual(set(res.json().keys()), set(["success", "group"]))
self.assertEqual(set(res.json()["group"].keys()),
set(["id", "created", "name", "description", "users", "sites"]))
self.assertEqual(res.json()['group']['name'], self.group_name)
self.assertEqual(res.json()['group']['description'], self.group_description)
示例14: test_invite_an_existing_user
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [as 别名]
def test_invite_an_existing_user(self):
sender = User(self.email)
sender.create()
recipient = User(self.random_email(), name="Alice")
# don't invite, do a physical creation
recipient.create()
# try invite recipient even though recipient is an active member
invite = Invite(sender.email, recipient.email)
res = invite.create()
self.assertEqual(res.json()['success'], False)
self.assertEqual(res.json()['reason'], 'recipient-already-joined')
示例15: test_accept_invite_with_a_different_login_email
# 需要导入模块: from base import User [as 别名]
# 或者: from base.User import create [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])