annotate MoinMoin/script/migration/_tests/test_conv160_wiki.py @ 2610:ffe8c2d9a4ba

1.6 converter: only convert current rev of a page, added commented failing test cases
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 06 Aug 2007 01:40:09 +0200
parents 7aac9e2ecb3a
children 7ed38f2af242 82b0e4625f90
rev   line source
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - tests of wiki content conversion
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
2606
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
5 TODO:
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
6 * add some ../some_page test
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
7 * add some /some_page test
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
8 * fix parser/converter anchor link handling
2608
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
9 * emit a warning if we find some page name that was renamed as a macro argument?
2606
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
10 * shall we support camelcase renaming?
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
11
2608
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
12 Limitations of this converter:
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
13 * converter does not touch "pre sections", thus markup examples in {{{ }}}
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
14 or ` ` will have to get handled manually.
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
15 * converter does not touch macro arguments, they will have to get handled
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
16 manually
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
17
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 @copyright: 2007 MoinMoin:ThomasWaldmann
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 @license: GNU GPL, see COPYING for details.
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 """
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 from MoinMoin.script.migration._conv160_wiki import convert_wiki
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 def test_wiki_conversion(request):
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 pagename = 'TestPage'
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 rename_some_page = {
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 ('PAGE', 'some_page'): 'some page',
2606
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
28 # NEEDED? ('PAGE', 'RenameThis'): 'ThisRenamed',
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 }
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 rename_some_file = {
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 ('FILE', pagename, 'with_underscore'): 'without underscore',
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 ('FILE', pagename, 'with blank'): 'without_blank',
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 }
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 tests = [
2606
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
35 # NEEDED? ('CamelCase', {}, 'CamelCase'),
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
36 # FAILS ('RenameThis', rename_some_page, 'ThisRenamed'),
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
37 # NEEDED? ('!RenameThis', {}, '!RenameThis'), # not a link
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
38
2610
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
39 # FAILING tests:
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
40 #('[wiki:/OtherPage]', rename_some_page, '[wiki:/OtherPage]'),
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
41 #('[wiki:/OtherPage other page]', rename_some_page, '[wiki:/OtherPage other page]'),
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
42 # ('[:Something:Something]', {}, '["Something"]'),
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
43 #('[attachment:My%20Attachment.jpg:it works]', {}, '[attachment:"My Attachment.jpg" it works]'),
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
44 #('[wiki:LinuxWiki: LinuxWiki.de]', {}, '[wiki:LinuxWiki: LinuxWiki.de]'),
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
45 #('[:MeatBall:CleanLinking meatball-wiki: clean linking]', {}, '[:MeatBall:CleanLinking meatball-wiki: clean linking]'),
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
46
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
47 # ambiguity!!! can be resolved with some interwiki map lookup
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
48 # and transformed to wiki:SeaPig:BrianDorsey if SeaPig is in
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
49 # interwiki map, but no page SeaPig exists.
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
50 #('[wiki:MacroMarket/EmbedObject EO]', {}, '["MacroMarket/EmbedObject" EO]'),
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
51 ('[wiki:SeaPig/BrianDorsey]', {}, '[wiki:SeaPig:BrianDorsey]'),
ffe8c2d9a4ba 1.6 converter: only convert current rev of a page, added commented failing test cases
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2609
diff changeset
52
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 # "nothing changed" checks
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
54 ('', {}, ''),
2604
27f06531a91b 1.6 converter: improve content conversion, give request obj to converter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2603
diff changeset
55 ('MoinMaster:CamelCase', {}, 'MoinMaster:CamelCase'),
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56 ('some_text', {}, 'some_text'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 ('["some_text"]', {}, '["some_text"]'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 ('some_page', rename_some_page, 'some_page'), # not a link
2606
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
59 ('{{{["some_page"]}}}', rename_some_page, '{{{["some_page"]}}}'), # not a link
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
60 ('`["some_page"]`', rename_some_page, '`["some_page"]`'), # not a link
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
61 ('["OtherPage/some_page"]', rename_some_page, '["OtherPage/some_page"]'), # different link
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
62 ('MoinMaster:some_page', rename_some_page, 'MoinMaster:some_page'), # external link
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
63 ('http://some_server/some_page', rename_some_page, 'http://some_server/some_page'), # external link
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
64 ('[http://some_server/some_page]', rename_some_page, '[http://some_server/some_page]'), # external link
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
65 ('[#some_page]', rename_some_page, '[#some_page]'), # link to anchor that has same name
2608
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
66 ('[attachment:some_page.png]', rename_some_page, '[attachment:some_page.png]'), # att, not page
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
67 ('[attachment:some_page.png test picture]', rename_some_page, '[attachment:some_page.png test picture]'), # att, not page
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
68 ('[attachment:some_page.txt attachment:some_page.png]', rename_some_page, '[attachment:some_page.txt attachment:some_page.png]'),
2603
c61c10e3fcde 1.6 converter: improve content conversion, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2602
diff changeset
69
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 # page rename changes result
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 ('["some_page"]', rename_some_page, '["some page"]'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72 ('[:some_page]', rename_some_page, '["some page"]'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73 ('[:some_page:]', rename_some_page, '["some page"]'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74 ('[:some_page:some text]', rename_some_page, '["some page" some text]'),
2603
c61c10e3fcde 1.6 converter: improve content conversion, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2602
diff changeset
75 ('Self:some_page', rename_some_page, '["some page"]'),
c61c10e3fcde 1.6 converter: improve content conversion, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2602
diff changeset
76 ('wiki:Self:some_page', rename_some_page, '["some page"]'),
2608
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
77 ('[wiki:Self:some_page some text]', rename_some_page, '["some page" some text]'),
2606
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
78 # XXX FAILS ('wiki:Self:some_page#some_anchor', rename_some_page, '["some page"#some_anchor]'),
2603
c61c10e3fcde 1.6 converter: improve content conversion, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2602
diff changeset
79
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
80 # other markup changes we do
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
81 ('[:other page]', {}, '["other page"]'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82 ('[:other page:]', {}, '["other page"]'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
83 ('[:other page:other text]', {}, '["other page" other text]'),
2603
c61c10e3fcde 1.6 converter: improve content conversion, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2602
diff changeset
84 # FAILS ('Self:CamelCase', {}, 'CamelCase'),
2608
3ff3beef1edf 1.6 converter: add more tests, fixed bugs, better quoting, cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2606
diff changeset
85 ('[wiki:WikiPedia:Lynx_%28web_browser%29 Lynx]', {}, '[wiki:WikiPedia:"Lynx_(web_browser)" Lynx]'),
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
86
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
87 # "nothing changed" checks
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
88 ('attachment:OtherPage/with_underscore', rename_some_file, 'attachment:OtherPage/with_underscore'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
89
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
90 # file rename changes result
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
91 ('attachment:with_underscore', rename_some_file, 'attachment:"without underscore"'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
92 ('attachment:TestPage/with_underscore', rename_some_file, 'attachment:"without underscore"'), # remove superfluous pagename
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
93
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
94 # attachment syntax: kill %20
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
95 ('attachment:with%20blank', rename_some_file, 'attachment:without_blank'), # plus rename
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
96 ('attachment:keep%20blank', rename_some_file, 'attachment:"keep blank"'), # no rename
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
97 ('attachment:TestPage/keep%20blank', rename_some_file, 'attachment:"keep blank"'), # remove superfluous pagename
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
98 ('attachment:OtherPage/keep%20blank', rename_some_file, 'attachment:"OtherPage/keep blank"'),
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
99 ]
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
100 for data, renames, expected in tests:
2604
27f06531a91b 1.6 converter: improve content conversion, give request obj to converter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2603
diff changeset
101 assert convert_wiki(request, pagename, data, renames) == expected
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
102