Back to index

moin  1.9.0~rc2
Namespaces | Functions
MoinMoin._tests Namespace Reference

Namespaces

namespace  _test_template
namespace  ldap_testbase
namespace  ldap_testdata
namespace  maketestwiki
namespace  pep8
namespace  test_caching
namespace  test_error
namespace  test_packages
namespace  test_Page
namespace  test_PageEditor
namespace  test_sourcecode
namespace  test_user
namespace  test_wikisync
namespace  test_wikiutil
namespace  test_wsgiapp
namespace  wikiconfig

Functions

def become_valid
def become_trusted
def become_superuser
def nuke_user
def create_page
def append_page
def nuke_eventlog
def nuke_page
def create_random_string_list
def make_macro
def nuke_xapian_index

Function Documentation

def MoinMoin._tests.append_page (   request,
  pagename,
  content,
  do_editor_backup = False 
)
appends some conetent to an existing page 

Definition at line 79 of file __init__.py.

00079 
00080 def append_page(request, pagename, content, do_editor_backup=False):
00081     """ appends some conetent to an existing page """
00082     # reads the raw text of the existing page
00083     raw = Page(request, pagename).get_raw_body()
00084     # adds the new content to the old
00085     content = "%s\n%s\n"% (raw, content)
00086     page = PageEditor(request, pagename, do_editor_backup=do_editor_backup)
00087     page.saveText(content, 0)
00088     return page

Here is the caller graph for this function:

modify request.user so it is in the superuser list,
    also make the user valid (see notes in become_valid()),
    also make the user trusted (and thus in "Trusted" ACL pseudo group).

    Note: being superuser is completely unrelated to ACL rights,
          especially it is not related to ACL admin rights.

Definition at line 43 of file __init__.py.

00043 
00044 def become_superuser(request):
00045     """ modify request.user so it is in the superuser list,
00046         also make the user valid (see notes in become_valid()),
00047         also make the user trusted (and thus in "Trusted" ACL pseudo group).
00048 
00049         Note: being superuser is completely unrelated to ACL rights,
00050               especially it is not related to ACL admin rights.
00051     """
00052     su_name = u"SuperUser"
00053     become_trusted(request, su_name)
00054     if su_name not in request.cfg.superuser:
00055         request.cfg.superuser.append(su_name)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin._tests.become_trusted (   request,
  username = u"TrustedUser" 
)
modify request.user to make the user valid and trusted, so it is in acl group Trusted 

Definition at line 37 of file __init__.py.

00037 
00038 def become_trusted(request, username=u"TrustedUser"):
00039     """ modify request.user to make the user valid and trusted, so it is in acl group Trusted """
00040     become_valid(request, username)
00041     request.user.auth_method = request.cfg.auth_methods_trusted[0]
00042 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin._tests.become_valid (   request,
  username = u"ValidUser" 
)
modify request.user to make the user valid.
    Note that a valid user will only be in ACL special group "Known", if
    we have a user profile for this user as the ACL system will check if
    there is a userid for this username.
    Thus, for testing purposes (e.g. if you need delete rights), it is
    easier to use become_trusted().

Definition at line 24 of file __init__.py.

00024 
00025 def become_valid(request, username=u"ValidUser"):
00026     """ modify request.user to make the user valid.
00027         Note that a valid user will only be in ACL special group "Known", if
00028         we have a user profile for this user as the ACL system will check if
00029         there is a userid for this username.
00030         Thus, for testing purposes (e.g. if you need delete rights), it is
00031         easier to use become_trusted().
00032     """
00033     request.user.name = username
00034     request.user.may.name = username
00035     request.user.valid = 1
00036 

Here is the caller graph for this function:

def MoinMoin._tests.create_page (   request,
  pagename,
  content,
  do_editor_backup = False 
)
create a page with some content 

Definition at line 70 of file __init__.py.

00070 
00071 def create_page(request, pagename, content, do_editor_backup=False):
00072     """ create a page with some content """
00073     # make sure there is nothing already there:
00074     nuke_page(request, pagename)
00075     # now create from scratch:
00076     page = PageEditor(request, pagename, do_editor_backup=do_editor_backup)
00077     page.saveText(content, 0)
00078     return page

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin._tests.create_random_string_list (   length = 14,
  count = 10 
)
creates a list of random strings 

Definition at line 106 of file __init__.py.

00106 
00107 def create_random_string_list(length=14, count=10):
00108     """ creates a list of random strings """
00109     chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
00110     return [u"%s" % random_string(length, chars) for counter in range(count)]

Here is the caller graph for this function:

def MoinMoin._tests.make_macro (   request,
  page 
)
creates the macro 

Definition at line 111 of file __init__.py.

00111 
00112 def make_macro(request, page):
00113     """ creates the macro """
00114     from MoinMoin import macro
00115     p = Parser("##\n", request)
00116     p.formatter = Formatter(request)
00117     p.formatter.page = page
00118     request.page = page
00119     request.formatter = p.formatter
00120     p.form = request.form
00121     m = macro.Macro(p)
00122     return m

Here is the caller graph for this function:

def MoinMoin._tests.nuke_eventlog (   request)
removes event-log file 

Definition at line 89 of file __init__.py.

00089 
00090 def nuke_eventlog(request):
00091     """ removes event-log file """
00092     fpath = request.rootpage.getPagePath('event-log', isfile=1)
00093     if os.path.exists(fpath):
00094         os.remove(fpath)

Here is the caller graph for this function:

def MoinMoin._tests.nuke_page (   request,
  pagename 
)
completely delete a page, everything in the pagedir 

Definition at line 95 of file __init__.py.

00095 
00096 def nuke_page(request, pagename):
00097     """ completely delete a page, everything in the pagedir """
00098     attachments = AttachFile._get_files(request, pagename)
00099     for attachment in attachments:
00100         AttachFile.remove_attachment(request, pagename, attachment)
00101     page = PageEditor(request, pagename, do_editor_backup=False)
00102     page.deletePage()
00103     # really get rid of everything there:
00104     fpath = page.getPagePath(check_create=0)
00105     shutil.rmtree(fpath, True)

Here is the caller graph for this function:

def MoinMoin._tests.nuke_user (   request,
  username 
)
completely delete a user 

Definition at line 56 of file __init__.py.

00056 
00057 def nuke_user(request, username):
00058     """ completely delete a user """
00059     user_dir = request.cfg.user_dir
00060     user_id = user.getUserId(request, username)
00061     # really get rid of the user
00062     fpath = os.path.join(user_dir, user_id)
00063     os.remove(fpath)
00064     # delete cache
00065     arena = 'user'
00066     key = 'name2id'
00067     caching.CacheEntry(request, arena, key, scope='wiki').remove()
00068 
00069 # Creating and destroying test pages --------------------------------

Here is the call graph for this function:

Here is the caller graph for this function:

completely delete everything in xapian index dir 

Definition at line 123 of file __init__.py.

00123 
00124 def nuke_xapian_index(request):
00125     """ completely delete everything in xapian index dir """
00126     fpath = os.path.join(request.cfg.cache_dir, 'xapian')
00127     if os.path.exists(fpath):
00128         shutil.rmtree(fpath, True)

Here is the caller graph for this function: