本文整理汇总了Python中base.User类的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_group
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)
示例2: test_patch_group_remove_user
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'], [])
示例3: test_patch_group_add_site
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)
示例4: test_update_invited_user
def test_update_invited_user(self):
#self.start_smtp()
bob = User(self.email)
res1 = bob.invite()
res2 = bob.update(status="active")
self.assertEqual(res2.json()['user']['status'], 'active')
self.assertEqual(res1.json()['user']['status'], 'invited')
示例5: init_data
def init_data():
"""Fish data for project"""
db.drop_all()
db.create_all()
user = User(username='John Doe', email='[email protected]', password='test')
user.save()
示例6: test_update_user
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")
示例7: test_get_all_groups
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'])
示例8: test_create_duplicate_group
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')
示例9: test_get_group
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)
示例10: test_login_non_active_user
def test_login_non_active_user(self):
bob = User(self.email)
res1 = bob.create()
# change user to banned
res2 = bob.update(status="banned")
res3 = bob.login()
self.assertEqual(res3.json()['success'], False)
self.assertEqual(res3.json()['reason'], 'banned')
示例11: init_data
def init_data():
"""Fish data for project"""
db.drop_all()
db.create_all()
admin = User(
username=app.config["ADMIN_USERNAME"], email=app.config["ADMIN_EMAIL"], password=app.config["ADMIN_PASSWORD"]
)
admin.save()
示例12: test_get_all_users
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
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_sender_not_found
def test_sender_not_found(self):
recipient = User(self.random_email(), name="Alice")
recipient.invite()
invite = Invite(self.email, recipient.email)
res = invite.create()
# sender self.email has not yet been created in minion
self.assertEqual(res.json()['success'], False)
self.assertEqual(res.json()['reason'], 'sender-not-found-in-user-record')
示例15: test_delete_user
def test_delete_user(self):
# Create a user
bob = User(self.email)
r = bob.create()
j = r.json()
self.assertEqual(True, j['success'])
# Delete the user
r = bob.delete()
self.assertEqual({'success': True}, r.json())
# Make sure the user is gone
r = bob.delete()
self.assertEqual({'success': False, 'reason': 'no-such-user'}, r.json())