annotate MoinMoin/_tests/test_packages.py @ 3063:726f96c0f12e

test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 21 Feb 2008 21:14:57 +0100
parents c9949c55ff5e
children ed1a433803c6
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
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
5 @copyright: 2005 MoinMoin:AlexanderSchremmer,
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
6 2007 Federico Lorenzi
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
7 @license: GNU GPL, see COPYING for details.
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
8 """
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
9
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
10 import tempfile
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
11 import py
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
12 import zipfile
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
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
14 from MoinMoin import wikiutil
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
15 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
16 from MoinMoin.PageEditor import PageEditor
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
17 from MoinMoin.action.PackagePages import PackagePages
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
18 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
19 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
20
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
21
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
22 class DebugPackage(Package, ScriptEngine):
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
23 """ Used for debugging, does not need a real .zip file. """
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
24
260
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
25 def __init__(self, request, filename, script=None):
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
26 Package.__init__(self, request)
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
27 ScriptEngine.__init__(self)
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
28 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
29 self.script = script or u"""moinmoinpackage|1
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
30 print|foo
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
31 ReplaceUnderlay|testdatei|TestSeite2
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
32 IgnoreExceptions|True
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
33 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
34 DeletePage|FooPage|Test ...
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
35 IgnoreExceptions|False
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
36 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
37 AddRevision|foofile|FooPage
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
38 setthemename|foo
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
39 #foobar
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
40 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
41 """
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
42
3d8df5b91504 Enhanced packages test to write to a page two times.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 80
diff changeset
43 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
44 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
45 return self.script.encode("utf-8")
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
46 else:
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
47 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
48
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
49 def filelist(self):
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
50 return [MOIN_PACKAGE_FILE, "foo"]
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
51
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
52 def isPackage(self):
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
53 return True
892
9931a09387b0 some whitespace cleanup in the tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 260
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
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
56 class TestUnsafePackage:
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
57 """ 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
58 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
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 setup_class(self):
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
61 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
62 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
63
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
64 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
65 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
66 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
67 """).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
68
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
69 def testBasicPackageThings(self):
2409
7c32a0f0d570 Forgotten file (test_packages.py)
Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2246
diff changeset
70 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
71 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
72 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
73 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
74 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
75 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
76 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
77
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
78
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 class TestQuoting:
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
80
80
99f0d19d0285 Integrated MoinMoin:PackageInstaller and zip support.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
81 def testQuoting(self):
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
82 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
83 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
84
3063
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
85
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
86 class TestRealCreation:
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
87
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
88 def testSearchCreate(self):
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
89 package = PackagePages(self.request.rootpage.page_name, self.request)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
90 temp = tempfile.NamedTemporaryFile(suffix='.zip')
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
91 package.collectpackage(package.searchpackage(self.request, "Category"), temp)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
92 assert zipfile.is_zipfile(temp.name)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
93
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
94 def testListCreate(self):
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
95 package = PackagePages(self.request.rootpage.page_name, self.request)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
96 temp = tempfile.NamedTemporaryFile(suffix='.zip')
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
97 package.collectpackage(['FrontPage'], temp)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
98 assert zipfile.is_zipfile(temp.name)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
99
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
100 def testAllCreate(self):
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
101 package = PackagePages(self.request.rootpage.page_name, self.request)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
102 temp = tempfile.NamedTemporaryFile(suffix='.zip')
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
103 package.collectpackage(self.request.rootpage.getPageList(
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
104 include_underlay=False,
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
105 filter=lambda name: not wikiutil.isSystemPage(self.request, name)),
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
106 temp)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
107 if package:
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
108 py.test.skip("No user created pages in wiki!")
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
109 assert zipfile.is_zipfile(temp.name)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
110
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
111 def testInvalidCreate(self):
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
112 package = PackagePages(self.request.rootpage.page_name, self.request)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
113 temp = tempfile.NamedTemporaryFile(suffix='.zip')
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
114 package.collectpackage(['___//THIS PAGE SHOULD NOT EXIST\\___'], temp)
726f96c0f12e test_packages: further tests for PackagePages (Thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2448
diff changeset
115 assert not zipfile.is_zipfile(temp.name)
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2409
diff changeset
116 coverage_modules = ['MoinMoin.packages']