本文整理匯總了Python中base.User.update方法的典型用法代碼示例。如果您正苦於以下問題:Python User.update方法的具體用法?Python User.update怎麽用?Python User.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類base.User
的用法示例。
在下文中一共展示了User.update方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_update_invited_user
# 需要導入模塊: from base import User [as 別名]
# 或者: from base.User import update [as 別名]
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')
示例2: test_update_user
# 需要導入模塊: from base import User [as 別名]
# 或者: from base.User import update [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")
示例3: test_login_non_active_user
# 需要導入模塊: from base import User [as 別名]
# 或者: from base.User import update [as 別名]
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')