diff MoinMoin/script/migration/_tests/test_conv160a_wiki.py @ 4490:b120d9978144

1.6.0a mig script/converter: fixed inline/drawing conversion, added more tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 16 Jan 2009 12:55:31 +0100
parents a835ada897e0
children b0319cfcb1bc
line wrap: on
line diff
--- a/MoinMoin/script/migration/_tests/test_conv160a_wiki.py	Fri Jan 16 01:42:02 2009 +0100
+++ b/MoinMoin/script/migration/_tests/test_conv160a_wiki.py	Fri Jan 16 12:55:31 2009 +0100
@@ -42,6 +42,12 @@
             ("[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]]"),
+            ('[inline:text.txt]', {}, '{{attachment:text.txt}}'), # inline is now implied by {{...}}
+            ('[inline:image.jpg]', {}, '{{attachment:image.jpg}}'), # inline is now implied by {{...}}
+            ('[drawing:image]', {}, '{{drawing:image}}'),
+            ('[inline:text.txt foo]', {}, '{{attachment:text.txt|foo}}'), # inline is now implied by {{...}}
+            ('[inline:image.jpg foo]', {}, '{{attachment:image.jpg|foo}}'), # inline is now implied by {{...}}
+            ('[drawing:image foo]', {}, '{{drawing:image|foo}}'),
 
             # "nothing changed" checks (except markup)
             ('', {}, ''),
@@ -156,4 +162,262 @@
         for data, renames, expected in tests:
             assert convert_wiki(request, pagename, data, renames) == expected
 
