当前位置: 首页>>代码示例>>Python>>正文


Python Arango.replace_user方法代码示例

本文整理汇总了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(
#.........这里部分代码省略.........
开发者ID:allanino,项目名称:python-arango,代码行数:103,代码来源:test_users.py


注:本文中的arango.Arango.replace_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。