diff MoinMoin/_tests/maketestwiki.py @ 2006:1339d6fdc4ff

Changed tests to use py.test. Also changed the semantics a bit - the test wiki directory is only created freshly if it does not exist.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Fri, 20 Apr 2007 00:12:50 +0200
parents tests/maketestwiki.py@767109c48208
children f5f4dbbd0c51
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/_tests/maketestwiki.py	Fri Apr 20 00:12:50 2007 +0200
@@ -0,0 +1,64 @@
+# -*- coding: iso-8859-1 -*-
+"""
+MoinMoin - make a test wiki
+
+Usage:
+
+    maketestwiki.py
+
+@copyright: 2005 by Thomas Waldmann
+@license: GNU GPL, see COPYING for details.
+"""
+
+import os, sys, shutil, errno, tarfile
+
+filename = globals().get("__file__") or sys.argv[0]
+moinpath = os.path.abspath(os.path.join(os.path.dirname(filename), os.pardir, os.pardir))
+sys.path.insert(0, moinpath)
+
+WIKI = os.path.abspath(os.path.join(moinpath, 'tests', 'wiki'))
+SHARE = os.path.abspath(os.path.join(moinpath, 'wiki'))
+
+
+def removeTestWiki():
+    print 'removing old wiki ...'
+    for dir in ['data', 'underlay']:
+        try:
+            shutil.rmtree(os.path.join(WIKI, dir))
+        except OSError, err:
+            if not (err.errno == errno.ENOENT or
+                    (err.errno == 3 and os.name == 'nt')):
+                raise
+
+
+def copyData():
+    print 'copying data ...'
+    src = os.path.join(SHARE, 'data')
+    dst = os.path.join(WIKI, 'data')
+    shutil.copytree(src, dst)
+
+
+def untarUnderlay():
+    print 'untaring underlay ...'
+    tar = tarfile.open(os.path.join(SHARE, 'underlay.tar.bz2'), mode='r:bz2')
+    for member in tar:
+        tar.extract(member, WIKI)
+    tar.close()
+
+
+def run(skip_if_existing=False):
+    try:
+        os.makedirs(WIKI)
+    except OSError, e:
+        if e.errno != errno.EEXIST:
+            raise
+
+    if skip_if_existing and os.path.exists(os.path.join(WIKI, 'data')):
+        return
+    removeTestWiki()
+    copyData()
+    untarUnderlay()
+
+if __name__ == '__main__':
+    run()
+