annotate MoinMoin/_tests/test_wikidicts.py @ 3910:6fbfffffc4d1

Insert moins path more aggressively into sys.path to win the race against py.test, do insertions less often in make_test_wiki
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Thu, 31 Jul 2008 14:17:19 +0200
parents ece71db231f1
children 3f9147c23d9c 7a826f946da3
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - MoinMoin.wikidicts tests
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>,
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
6 2007 by MoinMoin:ThomasWaldmann
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
10 import py
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11 import re
3211
8a1f1a9dd37f fix. misc problems found by pydev (unused/double imports, unused attributes, ...)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2899
diff changeset
12 import shutil
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13
893
324b2948d197 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
14 from MoinMoin import wikidicts
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 from MoinMoin import Page
2878
455c3f051a2d test_wikidicts: rename Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2771
diff changeset
16 from MoinMoin.PageEditor import PageEditor
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
17 from MoinMoin.user import User
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
18 from MoinMoin._tests import append_page, become_trusted, create_page, create_random_string_list, nuke_page, nuke_user
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
20 class TestGroupPage:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 def testCamelCase(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 """ wikidicts: initFromText: CamelCase links """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 text = """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 * CamelCase
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 """
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
27 assert self.getMembers(text) == ['CamelCase']
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 def testExtendedName(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30 """ wikidicts: initFromText: extended names """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 text = """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 * extended name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33 """
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
34 assert self.getMembers(text) == ['extended name']
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36 def testExtendedLink(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37 """ wikidicts: initFromText: extended link """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 text = """
2771
1134a5cc12c2 gui converter fixes for new markup, fix/extend tests, remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
39 * [[extended link]]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
40 """
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
41 assert self.getMembers(text) == ['extended link']
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43 def testIgnoreSecondLevelList(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 """ wikidicts: initFromText: ignore non first level items """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 text = """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 * second level
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47 * third level
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 * forth level
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 * and then some...
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50 """
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
51 assert self.getMembers(text) == []
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53 def testIgnoreOther(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54 """ wikidicts: initFromText: ignore anything but first level list itmes """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55 text = """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56 = ignore this =
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 * take this
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59 Ignore previous line and this text.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 """
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
61 assert self.getMembers(text) == ['take this']
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63 def testStripWhitespace(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
64 """ wikidicts: initFromText: strip whitespace around items """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
65 text = """
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2252
diff changeset
66 * take this
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
67 """
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
68 assert self.getMembers(text) == ['take this']
893
324b2948d197 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
69
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
70 def getMembers(self, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
71 group = wikidicts.Group(self.request, '')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
72 group.initFromText(text)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
73 return group.members()
893
324b2948d197 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
74
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
75
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
76 class TestDictPage:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
77
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
78 def testGroupMembers(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79 """ wikidicts: create dict from keys and values in text """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
80 text = '''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 Text ignored
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
82 * list items ignored
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
83 * Second level list ignored
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
84 First:: first item
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
85 text with spaces:: second item
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
86
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 Empty lines ignored, so is this text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
88 Next line has key with empty value
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2252
diff changeset
89 Empty string::\x20
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
90 Last:: last item
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
91 '''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
92 d = wikidicts.Dict(self.request, '')
893
324b2948d197 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
93 d.initFromText(text)
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
94 assert d['First'] == 'first item'
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
95 assert d['text with spaces'] == 'second item'
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2252
diff changeset
96 assert d['Empty string'] == '' # XXX fails if trailing blank is missing
2247
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
97 assert d['Last'] == 'last item'
d782b0db4757 wikidicts: more comments, minor cleanup, converted tests to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
98 assert len(d) == 4
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
99
2252
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
100 class TestGroupDicts:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
101
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
102 def testSystemPagesGroupInDicts(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
103 """ wikidict: names in SystemPagesGroup should be in request.dicts
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
104
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
105 Get a list of all pages, and check that the dicts list all of them.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
106
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
107 Assume that the SystemPagesGroup is in the data or the underlay dir.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
108 """
2252
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
109 assert Page.Page(self.request, 'SystemPagesGroup').exists(), "SystemPagesGroup is missing, Can't run test"
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
110 systemPages = wikidicts.Group(self.request, 'SystemPagesGroup')
2252
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
111 #print repr(systemPages)
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
112 #print repr(self.request.dicts['SystemPagesGroup'])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
113 for member in systemPages.members():
2252
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
114 assert self.request.dicts.has_member('SystemPagesGroup', member), '%s should be in request.dict' % member
893
324b2948d197 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 0
diff changeset
115
2252
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
116 members, groups = self.request.dicts.expand_group('SystemPagesGroup')
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
117 assert 'SystemPagesInEnglishGroup' in groups
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
118 assert 'RecentChanges' in members
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
119 assert 'HelpContents' in members
ece659592dd9 wikidicts: refactoring, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2247
diff changeset
120
2878
455c3f051a2d test_wikidicts: rename Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2771
diff changeset
121 def testRenameGroupPage(self):
455c3f051a2d test_wikidicts: rename Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2771
diff changeset
122 """
455c3f051a2d test_wikidicts: rename Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2771
diff changeset
123 tests if the dict cache for groups is refreshed after renaming a Group page
455c3f051a2d test_wikidicts: rename Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2771
diff changeset
124 """
3504
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
125 request = self.request
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
126 become_trusted(request)
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
127 page = create_page(request, u'SomeGroup', u" * ExampleUser")
2878
455c3f051a2d test_wikidicts: rename Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2771
diff changeset
128 page.renamePage('AnotherGroup')
3504
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
129 group = wikidicts.Group(request, '')
3573
124d0ef138aa change page_*_regex processing, see docs/CHANGES (fixes Xapian category search for non-english)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3560
diff changeset
130 isgroup = request.cfg.cache.page_group_regexact.search
3504
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
131 grouppages = request.rootpage.getPageList(user='', filter=isgroup)
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
132 result = request.dicts.has_member(u'AnotherGroup', u'ExampleUser')
3504
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
133 nuke_page(request, u'AnotherGroup')
2878
455c3f051a2d test_wikidicts: rename Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2771
diff changeset
134
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
135 assert result is True
2878
455c3f051a2d test_wikidicts: rename Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2771
diff changeset
136
2880
6739287e65c9 test_wikidicts: copy Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2878
diff changeset
137 def testCopyGroupPage(self):
6739287e65c9 test_wikidicts: copy Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2878
diff changeset
138 """
6739287e65c9 test_wikidicts: copy Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2878
diff changeset
139 tests if the dict cache for groups is refreshed after copying a Group page
6739287e65c9 test_wikidicts: copy Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2878
diff changeset
140 """
3504
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
141 request = self.request
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
142 become_trusted(request)
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
143 page = create_page(request, u'SomeGroup', u" * ExampleUser")
2880
6739287e65c9 test_wikidicts: copy Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2878
diff changeset
144 page.copyPage(u'OtherGroup')
3504
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
145 group = wikidicts.Group(request, '')
3573
124d0ef138aa change page_*_regex processing, see docs/CHANGES (fixes Xapian category search for non-english)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3560
diff changeset
146 isgroup = request.cfg.cache.page_group_regexact.search
3504
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
147 grouppages = request.rootpage.getPageList(user='', filter=isgroup)
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
148 result = request.dicts.has_member(u'OtherGroup', u'ExampleUser')
3504
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
149 nuke_page(request, u'OtherGroup')
7ee94ad36708 tests: test page creation/deletion now done by helpers in MoinMoin._tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3503
diff changeset
150 nuke_page(request, u'SomeGroup')
2880
6739287e65c9 test_wikidicts: copy Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2878
diff changeset
151
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
152 assert result is True
2880
6739287e65c9 test_wikidicts: copy Group page test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2878
diff changeset
153
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
154 def testAppendingGroupPage(self):
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
155 """
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
156 tests scalability by appending a name to a large list of group members
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
157 """
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
158 # long list of users
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
159 page_content = [u" * %s" % member for member in create_random_string_list(length=15, count=30000)]
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
160 request = self.request
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
161 become_trusted(request)
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
162 test_user = create_random_string_list(length=15, count=1)[0]
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
163 page = create_page(request, u'UserGroup', "\n".join(page_content))
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
164 page = append_page(request, u'UserGroup', u' * %s' % test_user)
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
165 result = request.dicts.has_member('UserGroup', test_user)
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
166 nuke_page(request, u'UserGroup')
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
167
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
168 assert result is True
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
169
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
170 def testUserAppendingGroupPage(self):
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
171 """
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
172 tests appending a username to a large list of group members and user creation
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
173 """
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
174 # long list of users
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
175 page_content = [u" * %s" % member for member in create_random_string_list()]
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
176 request = self.request
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
177 become_trusted(request)
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
178 test_user = create_random_string_list(length=15, count=1)[0]
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
179 page = create_page(request, u'UserGroup', "\n".join(page_content))
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
180 page = append_page(request, u'UserGroup', u' * %s' % test_user)
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
181
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
182 # now shortly later we create a user object
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
183 user = User(request, name=test_user)
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
184 if not user.exists():
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
185 User(request, name=test_user, password=test_user).save()
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
186
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
187 result = request.dicts.has_member('UserGroup', test_user)
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
188 nuke_page(request, u'UserGroup')
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
189 nuke_user(request, test_user)
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
190
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
191 assert result is True
3557
9052c06d4ae3 test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3504
diff changeset
192
3559
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
193 def testMemberRemovedFromGroupPage(self):
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
194 """
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
195 tests appending a member to a large list of group members and recreating the page without the member
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
196 """
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
197 # long list of users
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
198 page_content = [u" * %s" % member for member in create_random_string_list()]
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
199 page_content = "\n".join(page_content)
3559
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
200 request = self.request
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
201 become_trusted(request)
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
202 test_user = create_random_string_list(length=15, count=1)[0]
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
203 page = create_page(request, u'UserGroup', page_content)
3559
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
204 page = append_page(request, u'UserGroup', u' * %s' % test_user)
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
205 # saves the text without test_user
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
206 page.saveText(page_content, 0)
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
207 result = request.dicts.has_member('UserGroup', test_user)
3559
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
208 nuke_page(request, u'UserGroup')
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
209
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
210 assert result is False
3559
8af17e0d221b test_wikidicts: refactored and added a test for removing a member from a Group page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3557
diff changeset
211
3560
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
212 def testGroupPageTrivialChange(self):
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
213 """
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
214 tests appending a username to a group page by trivial change
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
215 """
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
216 request = self.request
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
217 become_trusted(request)
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
218 test_user = create_random_string_list(length=15, count=1)[0]
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
219 member = u" * %s\n" % test_user
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
220 page = create_page(request, u'UserGroup', member)
3560
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
221 # next member saved as trivial change
3575
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
222 test_user = create_random_string_list(length=15, count=1)[0]
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
223 member = u" * %s\n" % test_user
baa5bfe1b8e1 test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3574
diff changeset
224 page.saveText(member, 0, trivial=1)
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
225 result = request.dicts.has_member('UserGroup', test_user)
3560
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
226 nuke_page(request, u'UserGroup')
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
227
3593
ece71db231f1 test_wikidicts: optimize group membership calculation
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3575
diff changeset
228 assert result is True
3560
2d9f1ae98b2a test_wikidicts: test added for trivial change
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3559
diff changeset
229
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
230 coverage_modules = ['MoinMoin.wikidicts']
3574
0b7eb697e952 test_wikidicts: PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3573
diff changeset
231