annotate MoinMoin/_tests/test_wikiutil.py @ 2140:ff428fa12e3c

Added legacy warning to old unittests.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sun, 17 Jun 2007 23:49:40 +0200
parents 1376525701c1
children 7fed5edaa2a5
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - MoinMoin.wikiutil Tests
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
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: 534
diff changeset
5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8
2140
ff428fa12e3c Added legacy warning to old unittests.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2052
diff changeset
9 import unittest # LEGACY UNITTEST, PLEASE DO NOT IMPORT unittest IN NEW TESTS, PLEASE CONSULT THE py.test DOCS
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10 from MoinMoin import wikiutil
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12
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 class TestSystemPage(unittest.TestCase):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14 systemPages = (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 # First level, on SystemPagesGroup
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 'SystemPagesInEnglishGroup',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17 # Second level, on one of the pages above
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 'RecentChanges',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 'TitleIndex',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 notSystemPages = (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 'NoSuchPageYetAndWillNeverBe',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 def testSystemPage(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 """wikiutil: good system page names accepted, bad rejected"""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27 for name in self.systemPages:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28 self.assert_(wikiutil.isSystemPage(self.request, name),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 '"%(name)s" is a system page' % locals())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30 for name in self.notSystemPages:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 self.failIf(wikiutil.isSystemPage(self.request, name),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 '"%(name)s" is NOT a system page' % locals())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.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: 1918
diff changeset
35 class TestTemplatePage(unittest.TestCase):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36 good = (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37 'aTemplate',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 'MyTemplate',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
39 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
40 bad = (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41 'Template',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 'ATemplate',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43 'TemplateInFront',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 'xTemplateInFront',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 'XTemplateInFront',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 # require default page_template_regex config
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 def setUp(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
50 self.config = self.TestConfig(defaults=['page_template_regex'])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 def tearDown(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
52 self.config.restore()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54 def testTemplatePage(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55 """wikiutil: good template names accepted, bad rejected"""
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56 for name in self.good:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 self.assert_(wikiutil.isTemplatePage(self.request, name),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58 '"%(name)s" is a valid template name' % locals())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59 for name in self.bad:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 self.failIf(wikiutil.isTemplatePage(self.request, name),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 '"%(name)s" is NOT a valid template name' % locals())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63
2052
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
64 class TestParmeterParser(unittest.TestCase):
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
65
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
66 def testNoWantedArguments(self):
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
67 args = ''
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
68 argParser = wikiutil.ParameterParser('')
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
69 self.arg_list, self.arg_dict = argParser.parse_parameters(args)
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
70 result = len(self.arg_dict) > 0
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
71 expected = False
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
72 self.assert_(result is expected,
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
73 'Expected "%(expected)s" but got "%(result)s"' % locals())
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
74
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
75 def testWantedArguments(self):
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
76 test_args = ('',
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
77 'width=100',
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
78 'width=100, height=200', )
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
79
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
80 argParser = wikiutil.ParameterParser("%(width)s%(height)s")
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
81 for args in test_args:
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
82 self.arg_list, self.arg_dict = argParser.parse_parameters(args)
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
83 result = len(self.arg_dict) == 2
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
84 expected = True
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
85 self.assert_(result is expected,
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
86 'Expected "%(expected)s" but got "%(result)s"' % locals())
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
87
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
88 def testTooMuchWantedArguments(self):
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
89 args = 'width=100, height=200, alt=Example'
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
90 argParser = wikiutil.ParameterParser("%(width)s%(height)s")
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
91 self.arg_list, self.arg_dict = argParser.parse_parameters(args)
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
92 result = len(self.arg_dict) == 2
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
93 expected = True
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
94 self.assert_(result is expected,
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
95 'Expected "%(expected)s" but got "%(result)s"' % locals())
1376525701c1 wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2006
diff changeset
96