annotate MoinMoin/_tests/maketestwiki.py @ 3392:48b95abf3994

fix tests: need to untar underlay.tar not underlay.tar.bz2
author Johannes Berg <johannes AT sipsolutions DOT net>
date Fri, 21 Mar 2008 15:40:54 +0100
parents f5f4dbbd0c51
children 6fbfffffc4d1
rev   line source
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
2 """
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
3 MoinMoin - make a test wiki
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
4
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
5 Usage:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
6
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
7 maketestwiki.py
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
8
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
9 @copyright: 2005 by Thomas Waldmann
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
11 """
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
12
2174
f5f4dbbd0c51 added tarfile.py from py 2.5.1 (backported to work with py 2.3/2.4), fix imports to use it for tests/backup (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2006
diff changeset
13 import os, sys, shutil, errno
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
14
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
15 filename = globals().get("__file__") or sys.argv[0]
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
16 moinpath = os.path.abspath(os.path.join(os.path.dirname(filename), os.pardir, os.pardir))
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
17 sys.path.insert(0, moinpath)
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
18
2174
f5f4dbbd0c51 added tarfile.py from py 2.5.1 (backported to work with py 2.3/2.4), fix imports to use it for tests/backup (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2006
diff changeset
19 from MoinMoin.support import tarfile
f5f4dbbd0c51 added tarfile.py from py 2.5.1 (backported to work with py 2.3/2.4), fix imports to use it for tests/backup (ported from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2006
diff changeset
20
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
21 WIKI = os.path.abspath(os.path.join(moinpath, 'tests', 'wiki'))
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
22 SHARE = os.path.abspath(os.path.join(moinpath, 'wiki'))
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
23
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
24
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
25 def removeTestWiki():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
26 print 'removing old wiki ...'
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
27 for dir in ['data', 'underlay']:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
28 try:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
29 shutil.rmtree(os.path.join(WIKI, dir))
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
30 except OSError, err:
348
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
31 if not (err.errno == errno.ENOENT or
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
32 (err.errno == 3 and os.name == 'nt')):
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
33 raise
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
34
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
35
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
36 def copyData():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
37 print 'copying data ...'
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
38 src = os.path.join(SHARE, 'data')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
39 dst = os.path.join(WIKI, 'data')
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
40 shutil.copytree(src, dst)
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
41
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
42
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
43 def untarUnderlay():
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
44 print 'untaring underlay ...'
3392
48b95abf3994 fix tests: need to untar underlay.tar not underlay.tar.bz2
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2174
diff changeset
45 tar = tarfile.open(os.path.join(SHARE, 'underlay.tar'))
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
46 for member in tar:
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
47 tar.extract(member, WIKI)
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
48 tar.close()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
49
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
50
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
51 def run(skip_if_existing=False):
348
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
52 try:
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
53 os.makedirs(WIKI)
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
54 except OSError, e:
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
55 if e.errno != errno.EEXIST:
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
56 raise
f308f9478d51 Fixed maketestwiki.py for cases when there is not testwiki dir, or when run on Windows (How i hate this WindowsError exception).
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 315
diff changeset
57
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
58 if skip_if_existing and os.path.exists(os.path.join(WIKI, 'data')):
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.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1603
diff changeset
59 return
315
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
60 removeTestWiki()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
61 copyData()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
62 untarUnderlay()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
63
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
64 if __name__ == '__main__':
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
65 run()
830cf8bdcf24 implemented 'make pagepacks', updated underlay
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
66