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


Python Permission.issubset方法代码示例

本文整理汇总了Python中flask_principal.Permission.issubset方法的典型用法代码示例。如果您正苦于以下问题:Python Permission.issubset方法的具体用法?Python Permission.issubset怎么用?Python Permission.issubset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_principal.Permission的用法示例。


在下文中一共展示了Permission.issubset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_permissions_delete

# 需要导入模块: from flask_principal import Permission [as 别名]
# 或者: from flask_principal.Permission import issubset [as 别名]
    def test_permissions_delete(self):
        self.app.config["BLOGGING_PERMISSIONS"] = True
        # Assuming "BLOGGING_PERMISSIONNAME" read failure
        # self.app.config["BLOGGING_PERMISSIONNAME"] = None
        user_id = "testuser"
        self._set_identity_loader(self.app.config.get(
            "BLOGGING_PERMISSIONNAME", "blogger"))

        with self.client:
            # Anonymous user cannot delete
            response = self.client.post("/blog/delete/%s/" % self.pids[0])
            self.assertEqual(response.status_code, 401)

            self.login(user_id)
            # non blogger cannot delete posts
            response = self.client.post("/blog/delete/%s/" % self.pids[0])
            self.assertEqual(response.status_code, 302)  # will be redirected
            self.logout()

            self.login(user_id, blogger=True)
            response = self.client.post("/blog/delete/%s/" % self.pids[0],
                                        follow_redirects=True)
            assert "Your post was successfully deleted" in str(response.data)

            # a user cannot delete another person's post
            self.assertEquals(current_user.get_id(), user_id)
            response = self.client.post("/blog/delete/%s/" % self.pids[10],
                                        follow_redirects=True)
            assert "You do not have the rights to delete this post" in \
                   str(response.data)

            test_permission = Permission(RoleNeed("testblogger"))
            blogger_permission = Permission(RoleNeed("blogger"))
            self.assertFalse(test_permission.issubset(
                self.engine.blogger_permission))
            self.assertTrue(blogger_permission.issubset(
                self.engine.blogger_permission))
开发者ID:adilosa,项目名称:Flask-Blogging,代码行数:39,代码来源:test_views.py

示例2: test_permissions_editor

# 需要导入模块: from flask_principal import Permission [as 别名]
# 或者: from flask_principal.Permission import issubset [as 别名]
    def test_permissions_editor(self):
        self.app.config["BLOGGING_PERMISSIONS"] = True
        self.app.config["BLOGGING_PERMISSIONNAME"] = "testblogger"
        user_id = "newuser"
        self._set_identity_loader(self.app.config.get(
            "BLOGGING_PERMISSIONNAME", "blogger"))

        with self.client:
            response = self.client.post("/blog/editor/")
            self.assertEqual(response.status_code, 401)

            response = self.client.post("/blog/editor/1/")
            self.assertEqual(response.status_code, 401)

            self.login(user_id)
            response = self.client.post("/blog/editor/")
            self.assertEqual(response.status_code, 302)

            response = self.client.post("/blog/editor/1/")
            self.assertEqual(response.status_code, 302)

            self.logout()

            self.login(user_id, blogger=True)
            response = self.client.post("/blog/editor/")
            self.assertEqual(response.status_code, 200)

            response = self.client.post("/blog/editor/1/")
            self.assertEqual(response.status_code, 200)

            test_permission = Permission(RoleNeed("testblogger"))
            blogger_permission = Permission(RoleNeed("blogger"))
            self.assertTrue(test_permission.issubset(
                self.engine.blogger_permission))
            self.assertFalse(blogger_permission.issubset(
                self.engine.blogger_permission))
开发者ID:adilosa,项目名称:Flask-Blogging,代码行数:38,代码来源:test_views.py

示例3: test_contains

# 需要导入模块: from flask_principal import Permission [as 别名]
# 或者: from flask_principal.Permission import issubset [as 别名]
    def test_contains(self):
        p1 = Permission(RoleNeed('boss'), RoleNeed('lackey'))
        p2 = Permission(RoleNeed('lackey'))

        assert p2.issubset(p1)
        assert p2 in p1
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py

示例4: test_permission_union_denial

# 需要导入模块: from flask_principal import Permission [as 别名]
# 或者: from flask_principal.Permission import issubset [as 别名]
 def test_permission_union_denial(self):
     p1 = Permission(('a', 'b'))
     p2 = Denial(('a', 'c'))
     p3 = p1.union(p2)
     assert p1.issubset(p3)
     assert p2.issubset(p3)
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py


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