comparison MoinMoin/_tests/test_wikiutil.py @ 2052:1376525701c1

wikiutil.ParameterParser: tests added and bug fixed if args is empty and parameters wanted
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 10 Jun 2007 16:13:08 +0200
parents 1339d6fdc4ff
children ff428fa12e3c
comparison
equal deleted inserted replaced
2051:b1046ec29bca 2052:1376525701c1
59 for name in self.bad: 59 for name in self.bad:
60 self.failIf(wikiutil.isTemplatePage(self.request, name), 60 self.failIf(wikiutil.isTemplatePage(self.request, name),
61 '"%(name)s" is NOT a valid template name' % locals()) 61 '"%(name)s" is NOT a valid template name' % locals())
62 62
63 63
64 class TestParmeterParser(unittest.TestCase):
65
66 def testNoWantedArguments(self):
67 args = ''
68 argParser = wikiutil.ParameterParser('')
69 self.arg_list, self.arg_dict = argParser.parse_parameters(args)
70 result = len(self.arg_dict) > 0
71 expected = False
72 self.assert_(result is expected,
73 'Expected "%(expected)s" but got "%(result)s"' % locals())
74
75 def testWantedArguments(self):
76 test_args = ('',
77 'width=100',
78 'width=100, height=200', )
79
80 argParser = wikiutil.ParameterParser("%(width)s%(height)s")
81 for args in test_args:
82 self.arg_list, self.arg_dict = argParser.parse_parameters(args)
83 result = len(self.arg_dict) == 2
84 expected = True
85 self.assert_(result is expected,
86 'Expected "%(expected)s" but got "%(result)s"' % locals())
87
88 def testTooMuchWantedArguments(self):
89 args = 'width=100, height=200, alt=Example'
90 argParser = wikiutil.ParameterParser("%(width)s%(height)s")
91 self.arg_list, self.arg_dict = argParser.parse_parameters(args)
92 result = len(self.arg_dict) == 2
93 expected = True
94 self.assert_(result is expected,
95 'Expected "%(expected)s" but got "%(result)s"' % locals())
96