Back to index

moin  1.9.0~rc2
test_lazy_config_groups.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - MoinMoin.backends.config_lazy_groups tests
00004 
00005     @copyright: 2009 by MoinMoin:DmitrijsMilajevs
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 from MoinMoin.datastruct.backends._tests import GroupsBackendTest
00010 from MoinMoin.datastruct.backends.config_lazy_groups import ConfigLazyGroups
00011 from MoinMoin.datastruct import ConfigGroups, CompositeGroups, GroupDoesNotExistError
00012 from MoinMoin._tests import wikiconfig
00013 
00014 
00015 class TestLazyConfigGroups(GroupsBackendTest):
00016 
00017     test_groups = {u'EditorGroup': [u'John', u'JoeDoe', u'Editor1'],
00018                    u'AdminGroup': [u'Admin1', u'Admin2', u'John'],
00019                    u'OtherGroup': [u'SomethingOther'],
00020                    u'EmptyGroup': []}
00021 
00022     expanded_groups = test_groups
00023 
00024     class Config(wikiconfig.Config):
00025 
00026         def groups(self, request):
00027             groups = TestLazyConfigGroups.test_groups
00028             return ConfigLazyGroups(request, groups)
00029 
00030     def test_contains_group(self):
00031         """
00032         ConfigLazyGroups can not contain other group members.
00033 
00034         This test does not make sense.
00035         """
00036 
00037 
00038 class TestCompositeAndLazyConfigGroups(GroupsBackendTest):
00039 
00040     class Config(wikiconfig.Config):
00041 
00042         def groups(self, request):
00043             config_groups = {u'EditorGroup': [u'AdminGroup', u'John', u'JoeDoe', u'Editor1', u'John'],
00044                              u'RecursiveGroup': [u'Something', u'OtherRecursiveGroup'],
00045                              u'OtherRecursiveGroup': [u'RecursiveGroup', u'Anything', u'NotExistingGroup'],
00046                              u'ThirdRecursiveGroup': [u'ThirdRecursiveGroup', u'Banana'],
00047                              u'CheckNotExistingGroup': [u'NotExistingGroup']}
00048 
00049             lazy_groups = {u'AdminGroup': [u'Admin1', u'Admin2', u'John'],
00050                            u'OtherGroup': [u'SomethingOther'],
00051                            u'EmptyGroup': []}
00052 
00053             return CompositeGroups(request,
00054                                    ConfigGroups(request, config_groups),
00055                                    ConfigLazyGroups(request, lazy_groups))
00056 
00057 
00058 coverage_modules = ['MoinMoin.datastruct.backends.config_lazy_groups']