def test_member_names(self): member_names = ['one', 'two', 'three'] enum = create_permission_enum('example', member_names) actual = list(enum.__members__) self.assertEqual(actual, member_names)
# -*- coding: utf-8 -*- """ byceps.blueprints.seating_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum SeatingPermission = create_permission_enum("seating", ["view"])
# -*- coding: utf-8 -*- """ byceps.blueprints.snippet_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum MountpointPermission = create_permission_enum('mountpoint', [ 'create', 'delete', ]) SnippetPermission = create_permission_enum('snippet', [ 'list', 'create', 'update', 'view_history', ])
def test_key(key): enum = create_permission_enum(key, ['some_member']) assert enum.__key__ == key
""" byceps.blueprints.admin.board.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum BoardCategoryPermission = create_permission_enum('board_category', [ 'create', 'update', 'view', ])
# -*- coding: utf-8 -*- """ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from unittest import TestCase from nose2.tools import params from byceps.blueprints.authorization.models import Permission from byceps.util.authorization import create_permission_enum ExamplePermission = create_permission_enum('example', ['one', 'two', 'three']) MultiWordPermission = create_permission_enum('multi_word', ['foo', 'bar']) class PermissionTestCase(TestCase): @params( (ExamplePermission.one, 'example.one' ), (ExamplePermission.three, 'example.three' ), (MultiWordPermission.foo, 'multi_word.foo'), ) def test_creation_from_enum_member(self, enum_member, expected): actual = Permission.from_enum_member(enum_member) self.assertEqual(actual.id, expected)
""" byceps.blueprints.orga_team_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum OrgaTeamPermission = create_permission_enum('orga_team', [ 'create', 'delete', 'list', 'administrate_memberships', ])
""" byceps.blueprints.news_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum NewsItemPermission = create_permission_enum('news_item', [ 'create', 'update', 'list', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.shop_order_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum ShopOrderPermission = create_permission_enum('shop_order', [ 'update', 'list', 'view', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.core_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum AdminPermission = create_permission_enum('admin', [ 'access', ])
""" byceps.blueprints.admin.authorization.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum RolePermission = create_permission_enum('role', [ 'assign', 'view', ])
""" byceps.blueprints.admin.jobs.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum JobsPermission = create_permission_enum('jobs', [ 'view', ])
""" byceps.blueprints.brand_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum BrandPermission = create_permission_enum('brand', [ 'create', 'view', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.orga_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum OrgaBirthdayPermission = create_permission_enum('orga_birthday', [ 'list', ]) OrgaDetailPermission = create_permission_enum('orga_detail', [ 'view', ]) OrgaTeamPermission = create_permission_enum('orga_team', [ 'create', 'delete', 'list', 'administrate_memberships', ])
""" byceps.blueprints.board.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum BoardTopicPermission = create_permission_enum('board_topic', [ 'create', 'update', 'update_of_others', 'hide', 'lock', 'move', 'pin', 'view_hidden', ]) BoardPostingPermission = create_permission_enum('board_posting', [ 'create', 'update', 'update_of_others', 'hide', 'view_hidden', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.news_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum NewsItemPermission = create_permission_enum('news_item', [ 'create', 'update', 'list', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.user_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum UserPermission = create_permission_enum('user', [ 'list', ])
""" byceps.blueprints.admin.user.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum UserPermission = create_permission_enum('user', [ 'administrate', 'create', 'set_password', 'view', ])
# -*- coding: utf-8 -*- """ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from nose2.tools import params from byceps.blueprints.authorization.registry import PermissionRegistry from byceps.util.authorization import create_permission_enum ItemPermission = create_permission_enum("item", ["view", "create", "update"]) @params( ("item.create", ItemPermission.create), # enum member exists ("item.delete", None), # enum exists, but member does not ("article.create", None), # enum does not exist ) def test_get_enum_member(permission_id, expected): registry = create_registry_with_registered_enum() assert registry.get_enum_member(permission_id) == expected @params( ({"item.create", "item.create"}, {ItemPermission.create}), # duplicates are ignored ( {"item.create", "item.update"},
""" byceps.blueprints.snippet_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum MountpointPermission = create_permission_enum('mountpoint', [ 'create', 'delete', ]) SnippetPermission = create_permission_enum('snippet', [ 'list', 'create', 'update', 'view_history', ])
""" byceps.blueprints.admin.terms.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum TermsPermission = create_permission_enum('terms', [ 'create', 'view', ])
""" byceps.blueprints.shop_article_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2018 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum ShopArticlePermission = create_permission_enum('shop_article', [ 'create', 'update', 'list', 'view', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.orga_presence.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum OrgaPresencePermission = create_permission_enum('orga_presence', [ 'list', 'update', ])
""" byceps.blueprints.admin.newsletter.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum NewsletterPermission = create_permission_enum('newsletter', [ 'export_subscribers', 'view_subscriptions', ])
""" byceps.blueprints.admin.tourney.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum TourneyCategoryPermission = create_permission_enum('tourney_category', [ 'create', 'update', 'view', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.newsletter_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum NewsletterPermission = create_permission_enum('newsletter', [ 'export_subscribers', 'view_subscriptions', ])
def test_key(self, key): enum = create_permission_enum(key, ['some_member']) self.assertEqual(enum.__key__, key)
# -*- coding: utf-8 -*- """ byceps.blueprints.ticket_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum TicketPermission = create_permission_enum('ticket', [ 'list', 'view', ])
def test_name_derivation(self, key, expected): enum = create_permission_enum(key, ['some_member']) actual = enum.some_member.__class__.__name__ self.assertEqual(actual, expected)
""" byceps.blueprints.admin.site.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum SitePermission = create_permission_enum('site', [ 'create', 'update', 'view', ])
""" byceps.blueprints.board.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum BoardTopicPermission = create_permission_enum('board_topic', [ 'create', 'update', 'update_of_others', 'hide', 'lock', 'move', 'pin', 'view_hidden', ]) BoardPostingPermission = create_permission_enum('board_posting', [ 'create', 'update', 'update_of_others', 'hide', 'view_hidden', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.party_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum PartyPermission = create_permission_enum('party', [ 'list', 'create', ])
""" byceps.blueprints.party_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum PartyPermission = create_permission_enum('party', [ 'list', 'create', 'update', ])
""" byceps.blueprints.orga_presence.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum OrgaPresencePermission = create_permission_enum('orga_presence', [ 'list', 'update', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.user_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum UserPermission = create_permission_enum("user", ["list", "view"])
""" byceps.blueprints.admin.consent.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum ConsentPermission = create_permission_enum('consent', [ 'administrate', ])
""" byceps.blueprints.admin.party.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum PartyPermission = create_permission_enum('party', [ 'create', 'update', 'view', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.shop_article_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum ShopArticlePermission = create_permission_enum('shop_article', [ 'create', 'update', 'list', 'view', ])
class PermissionRegistryTestCase(TestCase): def setUp(self): self.registry = PermissionRegistry() self.registry.register_enum(ItemPermission) def test_lookup_of_existing_enum_member(self): permission = create_permission('item.create') self.assert_get_enum_member_equals(permission, ItemPermission.create) def test_lookup_of_nonexistent_member_of_existing_enum(self): permission = create_permission('item.delete') self.assert_get_enum_member_equals(permission, None) def test_lookup_of_member_of_nonexistent_enum(self): permission = create_permission('article.create') self.assert_get_enum_member_equals(permission, None) def assert_get_enum_member_equals(self, permission, expected): actual = self.registry.get_enum_member(permission) self.assertEqual(actual, expected) ItemPermission = create_permission_enum('item', ['view', 'create', 'update']) def create_permission(id): return Permission(id=id)
""" byceps.blueprints.admin.core.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum AdminPermission = create_permission_enum('admin', [ 'access', ])
""" byceps.blueprints.shop_order_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2018 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum ShopOrderPermission = create_permission_enum('shop_order', [ 'update', 'list', 'view', ])
""" byceps.blueprints.admin_dashboard.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2018 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum AdminDashboardPermission = create_permission_enum('admin_dashboard', [ 'view_global', 'view_brand', 'view_party', ])
""" byceps.blueprints.user_badge_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2018 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum UserBadgePermission = create_permission_enum('user_badge', [ 'create', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.shop_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum ShopArticlePermission = create_permission_enum("shop_article", ["create", "update", "list", "view"]) ShopOrderPermission = create_permission_enum("shop_order", ["update", "list", "view"])
""" byceps.blueprints.orga_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2018 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum OrgaBirthdayPermission = create_permission_enum('orga_birthday', [ 'list', ]) OrgaDetailPermission = create_permission_enum('orga_detail', [ 'view', ])
""" byceps.blueprints.ticketing_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2018 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum TicketingPermission = create_permission_enum('ticketing', [ 'checkin', 'view', ])
""" byceps.blueprints.admin.news.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum NewsChannelPermission = create_permission_enum('news_channel', [ 'create', ]) NewsItemPermission = create_permission_enum('news_item', [ 'create', 'publish', 'update', 'view', 'view_draft', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.tourney_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum TourneyCategoryPermission = create_permission_enum('tourney_category', [ 'list', 'create', 'update', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.board_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum BoardCategoryPermission = create_permission_enum('board_category', [ 'create', 'update', 'list', ])
""" byceps.blueprints.authorization_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum RolePermission = create_permission_enum('role', [ 'list', 'assign', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.brand_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum BrandPermission = create_permission_enum('brand', [ 'create', 'view', ])
def test_name_derivation(key, expected): enum = create_permission_enum(key, ['some_member']) actual = enum.some_member.__class__.__name__ assert actual == expected
# -*- coding: utf-8 -*- """ byceps.blueprints.news_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum NewsItemPermission = create_permission_enum("news_item", ["create", "update", "list"])
# -*- coding: utf-8 -*- """ byceps.blueprints.authorization_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum RolePermission = create_permission_enum('role', [ 'list', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.orga_team_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum OrgaTeamPermission = create_permission_enum('orga_team', [ 'create', 'delete', 'list', 'administrate_memberships', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.admin_dashboard.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2016 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum AdminDashboardPermission = create_permission_enum('admin_dashboard', [ 'view_global', 'view_brand', 'view_party', ])
""" byceps.blueprints.seating_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2017 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum SeatingPermission = create_permission_enum('seating', [ 'view', ])
# -*- coding: utf-8 -*- """ byceps.blueprints.terms_admin.authorization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Copyright: 2006-2015 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from byceps.util.authorization import create_permission_enum TermsPermission = create_permission_enum('terms', [ 'list', 'create', ])
""" :Copyright: 2006-2019 Jochen Kupperschmidt :License: Modified BSD, see LICENSE for details. """ from unittest.mock import patch import pytest with patch('flask.current_app'): from byceps.blueprints.authorization.registry import PermissionRegistry from byceps.util.authorization import create_permission_enum ItemPermission = create_permission_enum('item', ['view', 'create', 'update']) @pytest.mark.parametrize( 'permission_id, expected', [ ('item.create', ItemPermission.create), # enum member exists ('item.delete', None), # enum exists, but member does not ('article.create', None), # enum does not exist ]) def test_get_enum_member(permission_id, expected): registry = create_registry_with_registered_enum() assert registry.get_enum_member(permission_id) == expected @pytest.mark.parametrize( 'permission_ids, expected',