diff MoinMoin/_tests/test_wikiutil.py @ 2265:a607b0329922

add tests for parsing and making of query strings
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 30 Jun 2007 21:09:33 +0200
parents 789c1a37e4ab
children 3318504c5dd5
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Sat Jun 30 17:30:39 2007 +0200
+++ b/MoinMoin/_tests/test_wikiutil.py	Sat Jun 30 21:09:33 2007 +0200
@@ -11,6 +11,27 @@
 from MoinMoin import wikiutil
 
 
+class TestQueryStringSupport:
+    tests = [
+        ('', {}, {}),
+        ('key1=value1', {'key1': 'value1'}, {'key1': u'value1'}),
+        ('key1=value1&key2=value2', {'key1': 'value1', 'key2': 'value2'}, {'key1': u'value1', 'key2': u'value2'}),
+        ('rc_de=Aktuelle%C3%84nderungen', {'rc_de': 'Aktuelle\xc3\x84nderungen'}, {'rc_de': u'Aktuelle\xc4nderungen'}),
+    ]
+    def testParseQueryString(self):
+        for qstr, expected_str, expected_unicode in self.tests:
+            assert wikiutil.parseQueryString(qstr, want_unicode=False) == expected_str
+            assert wikiutil.parseQueryString(qstr, want_unicode=True) == expected_unicode
+            assert wikiutil.parseQueryString(unicode(qstr), want_unicode=False) == expected_str
+            assert wikiutil.parseQueryString(unicode(qstr), want_unicode=True) == expected_unicode
+
+    def testMakeQueryString(self):
+        for qstr, in_str, in_unicode in self.tests:
+            assert wikiutil.parseQueryString(wikiutil.makeQueryString(in_unicode, want_unicode=False), want_unicode=False) == in_str
+            assert wikiutil.parseQueryString(wikiutil.makeQueryString(in_str, want_unicode=False), want_unicode=False) == in_str
+            assert wikiutil.parseQueryString(wikiutil.makeQueryString(in_unicode, want_unicode=True), want_unicode=True) == in_unicode
+            assert wikiutil.parseQueryString(wikiutil.makeQueryString(in_str, want_unicode=True), want_unicode=True) == in_unicode
+
 class TestSystemPagesGroup:
     def testSystemPagesGroupNotEmpty(self):
         assert self.request.dicts.members('SystemPagesGroup')