changeset 199:c4da076b6cbe

link converter: fix interwiki link conversion, add test
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 30 Apr 2011 01:02:09 +0200
parents ade15b9e74fd
children af91f53c87e8
files MoinMoin/_tests/wikiconfig.py MoinMoin/converter/_tests/test_link.py MoinMoin/converter/link.py
diffstat 3 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/wikiconfig.py	Fri Apr 29 23:17:03 2011 +0200
+++ b/MoinMoin/_tests/wikiconfig.py	Sat Apr 30 01:02:09 2011 +0200
@@ -22,4 +22,5 @@
     _test_items_xml = join(_here, 'testitems.xml')
     content_acl = None
     item_root = 'FrontPage'
+    interwiki_map = dict(MoinMoin='http://moinmo.in/')
 
--- a/MoinMoin/converter/_tests/test_link.py	Fri Apr 29 23:17:03 2011 +0200
+++ b/MoinMoin/converter/_tests/test_link.py	Sat Apr 30 01:02:09 2011 +0200
@@ -10,6 +10,8 @@
 
 from emeraldtree import tree as ET
 
+from flask import current_app as app
+
 from MoinMoin.converter.link import *
 from MoinMoin.util.iri import Iri
 
@@ -19,6 +21,7 @@
         self.conv = ConverterExternOutput(url_root=url_root)
 
     def test_wiki(self):
+        assert 'MoinMoin' in app.cfg.interwiki_map
         pairs = [
             ('wiki:///Test',
                 './Test'),
@@ -28,6 +31,8 @@
                 './Test#anchor'),
             ('wiki:///Test?mode=raw#anchor',
                 './Test?mode=raw#anchor'),
+            ('wiki://MoinMoin/Test',
+                'http://moinmo.in/Test'),
         ]
         for i in pairs:
             yield (self._do_wiki, ) + i
--- a/MoinMoin/converter/link.py	Fri Apr 29 23:17:03 2011 +0200
+++ b/MoinMoin/converter/link.py	Sat Apr 30 01:02:09 2011 +0200
@@ -137,9 +137,9 @@
         do, query = self._get_do(input.query)
         link = Iri(query=query, fragment=input.fragment)
 
-        if input.authority:
+        if input.authority and input.authority.host:
             # interwiki link
-            wikitag, wikiurl, wikitail, err = resolve_interwiki(input.authority, input.path[1:])
+            wikitag, wikiurl, wikitail, err = resolve_interwiki(unicode(input.authority.host), unicode(input.path[1:]))
             if not err:
                 elem.set(html.class_, 'interwiki')
                 if do is not None: