def test_declare_permission_section(monkeypatch): monkeypatch.setattr(permissions, "permission_section_registry", permissions.PermissionSectionRegistry()) assert "bla" not in permissions.permission_section_registry config.declare_permission_section("bla", u"bla perm", do_sort=False) assert "bla" in permissions.permission_section_registry section = permissions.permission_section_registry["bla"]() assert section.title == u"bla perm" assert section.sort_index == 50 assert section.do_sort is False
def test_declare_permission(monkeypatch): monkeypatch.setattr(permissions, "permission_section_registry", permissions.PermissionSectionRegistry()) assert "bla" not in permissions.permission_section_registry config.declare_permission_section("bla", u"bla perm", do_sort=False) assert "bla" in permissions.permission_section_registry monkeypatch.setattr(permissions, "permission_registry", permissions.PermissionRegistry()) assert "bla.blub" not in permissions.permission_registry config.declare_permission("bla.blub", u"bla perm", u"descrrrrr", ["admin"]) assert "bla.blub" in permissions.permission_registry permission = permissions.permission_registry["bla.blub"]() assert permission.section == permissions.permission_section_registry["bla"] assert permission.name == "bla.blub" assert permission.title == u"bla perm" assert permission.description == "descrrrrr" assert permission.defaults == ["admin"]