changeset 4489:a835ada897e0

1.6.0a mig script/converter: fix interwiki tests, cleanup
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 16 Jan 2009 01:42:02 +0100
parents a2a05ae3e7ec
children b120d9978144 eb377776ca34
files MoinMoin/script/migration/_conv160a_wiki.py MoinMoin/script/migration/_tests/test_conv160a_wiki.py
diffstat 2 files changed, 25 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/migration/_conv160a_wiki.py	Thu Jan 15 23:37:36 2009 +0100
+++ b/MoinMoin/script/migration/_conv160a_wiki.py	Fri Jan 16 01:42:02 2009 +0100
@@ -275,22 +275,24 @@
     def interwiki(self, target_and_text, **kw):
         scheme, rest = target_and_text.split(':', 1)
         wikiname, pagename, text = wikiutil160a.split_wiki(rest)
-        if text:
-            text = '|' + text
 
-        if (pagename.startswith(wikiutil.CHILD_PREFIX) or # fancy link to subpage [wiki:/SubPage text]
-            Page(self.request, pagename).exists()): # fancy link to local page [wiki:LocalPage text]
-            pagename = wikiutil.url_unquote(pagename)
-            pagename = self._replace_target(pagename)
-            return '[[%s%s]]' % (pagename, text)
+        #if (pagename.startswith(wikiutil.CHILD_PREFIX) or # fancy link to subpage [wiki:/SubPage text]
+        #    Page(self.request, pagename).exists()): # fancy link to local page [wiki:LocalPage text]
+        #    # XXX OtherWiki:FooPage markup -> checks for local FooPage -sense???
+        #    pagename = wikiutil.url_unquote(pagename)
+        #    pagename = self._replace_target(pagename)
+        #    return '[[%s%s]]' % (pagename, text)
 
         if wikiname in ('Self', self.request.cfg.interwikiname, ''): # [wiki:Self:LocalPage text] or [:LocalPage:text]
+            orig_pagename = pagename
             pagename = wikiutil.url_unquote(pagename)
             pagename = self._replace_target(pagename)
             camelcase = wikiutil.isStrictWikiname(pagename)
-            if camelcase and text == pagename:
-                return '%s' % pagename # optimize special case
+            if camelcase and (not text or text == orig_pagename):
+                return pagename # optimize special case
             else:
+                if text:
+                    text = '|' + text
                 return '[[%s%s]]' % (pagename, text)
 
         wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, wikiname+':')
@@ -308,6 +310,8 @@
             if ' ' not in wikitail and not text:
                 return '%s:%s' % (wikitag, wikitail)
             else:
+                if text:
+                    text = '|' + text
                 return '[[%s:%s%s]]' % (wikitag, wikitail, text)
 
     def attachment(self, target_and_text, **kw):
--- a/MoinMoin/script/migration/_tests/test_conv160a_wiki.py	Thu Jan 15 23:37:36 2009 +0100
+++ b/MoinMoin/script/migration/_tests/test_conv160a_wiki.py	Fri Jan 16 01:42:02 2009 +0100
@@ -3,7 +3,6 @@
     MoinMoin - tests of wiki content conversion
 
     TODO:
-    * fix failing tests
     * fix parser/converter anchor link handling
     * emit a warning if we find some page name that was renamed as a macro argument?
     * shall we support camelcase renaming?
