diff 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
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Sun Jun 10 00:39:21 2007 +0200
+++ b/MoinMoin/_tests/test_wikiutil.py	Sun Jun 10 16:13:08 2007 +0200
@@ -61,3 +61,36 @@
                 '"%(name)s" is NOT a valid template name' % locals())
 
 
+class TestParmeterParser(unittest.TestCase):
+ 
+    def testNoWantedArguments(self):
+        args = ''
+        argParser = wikiutil.ParameterParser('')
+        self.arg_list, self.arg_dict = argParser.parse_parameters(args)
+        result = len(self.arg_dict) > 0
+        expected = False
+        self.assert_(result is expected,
+                     'Expected "%(expected)s" but got "%(result)s"' % locals())
+
+    def testWantedArguments(self):
+        test_args = ('', 
+                     'width=100',
+                     'width=100, height=200', )
+       
+        argParser = wikiutil.ParameterParser("%(width)s%(height)s")
+        for args in test_args: 
+            self.arg_list, self.arg_dict = argParser.parse_parameters(args)
+            result = len(self.arg_dict) == 2
+            expected = True
+            self.assert_(result is expected,
+                         'Expected "%(expected)s" but got "%(result)s"' % locals())
+      
+    def testTooMuchWantedArguments(self):
+        args = 'width=100, height=200, alt=Example'
+        argParser = wikiutil.ParameterParser("%(width)s%(height)s")
+        self.arg_list, self.arg_dict = argParser.parse_parameters(args)
+        result = len(self.arg_dict) == 2
+        expected = True
+        self.assert_(result is expected,
+                     'Expected "%(expected)s" but got "%(result)s"' % locals())  
+      
\ No newline at end of file