annotate MoinMoin/datastruct/backends/_tests/test_wiki_groups.py @ 5787:00704da830ea

Fixed bug in groups formatter which caused the last list item to be not in the group. Removed some tests that didn't make sense for me, added some new to detect this bug.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 02 Aug 2011 23:52:32 +0200
parents c299e8ece712
children
rev   line source
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
2 """
4832
f83b7b0b59c4 Groups2009: groups and dicts were merged inside of the datastruct module.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4830
diff changeset
3 MoinMoin - MoinMoin.backends.wiki_group tests
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
4
4832
f83b7b0b59c4 Groups2009: groups and dicts were merged inside of the datastruct module.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4830
diff changeset
5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>,
f83b7b0b59c4 Groups2009: groups and dicts were merged inside of the datastruct module.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4830
diff changeset
6 2007 by MoinMoin:ThomasWaldmann
f83b7b0b59c4 Groups2009: groups and dicts were merged inside of the datastruct module.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4830
diff changeset
7 2008 by MoinMoin:MelitaMihaljevic
f83b7b0b59c4 Groups2009: groups and dicts were merged inside of the datastruct module.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4830
diff changeset
8 2009 by MoinMoin:DmitrijsMilajevs
f83b7b0b59c4 Groups2009: groups and dicts were merged inside of the datastruct module.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4830
diff changeset
9 @license: GNU GPL, see COPYING for details.
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
10 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
11
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
12 from py.test import raises
4789
31e0bbcf4fa6 Groups2009: Group objects of wiki_group backend expands themselves during the initialization.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4787
diff changeset
13 import re, shutil
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
14
4836
8be26b0ebc96 Groups2009: Tests for the WikiDicts and WikiGroups use default values for the group_manager_init and dict_manager_init. pep8 fixes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4833
diff changeset
15 from MoinMoin.datastruct.backends._tests import GroupsBackendTest
4832
f83b7b0b59c4 Groups2009: groups and dicts were merged inside of the datastruct module.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4830
diff changeset
16 from MoinMoin.datastruct import WikiGroups
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
17 from MoinMoin import Page, security
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
18 from MoinMoin.PageEditor import PageEditor
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
19 from MoinMoin.user import User
4803
167db6117bb4 Groups2009: pep8 fixes and typo elimination. BaseGroup._iter optimization. Test of group names mapping was removed.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4800
diff changeset
20 from MoinMoin._tests import append_page, become_trusted, create_page, create_random_string_list, nuke_page, nuke_user, wikiconfig
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
21
4803
167db6117bb4 Groups2009: pep8 fixes and typo elimination. BaseGroup._iter optimization. Test of group names mapping was removed.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4800
diff changeset
22
4843
d8093123a1bd Groups2009: Formatter which collects group definitions from a page was moved from datastruct.backend._formatter to formatter.groups. Refinements of the formatter. TestWikiGroupPageParser was removed because it duplicates formatter's test.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4836
diff changeset
23 class TestWikiGroupBackend(GroupsBackendTest):
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
24
4859
6a7395207387 Groups2009: dicts and groups instead of group_manager_init and dict_manager_init are used.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4843
diff changeset
25 # Suppose that default configuration for the groups is used which
6a7395207387 Groups2009: dicts and groups instead of group_manager_init and dict_manager_init are used.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4843
diff changeset
26 # is WikiGroups backend.
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
27
4789
31e0bbcf4fa6 Groups2009: Group objects of wiki_group backend expands themselves during the initialization.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4787
diff changeset
28 def setup_class(self):
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
29 become_trusted(self.request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
30
4898
c299e8ece712 Groups2009: Docstring for get() for BaseDictsBackend, BaseDict and BaseGroupsBackend. Tests for get check if another default value returned for not existing keys. Typo and other refinements.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4875
diff changeset
31 for group, members in self.test_groups.iteritems():
4789
31e0bbcf4fa6 Groups2009: Group objects of wiki_group backend expands themselves during the initialization.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4787
diff changeset
32 page_text = ' * %s' % '\n * '.join(members)
31e0bbcf4fa6 Groups2009: Group objects of wiki_group backend expands themselves during the initialization.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4787
diff changeset
33 create_page(self.request, group, page_text)
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
34
4789
31e0bbcf4fa6 Groups2009: Group objects of wiki_group backend expands themselves during the initialization.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4787
diff changeset
35 def teardown_class(self):
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
36 become_trusted(self.request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
37
4800
3b05bf18c0d1 Groups2009: The BackendTest class provides basic test methods for testing backends. It should be inherited to test backends.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4796
diff changeset
38 for group in self.test_groups:
4789
31e0bbcf4fa6 Groups2009: Group objects of wiki_group backend expands themselves during the initialization.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4787
diff changeset
39 nuke_page(self.request, group)
4790
cb95dae6cbe0 Groups2009: Whitespace fix.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4789
diff changeset
40
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
41 def test_rename_group_page(self):
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
42 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
43 Tests if the groups cache is refreshed after renaming a Group page.
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
44 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
45 request = self.request
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
46 become_trusted(request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
47
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
48 page = create_page(request, u'SomeGroup', u" * ExampleUser")
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
49 page.renamePage('AnotherGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
50
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
51 result = u'ExampleUser' in request.groups[u'AnotherGroup']
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
52 nuke_page(request, u'AnotherGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
53
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
54 assert result is True
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
55
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
56 def test_copy_group_page(self):
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
57 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
58 Tests if the groups cache is refreshed after copying a Group page.
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
59 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
60 request = self.request
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
61 become_trusted(request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
62
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
63 page = create_page(request, u'SomeGroup', u" * ExampleUser")
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
64 page.copyPage(u'SomeOtherGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
65
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
66 result = u'ExampleUser' in request.groups[u'SomeOtherGroup']
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
67
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
68 nuke_page(request, u'OtherGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
69 nuke_page(request, u'SomeGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
70
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
71 assert result is True
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
72
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
73 def test_appending_group_page(self):
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
74 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
75 Test scalability by appending a name to a large list of group members.
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
76 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
77 request = self.request
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
78 become_trusted(request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
79
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
80 # long list of users
4875
28077e7631a7 group scalability test: reduced member count so test runs in acceptable time
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4859
diff changeset
81 page_content = [u" * %s" % member for member in create_random_string_list(length=15, count=1234)]
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
82 test_user = create_random_string_list(length=15, count=1)[0]
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
83 create_page(request, u'UserGroup', "\n".join(page_content))
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
84 append_page(request, u'UserGroup', u' * %s' % test_user)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
85 result = test_user in request.groups['UserGroup']
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
86 nuke_page(request, u'UserGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
87
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
88 assert result
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
89
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
90 def test_user_addition_to_group_page(self):
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
91 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
92 Test addition of a username to a large list of group members.
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
93 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
94 request = self.request
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
95 become_trusted(request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
96
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
97 # long list of users
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
98 page_content = [u" * %s" % member for member in create_random_string_list()]
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
99 create_page(request, u'UserGroup', "\n".join(page_content))
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
100
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
101 new_user = create_random_string_list(length=15, count=1)[0]
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
102 append_page(request, u'UserGroup', u' * %s' % new_user)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
103 user = User(request, name=new_user)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
104 if not user.exists():
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
105 User(request, name=new_user, password=new_user).save()
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
106
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
107 result = new_user in request.groups[u'UserGroup']
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
108 nuke_page(request, u'UserGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
109 nuke_user(request, new_user)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
110
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
111 assert result
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
112
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
113 def test_member_removed_from_group_page(self):
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
114 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
115 Tests appending a member to a large list of group members and
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
116 recreating the page without the member.
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
117 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
118 request = self.request
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
119 become_trusted(request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
120
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
121 # long list of users
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
122 page_content = [u" * %s" % member for member in create_random_string_list()]
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
123 page_content = "\n".join(page_content)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
124 create_page(request, u'UserGroup', page_content)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
125
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
126 test_user = create_random_string_list(length=15, count=1)[0]
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
127 page = append_page(request, u'UserGroup', u' * %s' % test_user)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
128
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
129 # saves the text without test_user
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
130 page.saveText(page_content, 0)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
131 result = test_user in request.groups[u'UserGroup']
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
132 nuke_page(request, u'UserGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
133
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
134 assert not result
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
135
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
136 def test_group_page_user_addition_trivial_change(self):
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
137 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
138 Test addition of a user to a group page by trivial change.
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
139 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
140 request = self.request
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
141 become_trusted(request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
142
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
143 test_user = create_random_string_list(length=15, count=1)[0]
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
144 member = u" * %s\n" % test_user
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
145 page = create_page(request, u'UserGroup', member)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
146
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
147 # next member saved as trivial change
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
148 test_user = create_random_string_list(length=15, count=1)[0]
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
149 member = u" * %s\n" % test_user
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
150 page.saveText(member, 0, trivial=1)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
151
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
152 result = test_user in request.groups[u'UserGroup']
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
153
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
154 nuke_page(request, u'UserGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
155
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
156 assert result
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
157
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
158 def test_wiki_backend_page_acl_append_page(self):
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
159 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
160 Test if the wiki group backend works with acl code.
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
161 First check acl rights of a user that is not a member of group
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
162 then add user member to a page group and check acl rights
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
163 """
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
164 request = self.request
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
165 become_trusted(request)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
166
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
167 create_page(request, u'NewGroup', u" * ExampleUser")
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
168
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
169 acl_rights = ["NewGroup:read,write"]
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
170 acl = security.AccessControlList(request.cfg, acl_rights)
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
171
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
172 has_rights_before = acl.may(request, u"AnotherUser", "read")
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
173
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
174 # update page - add AnotherUser to a page group NewGroup
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
175 append_page(request, u'NewGroup', u" * AnotherUser")
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
176
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
177 has_rights_after = acl.may(request, u"AnotherUser", "read")
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
178
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
179 nuke_page(request, u'NewGroup')
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
180
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
181 assert not has_rights_before, 'AnotherUser has no read rights because in the beginning he is not a member of a group page NewGroup'
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
182 assert has_rights_after, 'AnotherUser must have read rights because after appendage he is member of NewGroup'
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
183
5787
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
184 def test_simple_group_page(self):
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
185 """
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
186 Tests if a simple group page is evaluated correctly.
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
187 """
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
188 request = self.request
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
189 become_trusted(request)
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
190 group_name = u'SimpleGroup'
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
191 page_text = u"""\
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
192 * FirstUser
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
193 * SecondUser
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
194 * LastUser"""
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
195 page = create_page(request, group_name, page_text)
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
196 group_members = set(request.groups[group_name])
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
197 assert group_members == set([u'FirstUser', u'SecondUser', u'LastUser'])
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
198 nuke_page(request, group_name)
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
199
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
200 def test_complex_group_page(self):
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
201 """
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
202 Tests if a complex group page is evaluated correctly.
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
203 """
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
204 request = self.request
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
205 become_trusted(request)
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
206 group_name = u'ComplexGroup'
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
207 page_text = u"""\
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
208 * FirstUser
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
209 * any text
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
210 * SecondUser
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
211 * LastUser
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
212 * any text"""
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
213 page = create_page(request, group_name, page_text)
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
214 group_members = set(request.groups[group_name])
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
215 assert group_members == set([u'FirstUser', u'SecondUser', u'LastUser'])
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
216 nuke_page(request, group_name)
00704da830ea Fixed bug in groups formatter which caused the last list item to be not in the group.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4898
diff changeset
217
4832
f83b7b0b59c4 Groups2009: groups and dicts were merged inside of the datastruct module.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4830
diff changeset
218 coverage_modules = ['MoinMoin.datastruct.backends.wiki_groups']
4787
de7ca86a9f62 Groups2009: MoinMoin.groups.backends.wiki_group backend was added.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
219