@@ -37,49 +36,38 @@
         }
 
         tests = [
-            # 1.6.0a specific tests (jk)
             # attachment links
             ("attachment:filename.ext", {}, "[[attachment:filename.ext]]"),
             ("[attachment:'Filename.ext' Aliasname]", {}, "[[attachment:Filename.ext|Aliasname]]"),
             ("[attachment:'Pagename/Filename.ext' Aliasname]", {}, "[[attachment:Pagename/Filename.ext|Aliasname]]"),
             ("[attachment:'Pagename/Subpage/Filename.ext' Aliasname]", {}, "[[attachment:Pagename/Subpage/Filename.ext|Aliasname]]"),
             ('[attachment:"Pagename/Subpage/File Name.ext" Aliasname]', {}, "[[attachment:Pagename/Subpage/File Name.ext|Aliasname]]"),
-            # page links
-            ('["Pagename"]', {}, "[[Pagename]]"),
+
+            # "nothing changed" checks (except markup)
+            ('', {}, ''),
+            ('CamelCase', {}, 'CamelCase'),
             ('["/Subpage"]', {}, "[[/Subpage]]"),
             ('["Pagename/Subpage"]', {}, "[[Pagename/Subpage]]"),
             ("['Pagename/Subpage' Aliasname]", {}, "[[Pagename/Subpage|Aliasname]]"),
-            # other links
-            ("[http://google.de google]", {}, "[[http://google.de|google]]"),
-            # other stuff
-            ("[[GetText(To)]]", {}, "<<GetText(To)>>"),
-
-            # 1.6.0a specific tests
             ('["some page" somepage]', {}, '[[some page|somepage]]'),
             ("['some page' somepage]", {}, '[[some page|somepage]]'),
+
+            ('Doesnotexist:CamelCase', {}, 'Doesnotexist:CamelCase'),
+            ('MoinMaster:CamelCase', {}, 'MoinMaster:CamelCase'),
             ("MoinMaster:'some page'", {}, '[[MoinMaster:some page]]'),
             ('MoinMaster:"some page"', {}, '[[MoinMaster:some page]]'),
-            #("MoinMaster:'some page'", {}, '[[MoinMaster:some page]]'),
-            # "nothing changed" checks (except markup)
-            ('', {}, ''),
-            ('CamelCase', {}, 'CamelCase'),
-            # XXX TODO ('MoinMaster:CamelCase', {}, 'MoinMaster:CamelCase'),
 
-            # did not work in 1.6a
-            #('[wiki:LinuxWiki: LinuxWiki.de]', {}, '[[LinuxWiki:|LinuxWiki.de]]'),
-            #('[wiki:/OtherPage]', rename_some_page, '[[/OtherPage]]'),
-            #('[wiki:/OtherPage other page]', rename_some_page, '[[/OtherPage|other page]]'),
-
-            # XXX TODO  ('[wiki:MoinMoin/FrontPage]', {}, 'MoinMoin:FrontPage'),
+            ('[wiki:MoinMoin/FrontPage]', {}, 'MoinMoin:FrontPage'),
             ('some_text', {}, 'some_text'),
             ('["some_text"]', {}, '[[some_text]]'),
             ('some_page', rename_some_page, 'some_page'), # not a link
             ('{{{["some_page"]}}}', rename_some_page, '{{{["some_page"]}}}'), # not a link
             ('`["some_page"]`', rename_some_page, '`["some_page"]`'), # not a link
             ('["OtherPage/some_page"]', rename_some_page, '[[OtherPage/some_page]]'), # different link
-            # XXX TODO ('MoinMaster:some_page', rename_some_page, 'MoinMaster:some_page'), # external link
+            ('MoinMaster:some_page', rename_some_page, 'MoinMaster:some_page'), # external link
             ('http://some_server/some_page', rename_some_page, 'http://some_server/some_page'), # external link
             ('[http://some_server/some_page]', rename_some_page, '[[http://some_server/some_page]]'), # external link
+            ('[http://some_server/some_page foo]', rename_some_page, '[[http://some_server/some_page|foo]]'), # external link
             ('[#some_page]', rename_some_page, '[[#some_page]]'), # link to anchor that has same name
             ('[attachment:some_page.png]', rename_some_page, '[[attachment:some_page.png]]'), # att, not page
             ('[attachment:some_page.png test picture]', rename_some_page, '[[attachment:some_page.png|test picture]]'), # att, not page
@@ -101,8 +89,8 @@
             ('[:other page]', {}, '[[other page]]'),
             ('[:other page:]', {}, '[[other page]]'),
             ('[:other page:other text]', {}, '[[other page|other text]]'),
-            # XXX TODO ('Self:CamelCase', {}, 'CamelCase'),
-            # XXX TODO ('[wiki:WikiPedia:Lynx_%28web_browser%29 Lynx]', {}, '[[WikiPedia:Lynx_(web_browser)|Lynx]]'),
+            ('Self:CamelCase', {}, 'CamelCase'),
+            ('[wiki:WikiPedia:Lynx_%28web_browser%29 Lynx]', {}, '[[WikiPedia:Lynx_(web_browser)|Lynx]]'),
             ('[:Something:Something]', {}, '[[Something]]'), # optimize markup
 
             # "nothing changed" checks