changeset 4630:b0319cfcb1bc

1.6.0a mig script/converter: fixed converter bug for parser sections, added unit tests for pre and parser sections
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 18 Feb 2009 06:53:55 +0100
parents bc0ad5554ab0
children 7fbbdd3e58a9
files MoinMoin/script/migration/_conv160a_wiki.py MoinMoin/script/migration/_tests/test_conv160_wiki.py MoinMoin/script/migration/_tests/test_conv160a_wiki.py
diffstat 3 files changed, 80 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/migration/_conv160a_wiki.py	Sat Feb 14 22:21:34 2009 +0100
+++ b/MoinMoin/script/migration/_conv160a_wiki.py	Wed Feb 18 06:53:55 2009 +0100
@@ -414,16 +414,16 @@
             else:
                 return '[[%s|%s]]' % (target, text)
 
+    def _parser_repl(self, word):
+        self.in_pre = 'no_parser'
+        return word
+
     def _pre_repl(self, word):
         w = word.strip()
         if w == '{{{' and not self.in_pre:
-            self.in_pre = True
+            self.in_pre = 'no_parser'
         elif w == '}}}' and self.in_pre:
-            self.in_pre = False
-        return word
-
-    def _processor_repl(self, word):
-        self.in_pre = True
+            self.in_pre = None
         return word
 
     def scan(self, scan_re, line):
--- a/MoinMoin/script/migration/_tests/test_conv160_wiki.py	Sat Feb 14 22:21:34 2009 +0100
+++ b/MoinMoin/script/migration/_tests/test_conv160_wiki.py	Wed Feb 18 06:53:55 2009 +0100
@@ -158,4 +158,42 @@
         for data, renames, expected in tests:
             assert convert_wiki(request, pagename, data, renames) == expected
 
+    def test_parser(self):
+        #py.test.skip("not wanted right now")
+        markup_15 = u"""\
+{{{#!html
+...
+}}}
 
+"""
+        expected_markup_160 = u"""\
+{{{#!html
+...
+}}}
+
+"""
+        markup_160 = convert_wiki(self.request, u'TestPage', markup_15, {})
+        #print markup_15 ; print "---" ; print markup_160
+        markup_160 = markup_160.replace('\r\n', '\n')
+        assert markup_160 == expected_markup_160
+
+
+    def test_pre(self):
+        #py.test.skip("not wanted right now")
+        markup_15 = u"""\
+{{{
+...
+}}}
+
+"""
+        expected_markup_160 = u"""\
+{{{
+...
+}}}
+
+"""
+        markup_160 = convert_wiki(self.request, u'TestPage', markup_15, {})
+        #print markup_15 ; print "---" ; print markup_160
+        markup_160 = markup_160.replace('\r\n', '\n')
+        assert markup_160 == expected_markup_160
+
--- a/MoinMoin/script/migration/_tests/test_conv160a_wiki.py	Sat Feb 14 22:21:34 2009 +0100
+++ b/MoinMoin/script/migration/_tests/test_conv160a_wiki.py	Wed Feb 18 06:53:55 2009 +0100
@@ -421,3 +421,39 @@
         markup_160 = markup_160.replace('\r\n', '\n')
         assert markup_160 == expected_markup_160
 
+    def test_parser(self):
+        markup_160a = u"""\
+{{{#!html
+...
+}}}
+
+"""
+        expected_markup_160 = u"""\
+{{{#!html
+...
+}}}
+
+"""
+        markup_160 = convert_wiki(self.request, u'TestPage', markup_160a, {})
+        #print markup_160a ; print "---" ; print markup_160
+        markup_160 = markup_160.replace('\r\n', '\n')
+        assert markup_160 == expected_markup_160
+
+    def test_pre(self):
+        markup_160a = u"""\
+{{{
+...
+}}}
+
+"""
+        expected_markup_160 = u"""\
+{{{
+...
+}}}
+
+"""
+        markup_160 = convert_wiki(self.request, u'TestPage', markup_160a, {})
+        #print markup_160a ; print "---" ; print markup_160
+        markup_160 = markup_160.replace('\r\n', '\n')
+        assert markup_160 == expected_markup_160
+