Mercurial > moin > 1.9
annotate MoinMoin/_tests/__init__.py @ 6028:1893da1d5213
userid lookup caches: use 1 on-disk cache file, update cache rather than rebuild
Before this, we maintained one cache file per attribute (e.g. name2id, openid2id,
...) - the related code did multiple passes over all user profiles to rebuild these
cache files.
Now doing a one-pass rebuild, writing all attribute -> userid mappings into
one on-disk cache file called "lookup".
Additionally to "name" and "openids", support fast lookup for "email" and "jid" also.
On profile save, we use to just kill the cache and let it rebuild. Now the cache
is read, updated and written back (which is much less expensive for wikis with more
than a few users).
Did some refactoring also, reducing duplication, breaking down the code into smaller
functions / methods.
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Wed, 12 Feb 2014 18:22:10 +0100 |
parents | 05a6897ee496 |
children |
rev | line source |
---|---|
3502
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
1 # -*- coding: iso-8859-1 -*- |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
2 """ |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
3 MoinMoin - some common code for testing |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
4 |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
5 @copyright: 2007 MoinMoin:KarolNowak, |
3948
62b9f61eb526
macro._tests: whitespace removed, docstring adjusted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3947
diff
changeset
|
6 2008 MoinMoin:ThomasWaldmann, MoinMoin:ReimarBauer |
3502
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
7 @license: GNU GPL, see COPYING for details. |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
8 """ |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
9 |
3557
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
10 import os, shutil |
3948
62b9f61eb526
macro._tests: whitespace removed, docstring adjusted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3947
diff
changeset
|
11 |
3947
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
12 from MoinMoin.parser.text import Parser |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
13 from MoinMoin.formatter.text_html import Formatter |
3557
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
14 from MoinMoin.Page import Page |
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
|
15 from MoinMoin.PageEditor import PageEditor |
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
|
16 from MoinMoin.util import random_string |
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 import caching, user |
5279
2aa43685e17b
AttachFile: added remove_attachment(), made nuke_page use it (details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
4762
diff
changeset
|
18 from MoinMoin.action import AttachFile |
3947
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
19 |
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
|
20 # Promoting the test user ------------------------------------------- |
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
|
21 # Usually the tests run as anonymous user, but for some stuff, you |
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
|
22 # need more privs... |
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
|
23 |
3503
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
24 def become_valid(request, username=u"ValidUser"): |
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
25 """ modify request.user to make the user valid. |
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
26 Note that a valid user will only be in ACL special group "Known", if |
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
27 we have a user profile for this user as the ACL system will check if |
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
28 there is a userid for this username. |
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
29 Thus, for testing purposes (e.g. if you need delete rights), it is |
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
30 easier to use become_trusted(). |
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
31 """ |
3502
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
32 request.user.name = username |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
33 request.user.may.name = username |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
34 request.user.valid = 1 |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
35 |
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
|
36 |
3502
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
37 def become_trusted(request, username=u"TrustedUser"): |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
38 """ modify request.user to make the user valid and trusted, so it is in acl group Trusted """ |
3503
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
39 become_valid(request, username) |
3502
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
40 request.user.auth_method = request.cfg.auth_methods_trusted[0] |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
41 |
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
|
42 |
3502
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
43 def become_superuser(request): |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
44 """ modify request.user so it is in the superuser list, |
3503
383fda7ebfd1
tests: add some clarifications to become_trusted/become_valid, use become_trusted instead of become_superuser when it does not need superuser permissions
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
3502
diff
changeset
|
45 also make the user valid (see notes in become_valid()), |
3502
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
46 also make the user trusted (and thus in "Trusted" ACL pseudo group). |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
47 |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
48 Note: being superuser is completely unrelated to ACL rights, |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
49 especially it is not related to ACL admin rights. |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
50 """ |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
51 su_name = u"SuperUser" |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
52 become_trusted(request, su_name) |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
53 if su_name not in request.cfg.superuser: |
02b73ceab324
tests: move code from MoinMoin._tests.common to MoinMoin._tests, rename gain_superuser_rights to become_superuser, add become_known and become_trusted
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
2006
diff
changeset
|
54 request.cfg.superuser.append(su_name) |
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
|
55 |
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:
3559
diff
changeset
|
56 def nuke_user(request, username): |
baa5bfe1b8e1
test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3559
diff
changeset
|
57 """ completely delete a 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:
3559
diff
changeset
|
58 user_dir = request.cfg.user_dir |
baa5bfe1b8e1
test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3559
diff
changeset
|
59 user_id = user.getUserId(request, username) |
baa5bfe1b8e1
test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3559
diff
changeset
|
60 # really get rid of the 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:
3559
diff
changeset
|
61 fpath = os.path.join(user_dir, user_id) |
baa5bfe1b8e1
test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3559
diff
changeset
|
62 os.remove(fpath) |
6028
1893da1d5213
userid lookup caches: use 1 on-disk cache file, update cache rather than rebuild
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
6025
diff
changeset
|
63 user.clearLookupCaches(request) |
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
|
64 |
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
|
65 # Creating and destroying test pages -------------------------------- |
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
|
66 |
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
|
67 def create_page(request, pagename, content, do_editor_backup=False): |
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
|
68 """ create a page with some content """ |
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
|
69 # make sure there is nothing already there: |
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
|
70 nuke_page(request, pagename) |
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
|
71 # now create from scratch: |
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
|
72 page = PageEditor(request, pagename, do_editor_backup=do_editor_backup) |
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
|
73 page.saveText(content, 0) |
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
|
74 return page |
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
|
75 |
3557
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
76 def append_page(request, pagename, content, do_editor_backup=False): |
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
77 """ appends some conetent to an existing page """ |
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
78 # reads the raw text of the existing page |
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
79 raw = Page(request, pagename).get_raw_body() |
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
80 # adds the new content to the old |
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
81 content = "%s\n%s\n"% (raw, content) |
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
82 page = PageEditor(request, pagename, do_editor_backup=do_editor_backup) |
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
83 page.saveText(content, 0) |
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
84 return page |
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
|
85 |
3947
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
86 def nuke_eventlog(request): |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
87 """ removes event-log file """ |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
88 fpath = request.rootpage.getPagePath('event-log', isfile=1) |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
89 if os.path.exists(fpath): |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
90 os.remove(fpath) |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
91 |
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
|
92 def nuke_page(request, pagename): |
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
|
93 """ completely delete a page, everything in the pagedir """ |
5279
2aa43685e17b
AttachFile: added remove_attachment(), made nuke_page use it (details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
4762
diff
changeset
|
94 attachments = AttachFile._get_files(request, pagename) |
2aa43685e17b
AttachFile: added remove_attachment(), made nuke_page use it (details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
4762
diff
changeset
|
95 for attachment in attachments: |
2aa43685e17b
AttachFile: added remove_attachment(), made nuke_page use it (details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
4762
diff
changeset
|
96 AttachFile.remove_attachment(request, pagename, attachment) |
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
|
97 page = PageEditor(request, pagename, do_editor_backup=False) |
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
|
98 page.deletePage() |
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
|
99 # really get rid of everything there: |
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
|
100 fpath = page.getPagePath(check_create=0) |
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
|
101 shutil.rmtree(fpath, True) |
3557
9052c06d4ae3
test_wikidicts: some more tests for group pages
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3504
diff
changeset
|
102 |
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:
3559
diff
changeset
|
103 def create_random_string_list(length=14, count=10): |
baa5bfe1b8e1
test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3559
diff
changeset
|
104 """ creates a list of random strings """ |
baa5bfe1b8e1
test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3559
diff
changeset
|
105 chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' |
baa5bfe1b8e1
test_wikidicts: refactored tests to more useful names, changed defaults for the string list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3559
diff
changeset
|
106 return [u"%s" % random_string(length, chars) for counter in range(count)] |
3947
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
107 |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
108 def make_macro(request, page): |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
109 """ creates the macro """ |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
110 from MoinMoin import macro |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
111 p = Parser("##\n", request) |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
112 p.formatter = Formatter(request) |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
113 p.formatter.page = page |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
114 request.page = page |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
115 request.formatter = p.formatter |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
116 p.form = request.form |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
117 m = macro.Macro(p) |
7626f4760d9f
macro._tests: refactored duplicated code to common methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3575
diff
changeset
|
118 return m |
4762
08dfaece84ad
test_search: calls now nuke_xapian_index for deleting everything in xapian index dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3948
diff
changeset
|
119 |
08dfaece84ad
test_search: calls now nuke_xapian_index for deleting everything in xapian index dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3948
diff
changeset
|
120 def nuke_xapian_index(request): |
08dfaece84ad
test_search: calls now nuke_xapian_index for deleting everything in xapian index dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3948
diff
changeset
|
121 """ completely delete everything in xapian index dir """ |
08dfaece84ad
test_search: calls now nuke_xapian_index for deleting everything in xapian index dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3948
diff
changeset
|
122 fpath = os.path.join(request.cfg.cache_dir, 'xapian') |
08dfaece84ad
test_search: calls now nuke_xapian_index for deleting everything in xapian index dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3948
diff
changeset
|
123 if os.path.exists(fpath): |
08dfaece84ad
test_search: calls now nuke_xapian_index for deleting everything in xapian index dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
3948
diff
changeset
|
124 shutil.rmtree(fpath, True) |