~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/_tests/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
    MoinMoin - some common code for testing
4
4
 
5
5
    @copyright: 2007 MoinMoin:KarolNowak,
6
 
                2008 MoinMoin:ThomasWaldmann, MoinMoin:ReimarBauer
 
6
                2008 MoinMoin:ThomasWaldmann
7
7
    @license: GNU GPL, see COPYING for details.
8
8
"""
9
9
 
10
10
import os, shutil
11
11
 
12
 
from MoinMoin.parser.text import Parser
13
 
from MoinMoin.formatter.text_html import Formatter
14
12
from MoinMoin.Page import Page
15
13
from MoinMoin.PageEditor import PageEditor
16
14
from MoinMoin.util import random_string
17
15
from MoinMoin import caching, user
18
 
from MoinMoin.action import AttachFile
19
 
 
20
16
# Promoting the test user -------------------------------------------
21
17
# Usually the tests run as anonymous user, but for some stuff, you
22
18
# need more privs...
86
82
    page.saveText(content, 0)
87
83
    return page
88
84
 
89
 
def nuke_eventlog(request):
90
 
    """ removes event-log file """
91
 
    fpath = request.rootpage.getPagePath('event-log', isfile=1)
92
 
    if os.path.exists(fpath):
93
 
        os.remove(fpath)
94
 
 
95
85
def nuke_page(request, pagename):
96
86
    """ completely delete a page, everything in the pagedir """
97
 
    attachments = AttachFile._get_files(request, pagename)
98
 
    for attachment in attachments:
99
 
        AttachFile.remove_attachment(request, pagename, attachment)
100
87
    page = PageEditor(request, pagename, do_editor_backup=False)
101
88
    page.deletePage()
102
89
    # really get rid of everything there:
107
94
    """ creates a list of random strings """
108
95
    chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
109
96
    return [u"%s" % random_string(length, chars) for counter in range(count)]
110
 
 
111
 
def make_macro(request, page):
112
 
    """ creates the macro """
113
 
    from MoinMoin import macro
114
 
    p = Parser("##\n", request)
115
 
    p.formatter = Formatter(request)
116
 
    p.formatter.page = page
117
 
    request.page = page
118
 
    request.formatter = p.formatter
119
 
    p.form = request.form
120
 
    m = macro.Macro(p)
121
 
    return m
122
 
 
123
 
def nuke_xapian_index(request):
124
 
    """ completely delete everything in xapian index dir """
125
 
    fpath = os.path.join(request.cfg.cache_dir, 'xapian')
126
 
    if os.path.exists(fpath):
127
 
        shutil.rmtree(fpath, True)