當前位置: 首頁>>代碼示例>>Python>>正文


Python Arango.delete_user方法代碼示例

本文整理匯總了Python中arango.Arango.delete_user方法的典型用法代碼示例。如果您正苦於以下問題:Python Arango.delete_user方法的具體用法?Python Arango.delete_user怎麽用?Python Arango.delete_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在arango.Arango的用法示例。


在下文中一共展示了Arango.delete_user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: UserManagementTest

# 需要導入模塊: from arango import Arango [as 別名]
# 或者: from arango.Arango import delete_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(
#.........這裏部分代碼省略.........
開發者ID:allanino,項目名稱:python-arango,代碼行數:103,代碼來源:test_users.py


注:本文中的arango.Arango.delete_user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。