+    def test_full_page(self):
+        #py.test.skip("not wanted right now")
+        markup_160a = u"""\
+= CamelCase =
+== Pages ==
+ 1. SomePage
+ 2. TestPage (does not link to current page)
+ 3. SomePage/SubPage
 
+## not supported on 160a
+##== Pages with anchor ==
+## 1. SomePage#anchor
+## 2. TestPage#anchor
+## 3. SomePage/SubPage#anchor
+
+= Interwiki =
+== Pages ==
+ 1. Self:SomePage
+ 2. Self:some_page
+ 3. Self:'some page'
+ 4. Self:"some page"
+ 5. MoinMoin:SomePage
+ 6. MoinMoin:some_page
+ 7. MoinMoin:'some page'
+ 8. MoinMoin:"some page"
+
+== Pages with anchor ==
+ 1. Self:SomePage#anchor
+ 2. Self:some_page#anchor
+ 3. Self:'some page#anchor'
+ 4. Self:"some page#anchor"
+ 5. MoinMoin:SomePage#anchor
+ 6. MoinMoin:some_page#anchor
+ 7. MoinMoin:'some page#anchor'
+ 8. MoinMoin:"some page#anchor"
+
+== Invalid wiki name ==
+ 1. Doesnotexist:CamelCase (shall not link)
+ 2. Foo:bar (shall not link)
+
+= URL =
+== simple ==
+ 1. http://moinmo.in/MoinMoin
+ 2. http://static.moinmo.in/logos/moinmoin.png (renders image in 160a)
+ 3. mailto:someone@example.org
+ 4. wiki:Self:some_page
+
+== with anchor ==
+ 1. http://moinmo.in/MoinMoin#anchor
+ 2. wiki:Self:some_page#anchor
+
+= bracketed link =
+== Page ==
+ 1. ["some page"]
+ 2. ["some page" somepage]
+ 3. ['some page' somepage]
+ 4. ["/Subpage"]
+ 5. ["SomePage/Subpage"]
+ 6. ['SomePage/Subpage' Some Page]
+
+== Page with anchor ==
+ 1. ["some page#anchor"]
+ 2. ["some page#anchor" somepage]
+ 3. ['some page#anchor' somepage]
+ 4. ["/Subpage#anchor"]
+ 5. ["SomePage/Subpage#anchor"]
+ 6. ['SomePage/Subpage#anchor' Some Page]
+
+== Anchor on current page ==
+ 1. [#anchor]
+## 1. [TestPage#anchor]  not supported on 160a
+
+== URL ==
+ 1. [http://some_server/some_page]
+ 2. [http://some_server/some_page some page]
+ 3. [wiki:MoinMoin/FrontPage]
+ 4. [wiki:Self:some_page some page]
+ 5. [wiki:WikiPedia:Lynx_(web_browser) Lynx]
+ 6. [:some_page]
+ 7. [:some_page:]
+ 8. [:some_page:some page]
+ 9. [:Something:Something]
+
+== URL with anchor ==
+ 1. [http://some_server/some_page#anchor]
+ 2. [http://some_server/some_page#anchor some page]
+ 3. [wiki:MoinMoin/FrontPage#anchor]
+ 4. [wiki:Self:some_page#anchor some page]
+ 5. [wiki:WikiPedia:Lynx_(web_browser)#anchor Lynx]
+ 6. [:some_page#anchor]
+ 7. [:some_page#anchor:]
+ 8. [:some_page#anchor:some page]
+ 9. [:Something#anchor:Something]
+
+= preformatted =
+ 1. {{{["some_page"]}}} (converter shall not change pre content)
+ 2. `["some_page"]` (converter shall not change pre content)
+
+= Attachments, Drawings, Images =
+== simple ==
+ 1. attachment:text.txt is linking
+ 2. inline:text.txt is embedding
+ 3. attachment:image.png is embedding
+ 4. inline:image.png is embedding
+ 5. drawing:image is embedding
+
+== bracketed ==
+ 1. [attachment:text.txt] is linking
+ 2. [inline:text.txt] is embedding
+ 3. [attachment:image.png] is linking
+ 4. [drawing:image] is embedding png image
+ 5. [inline:image.png] is showing binary content as text in 160a (wrong)
+
+== bracketed with label ==
+ 1. [attachment:text.txt some label] is linking
+ 2. [inline:text.txt some label] is embedding
+ 3. [attachment:image.png some label] is linking
+ 4. [drawing:image some label] is embedding png image
+ 5. [inline:image.png some label] is showing binary content as text in 160a (wrong)
+
+== bracketed, on other page, with label ==
+ 1. [attachment:SomePage/text.txt some label] is linking
+ 2. [inline:SomePage/text.txt some label] is embedding
+ 3. [attachment:SomePage/image.png some label] is linking
+ 4. [drawing:SomePage/image some label] is embedding png image
+ 5. [inline:SomePage/image.png some label] is showing binary content as text in 160a (wrong)
+
+"""
+        expected_markup_160 = u"""\
+= CamelCase =
+== Pages ==
+ 1. SomePage
+ 2. TestPage (does not link to current page)
+ 3. [[SomePage/SubPage]]
+
+## not supported on 160a
+##== Pages with anchor ==
+## 1. SomePage#anchor
+## 2. TestPage#anchor
+## 3. SomePage/SubPage#anchor
+
+= Interwiki =
+== Pages ==
+ 1. SomePage
+ 2. [[some_page]]
+ 3. [[some page]]
+ 4. [[some page]]
+ 5. MoinMoin:SomePage
+ 6. MoinMoin:some_page
+ 7. [[MoinMoin:some page]]
+ 8. [[MoinMoin:some page]]
+
+== Pages with anchor ==
+ 1. [[SomePage#anchor]]
+ 2. [[some_page#anchor]]
+ 3. [[some page#anchor]]
+ 4. [[some page#anchor]]
+ 5. MoinMoin:SomePage#anchor
+ 6. MoinMoin:some_page#anchor
+ 7. [[MoinMoin:some page#anchor]]
+ 8. [[MoinMoin:some page#anchor]]
+
+== Invalid wiki name ==
+ 1. Doesnotexist:CamelCase (shall not link)
+ 2. Foo:bar (shall not link)
+
+= URL =
+== simple ==
+ 1. http://moinmo.in/MoinMoin
+ 2. {{http://static.moinmo.in/logos/moinmoin.png}} (renders image in 160a)
+ 3. mailto:someone@example.org
+ 4. [[some_page]]
+
+== with anchor ==
+ 1. http://moinmo.in/MoinMoin#anchor
+ 2. [[some_page#anchor]]
+
+= bracketed link =
+== Page ==
+ 1. [[some page]]
+ 2. [[some page|somepage]]
+ 3. [[some page|somepage]]
+ 4. [[/Subpage]]
+ 5. [[SomePage/Subpage]]
+ 6. [[SomePage/Subpage|Some Page]]
+
+== Page with anchor ==
+ 1. [[some page#anchor]]
+ 2. [[some page#anchor|somepage]]
+ 3. [[some page#anchor|somepage]]
+ 4. [[/Subpage#anchor]]
+ 5. [[SomePage/Subpage#anchor]]
+ 6. [[SomePage/Subpage#anchor|Some Page]]
+
+== Anchor on current page ==
+ 1. [[#anchor]]
+## 1. [TestPage#anchor]  not supported on 160a
+
+== URL ==
+ 1. [[http://some_server/some_page]]
+ 2. [[http://some_server/some_page|some page]]
+ 3. MoinMoin:FrontPage
+ 4. [[some_page|some page]]
+ 5. [[WikiPedia:Lynx_(web_browser)|Lynx]]
+ 6. [[some_page]]
+ 7. [[some_page]]
+ 8. [[some_page|some page]]
+ 9. [[Something]]
+
+== URL with anchor ==
+ 1. [[http://some_server/some_page#anchor]]
+ 2. [[http://some_server/some_page#anchor|some page]]
+ 3. MoinMoin:FrontPage#anchor
+ 4. [[some_page#anchor|some page]]
+ 5. [[WikiPedia:Lynx_(web_browser)#anchor|Lynx]]
+ 6. [[some_page#anchor]]
+ 7. [[some_page#anchor]]
+ 8. [[some_page#anchor|some page]]
+ 9. [[Something#anchor|Something]]
+
+= preformatted =
+ 1. {{{["some_page"]}}} (converter shall not change pre content)
+ 2. `["some_page"]` (converter shall not change pre content)
+
+= Attachments, Drawings, Images =
+== simple ==
+ 1. [[attachment:text.txt]] is linking
+ 2. {{attachment:text.txt}} is embedding
+ 3. {{attachment:image.png}} is embedding
+ 4. {{attachment:image.png}} is embedding
+ 5. {{drawing:image}} is embedding
+
+== bracketed ==
+ 1. [[attachment:text.txt]] is linking
+ 2. {{attachment:text.txt}} is embedding
+ 3. [[attachment:image.png]] is linking
+ 4. {{drawing:image}} is embedding png image
+ 5. {{attachment:image.png}} is showing binary content as text in 160a (wrong)
+
+== bracketed with label ==
+ 1. [[attachment:text.txt|some label]] is linking
+ 2. {{attachment:text.txt|some label}} is embedding
+ 3. [[attachment:image.png|some label]] is linking
+ 4. {{drawing:image|some label}} is embedding png image
+ 5. {{attachment:image.png|some label}} is showing binary content as text in 160a (wrong)
+
+== bracketed, on other page, with label ==
+ 1. [[attachment:SomePage/text.txt|some label]] is linking
+ 2. {{attachment:SomePage/text.txt|some label}} is embedding
+ 3. [[attachment:SomePage/image.png|some label]] is linking
+ 4. {{drawing:SomePage/image|some label}} is embedding png image
+ 5. {{attachment:SomePage/image.png|some label}} is showing binary content as text in 160a (wrong)
+
+"""
+        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
+