annotate MoinMoin/_tests/test_wikiutil.py @ 2455:fe71235f1f7c

ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 21 Jul 2007 23:00:25 +0200
parents 18c71299e2bb
children 15502589ece6
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
2454
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
5 @copyright: 2003-2004 by Juergen Hermann <jh@web.de>,
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
6 2007 by MoinMoin:ThomasWaldmann
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 @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
8 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9
2172
c15ec6a2c69e reduce number of failing tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2164
diff changeset
10 import py
2454
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
11
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 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
13
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14
2265
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
15 class TestQueryStringSupport:
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
16 tests = [
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
17 ('', {}, {}),
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
18 ('key1=value1', {'key1': 'value1'}, {'key1': u'value1'}),
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
19 ('key1=value1&key2=value2', {'key1': 'value1', 'key2': 'value2'}, {'key1': u'value1', 'key2': u'value2'}),
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
20 ('rc_de=Aktuelle%C3%84nderungen', {'rc_de': 'Aktuelle\xc3\x84nderungen'}, {'rc_de': u'Aktuelle\xc4nderungen'}),
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
21 ]
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
22 def testParseQueryString(self):
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
23 for qstr, expected_str, expected_unicode in self.tests:
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
24 assert wikiutil.parseQueryString(qstr, want_unicode=False) == expected_str
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
25 assert wikiutil.parseQueryString(qstr, want_unicode=True) == expected_unicode
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
26 assert wikiutil.parseQueryString(unicode(qstr), want_unicode=False) == expected_str
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
27 assert wikiutil.parseQueryString(unicode(qstr), want_unicode=True) == expected_unicode
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
28
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
29 def testMakeQueryString(self):
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
30 for qstr, in_str, in_unicode in self.tests:
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
31 assert wikiutil.parseQueryString(wikiutil.makeQueryString(in_unicode, want_unicode=False), want_unicode=False) == in_str
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
32 assert wikiutil.parseQueryString(wikiutil.makeQueryString(in_str, want_unicode=False), want_unicode=False) == in_str
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
33 assert wikiutil.parseQueryString(wikiutil.makeQueryString(in_unicode, want_unicode=True), want_unicode=True) == in_unicode
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
34 assert wikiutil.parseQueryString(wikiutil.makeQueryString(in_str, want_unicode=True), want_unicode=True) == in_unicode
a607b0329922 add tests for parsing and making of query strings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2173
diff changeset
35
2267
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
36
2266
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
37 class TestTickets:
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
38 def testTickets(self):
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
39 from MoinMoin.Page import Page
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
40 # page name with double quotes
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
41 self.request.page = Page(self.request, u'bla"bla')
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
42 ticket1 = wikiutil.createTicket(self.request)
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
43 assert wikiutil.checkTicket(self.request, ticket1)
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
44 # page name with non-ASCII chars
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
45 self.request.page = Page(self.request, u'\xc4rger')
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
46 ticket2 = wikiutil.createTicket(self.request)
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
47 assert wikiutil.checkTicket(self.request, ticket2)
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
48 # same page with another action
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
49 self.request.page = Page(self.request, u'\xc4rger')
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
50 self.request.action = 'another'
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
51 ticket3 = wikiutil.createTicket(self.request)
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
52 assert wikiutil.checkTicket(self.request, ticket3)
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
53
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
54 assert ticket1 != ticket2
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
55 assert ticket2 != ticket3
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
56
3318504c5dd5 create tickets as fn(time, pagename, action, secret) - so they are not reusable, add tests for tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2265
diff changeset
57
2267
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
58 class TestCleanInput:
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
59 def testCleanInput(self):
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
60 tests = [(u"", u""), # empty
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
61 (u"aaa\r\n\tbbb", u"aaa bbb"), # ws chars -> blanks
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
62 (u"aaa\x00\x01bbb", u"aaabbb"), # strip weird chars
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
63 (u"a"*500, u""), # too long
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
64 ]
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
65 for instr, outstr in tests:
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
66 assert wikiutil.clean_input(instr) == outstr
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
67
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
68
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
69 class TestNameQuoting:
2378
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
70 tests = [(u"", u'""'), # empty
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
71 (u"test", u'"test"'), # nothing special
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
72 (u"Sarah O'Connor", u"\"Sarah O'Connor\""),
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
73 (u'Just "something" quoted', u'"Just ""something"" quoted"'),
2267
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
74 ]
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
75 def testQuoteName(self):
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
76 for name, qname in self.tests:
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
77 assert wikiutil.quoteName(name) == qname
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
78
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
79 def testUnquoteName(self):
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
80 for name, qname in self.tests:
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
81 assert wikiutil.unquoteName(qname) == name
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
82
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
83
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
84 class TestInterWiki:
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
85 def testSplitWiki(self):
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
86 tests = [('SomePage', ('Self', 'SomePage', '')),
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
87 ('OtherWiki:OtherPage', ('OtherWiki', 'OtherPage', '')),
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
88 ('MoinMoin:"Page with blanks" link title', ("MoinMoin", "Page with blanks", "link title")),
2378
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
89 ('MoinMoin:"Page with blanks"link title', ("MoinMoin", "Page with blanks", "link title")),
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
90 ('MoinMoin:"Page with blanks"', ("MoinMoin", "Page with blanks", "")),
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
91 ('MoinMoin:"Page with ""quote""" link title', ("MoinMoin", 'Page with "quote"', "link title")),
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
92 ('MoinMoin:"Page with """"double-quote"""link title', ("MoinMoin", 'Page with ""double-quote"', "link title")),
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
93 ('MoinMoin:"""starts with quote"link title', ("MoinMoin", '"starts with quote', "link title")),
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
94 ('MoinMoin:"ends with quote"""link title', ("MoinMoin", 'ends with quote"', "link title")),
a7f4b02f5fdb fix the quoting mess
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2267
diff changeset
95 ('MoinMoin:"""page with quotes around"""link title', ("MoinMoin", '"page with quotes around"', "link title")),
2267
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
96 ('attachment:"filename with blanks.txt" other title', ("attachment", "filename with blanks.txt", "other title")),
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
97 ]
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
98 for markup, (wikiname, pagename, linktext) in tests:
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
99 assert wikiutil.split_wiki(markup) == (wikiname, pagename, linktext)
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
100
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
101 def testJoinWiki(self):
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
102 tests = [(('http://example.org/', u'SomePage'), 'http://example.org/SomePage'),
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
103 (('http://example.org/?page=$PAGE&action=show', u'SomePage'), 'http://example.org/?page=SomePage&action=show'),
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
104 (('http://example.org/', u'Aktuelle\xc4nderungen'), 'http://example.org/Aktuelle%C3%84nderungen'),
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
105 (('http://example.org/$PAGE/show', u'Aktuelle\xc4nderungen'), 'http://example.org/Aktuelle%C3%84nderungen/show'),
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
106 ]
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
107 for (baseurl, pagename), url in tests:
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
108 assert wikiutil.join_wiki(baseurl, pagename) == url
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
109
463f3de3f981 more wikiutil tests, minor bugfix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2266
diff changeset
110
2173
789c1a37e4ab don't run docbook formatter test when we have no 4suite installed, add test for non-empty SystemPagesGroup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2172
diff changeset
111 class TestSystemPagesGroup:
789c1a37e4ab don't run docbook formatter test when we have no 4suite installed, add test for non-empty SystemPagesGroup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2172
diff changeset
112 def testSystemPagesGroupNotEmpty(self):
789c1a37e4ab don't run docbook formatter test when we have no 4suite installed, add test for non-empty SystemPagesGroup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2172
diff changeset
113 assert self.request.dicts.members('SystemPagesGroup')
789c1a37e4ab don't run docbook formatter test when we have no 4suite installed, add test for non-empty SystemPagesGroup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2172
diff changeset
114
2454
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
115 class TestSystemPage:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
116 systemPages = (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117 # 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
118 'SystemPagesInEnglishGroup',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
119 # 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
120 'RecentChanges',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
121 'TitleIndex',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
122 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
123 notSystemPages = (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
124 'NoSuchPageYetAndWillNeverBe',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
125 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
126
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
127 def testSystemPage(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
128 """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
129 for name in self.systemPages:
2454
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
130 assert wikiutil.isSystemPage(self.request, name)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
131 for name in self.notSystemPages:
2454
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
132 assert not wikiutil.isSystemPage(self.request, name)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
133
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
134
2454
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
135 class TestTemplatePage:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
136 good = (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
137 'aTemplate',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
138 'MyTemplate',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
139 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
140 bad = (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
141 'Template',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
142 'ATemplate',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
143 'TemplateInFront',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
144 'xTemplateInFront',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
145 'XTemplateInFront',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
146 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
147
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
148 def testTemplatePage(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
149 """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
150 for name in self.good:
2454
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
151 assert wikiutil.isTemplatePage(self.request, name)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
152 for name in self.bad:
2454
18c71299e2bb convert test_wikiutil to py.test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2453
diff changeset
153 assert not wikiutil.isTemplatePage(self.request, name)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
154
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
155
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
156 class TestParmeterParser:
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
157
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
158 def testParameterParser(self):
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
159 tests = [
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
160 # trivial
2455
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
161 ('', '', 0, {}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
162
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
163 # fixed
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
164 ('%s%i%f%b', '"test",42,23.0,True', 4, {0: 'test', 1: 42, 2: 23.0, 3: True}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
165
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
166 # fixed and named
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
167 ('%s%(x)i%(y)i', '"test"', 1, {0: 'test', 'x': None, 'y': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
168 ('%s%(x)i%(y)i', '"test",1', 1, {0: 'test', 'x': 1, 'y': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
169 ('%s%(x)i%(y)i', '"test",1,2', 1, {0: 'test', 'x': 1, 'y': 2}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
170 ('%s%(x)i%(y)i', '"test",x=1', 1, {0: 'test', 'x': 1, 'y': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
171 ('%s%(x)i%(y)i', '"test",x=1,y=2', 1, {0: 'test', 'x': 1, 'y': 2}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
172 ('%s%(x)i%(y)i', '"test",y=2', 1, {0: 'test', 'x': None, 'y': 2}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
173
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
174 # test mixed acceptance
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
175 ("%ifs", '100', 1, {0: 100}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
176 ("%ifs", '100.0', 1, {0: 100.0}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
177 ("%ifs", '"100"', 1, {0: "100"}),
2164
7fed5edaa2a5 tests: some fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
178
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
179 # boolean
2455
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
180 ("%(t)b%(f)b", '', 0, {'t': None, 'f': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
181 ("%(t)b%(f)b", 't=1', 0, {'t': True, 'f': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
182 ("%(t)b%(f)b", 'f=False', 0, {'t': None, 'f': False}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
183 ("%(t)b%(f)b", 't=True, f=0', 0, {'t': True, 'f': False}),
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
184
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
185 # integer
2455
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
186 ("%(width)i%(height)i", '', 0, {'width': None, 'height': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
187 ("%(width)i%(height)i", 'width=100', 0, {'width': 100, 'height': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
188 ("%(width)i%(height)i", 'height=200', 0, {'width': None, 'height': 200}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
189 ("%(width)i%(height)i", 'width=100, height=200', 0, {'width': 100, 'height': 200}),
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
190
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
191 # float
2455
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
192 ("%(width)f%(height)f", '', 0, {'width': None, 'height': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
193 ("%(width)f%(height)f", 'width=100.0', 0, {'width': 100.0, 'height': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
194 ("%(width)f%(height)f", 'height=2.0E2', 0, {'width': None, 'height': 200.0}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
195 ("%(width)f%(height)f", 'width=1000.0E-1, height=200.0', 0, {'width': 100.0, 'height': 200.0}),
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
196
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
197 # string
2455
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
198 ("%(width)s%(height)s", '', 0, {'width': None, 'height': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
199 ("%(width)s%(height)s", 'width="really wide"', 0, {'width': 'really wide', 'height': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
200 ("%(width)s%(height)s", 'height="not too high"', 0, {'width': None, 'height': 'not too high'}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
201 ("%(width)s%(height)s", 'width="really wide", height="not too high"', 0, {'width': 'really wide', 'height': 'not too high'}),
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
202 # XXX for the next 2 tests: unclear: wanted str, given int, shall that give int?
2455
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
203 ("%(width)s%(height)s", 'width=100', 0, {'width': 100, 'height': None}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
204 ("%(width)s%(height)s", 'width=100, height=200', 0, {'width': 100, 'height': 200}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
205
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
206 # complex test
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
207 ("%i%sf%s%ifs%(a)s|%(b)s", ' 4,"DI\'NG", b=retry, a="DING"', 2, {0: 4, 1: "DI'NG", 'a': 'DING', 'b': 'retry'}),
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
208
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
209 ]
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
210 for format, args, expected_fixed_count, expected_dict in tests:
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
211 argParser = wikiutil.ParameterParser(format)
2455
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
212 fixed_count, arg_dict = argParser.parse_parameters(args)
fe71235f1f7c ParameterParser: changed to return fixed_count, arg_dict, putting positional args into arg_dict[pos], more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2454
diff changeset
213 assert (fixed_count, arg_dict) == (expected_fixed_count, expected_dict)
2164
7fed5edaa2a5 tests: some fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
214
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
215 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
216 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
217 argParser = wikiutil.ParameterParser("%(width)s%(height)s")
2453
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
218 py.test.raises(ValueError, argParser.parse_parameters, args)
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
219
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
220 def testMalformedArguments(self):
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
221 args = '='
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
222 argParser = wikiutil.ParameterParser("%(width)s%(height)s")
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
223 py.test.raises(ValueError, argParser.parse_parameters, args)
adf5ec4874ed fix ParameterParser, rewrite ParameterParser tests for py.test (and add more tests), refactor Hits macro
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2448
diff changeset
224
2164
7fed5edaa2a5 tests: some fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2140
diff changeset
225
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
226 coverage_modules = ['MoinMoin.wikiutil']
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2378
diff changeset
227