本文整理匯總了Python中arango.Arango.replace_user方法的典型用法代碼示例。如果您正苦於以下問題:Python Arango.replace_user方法的具體用法?Python Arango.replace_user怎麽用?Python Arango.replace_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類arango.Arango
的用法示例。
在下文中一共展示了Arango.replace_user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: UserManagementTest
# 需要導入模塊: from arango import Arango [as 別名]
# 或者: from arango.Arango import replace_user [as 別名]
class UserManagementTest(unittest.TestCase):
def setUp(self):
self.arango = Arango()
self.username = generate_user_name(self.arango)
# Test user cleanup
self.addCleanup(self.arango.delete_user,
username=self.username, safe_delete=True)
def test_get_user(self):
self.assertEqual(
self.arango.create_user(self.username, "password"),
{"active": True, "change_password": False, "extra": {}}
)
self.assertEqual(
self.arango.user(self.username),
{"active": True, "change_password": False, "extra": {}}
)
# Retrieving a non-existing user should fail
self.assertRaises(
UserNotFoundError,
self.arango.user,
username=generate_user_name(self.arango)
)
def test_create_user(self):
self.assertEqual(
self.arango.create_user(
username=self.username,
password="password",
change_password=True,
extra={"key": "val"}
),
{
"active": True,
"change_password": True,
"extra": {"key": "val"}
}
)
self.assertIn(self.username, self.arango.users)
self.assertEqual(
self.arango.user(username=self.username),
{
"active": True,
"change_password": True,
"extra": {"key": "val"}
}
)
# Creating duplicate user should fail
self.assertRaises(
UserCreateError,
self.arango.create_user,
username=self.username,
password="password"
)
def test_update_user(self):
self.assertEqual(
self.arango.create_user(self.username, "password"),
{"active": True, "change_password": False, "extra": {}}
)
self.assertEqual(
self.arango.update_user(
username=self.username,
password="new_password",
change_password=True,
extra={"key": "val"}
),
{
"active": True,
"change_password": True,
"extra": {"key": "val"}
}
)
self.assertEqual(
self.arango.user(username=self.username),
{
"active": True,
"change_password": True,
"extra": {"key": "val"}
}
)
# Updating a non-existing user should fail
self.assertRaises(
UserUpdateError,
self.arango.update_user,
username=generate_user_name(self.arango),
password="password"
)
def test_replace_user(self):
self.arango.create_user(
username=self.username,
password="password",
change_password=True,
extra={"key": "val"}
),
self.assertEqual(
self.arango.replace_user(
#.........這裏部分代碼省略.........