Esempio n. 1
0
    def test_set_get(self):
        model = role.RoleModel()
        model.permissions = [
            {"name": "api", "permissions": ["view_user", "create_user"]}]

        assert model.permissions == [{
            "name": "api", "permissions": ["create_user", "view_user"]
        }]
Esempio n. 2
0
    def test_has_permissions(self):
        model = role.RoleModel()
        model.permissions = [
            {"name": "api", "permissions": ["view_user", "create_user"]}]
        assert not model.has_permission("api", "delete_user")

        model.add_permissions("api", ["delete_user"])
        assert model.has_permission("api", "delete_user")
Esempio n. 3
0
    def test_remove_permissions(self):
        model = role.RoleModel()
        model.permissions = [
            {"name": "api", "permissions": ["view_user", "create_user"]}]
        model.remove_permissions("api", ["create_user"])

        assert model.permissions == [
            {"name": "api", "permissions": ["view_user"]}]
Esempio n. 4
0
 def test_set_unknown_permissions(self):
     with pytest.raises(ValueError):
         role.RoleModel().permissions = [{
             "name": "api",
             "permissions": ["1"]
         }]
Esempio n. 5
0
 def test_set_unknown_permissions(self):
     role.RoleModel().permissions = [
         {"name": "api", "permissions": ["1"]}]