annotate MoinMoin/_tests/test_packages.py @ 2448:c9949c55ff5e

add coverage_modules attribute for coverage testing
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 20 Jul 2007 22:26:57 +0200
parents 7c32a0f0d570
children 726f96c0f12e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
2 """
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1336
diff changeset
3 MoinMoin - MoinMoin.packages tests
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1336
diff changeset
5 @copyright: 2005 MoinMoin:AlexanderSchremmer
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1336
diff changeset
6 @license: GNU GPL, see COPYING for details.
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
7 """
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
8
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: 1918
diff changeset
9
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: 1918
diff changeset
10 import py
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: 1918
diff changeset
11
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
12 from MoinMoin.Page import Page
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: 1918
diff changeset
13 from MoinMoin.PageEditor import PageEditor
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
14 from MoinMoin.packages import Package, ScriptEngine, MOIN_PACKAGE_FILE, packLine, unpackLine
2409
7c32a0f0d570 Forgotten file (test_packages.py)
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2246
diff changeset
15 from MoinMoin._tests.common import gain_superuser_rights
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: 1918
diff changeset
16
2246
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
17
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
18 class DebugPackage(Package, ScriptEngine):
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
19 """ Used for debugging, does not need a real .zip file. """
260
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
20 def __init__(self, request, filename, script=None):
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
21 Package.__init__(self, request)
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
22 ScriptEngine.__init__(self)
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
23 self.filename = filename
260
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
24 self.script = script or u"""moinmoinpackage|1
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
25 print|foo
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
26 ReplaceUnderlay|testdatei|TestSeite2
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
27 IgnoreExceptions|True
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
28 DeletePage|TestSeiteDoesNotExist|Test ...
2246
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
29 DeletePage|FooPage|Test ...
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
30 IgnoreExceptions|False
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
31 AddRevision|foofile|FooPage
260
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
32 AddRevision|foofile|FooPage
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
33 setthemename|foo
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
34 #foobar
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
35 installplugin|foo|local|parser|testy
260
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
36 """
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
37
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
38 def extract_file(self, filename):
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
39 if filename == MOIN_PACKAGE_FILE:
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
40 return self.script.encode("utf-8")
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
41 else:
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
42 return "Hello world, I am the file " + filename.encode("utf-8")
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
43
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
44 def filelist(self):
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
45 return [MOIN_PACKAGE_FILE, "foo"]
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
46
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
47 def isPackage(self):
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
48 return True
892
9931a09387b0 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 260
diff changeset
49
2246
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
50
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
51 class TestUnsafePackage:
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
52 """ Tests various things in the packages package. Note that this package does
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
53 not care to clean up and needs to run in a test wiki because of that. """
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
54
2246
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
55 def setup_class(self):
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
56 if not getattr(self.request.cfg, 'is_test_wiki', False):
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: 1918
diff changeset
57 py.test.skip('This test needs to be run using the test wiki.')
892
9931a09387b0 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 260
diff changeset
58
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
59
2246
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
60 def teardown_class(self):
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: 1918
diff changeset
61 DebugPackage(self.request, u"""moinmoinpackage|1
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: 1918
diff changeset
62 DeletePage|FooPage|Test ...
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: 1918
diff changeset
63 """).installPackage()
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: 1918
diff changeset
64
2246
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
65
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
66 def testBasicPackageThings(self):
2409
7c32a0f0d570 Forgotten file (test_packages.py)
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2246
diff changeset
67 gain_superuser_rights(self.request)
2246
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
68 myPackage = DebugPackage(self.request, 'test')
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
69 myPackage.installPackage()
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
70 assert myPackage.msg == u'foo\nFooPage added \n'
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
71 testseite2 = Page(self.request, 'TestSeite2')
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
72 assert testseite2.getPageText() == "Hello world, I am the file testdatei"
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
73 assert testseite2.isUnderlayPage()
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
74
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
75
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
76 class TestQuoting:
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
77 def testQuoting(self):
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
78 for line in ([':foo', 'is\\', 'ja|', u't|', u'baAz'], [], ['', '']):
2246
0893eaf60bbf Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2006
diff changeset
79 assert line == unpackLine(packLine(line))
892
9931a09387b0 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 260
diff changeset
80
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2409
diff changeset
81 coverage_modules = ['MoinMoin.packages']
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2409
diff changeset
82