annotate MoinMoin/script/migration/_tests/test_conv160_wiki.py @ 2606:482f0a9e555c

1.6 converter: add more tests, TODO, fixed sourcecode test failure
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 05 Aug 2007 14:47:10 +0200
parents 27f06531a91b
children 3ff3beef1edf
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
482f0a9e555c 1.6 converter: add more tests, TODO, fixed sourcecode test failure
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2604
diff changeset
9 * emit a warning if we find some page name that was renamed as a macro argument
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
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 @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
13 @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
14 """
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 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
17
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 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
19 pagename = 'TestPage'
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 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
21 ('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
22 # 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
23 }
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 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
25 ('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
26 ('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
27 }
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 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
29 # 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
30 # 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
31 # 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
32
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 # "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
34 ('', {}, ''),
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
35 ('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
36 ('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
37 ('["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
38 ('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
39 ('{{{["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
40 ('`["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
41 ('["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
42 ('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
43 ('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
44 ('[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
45 ('[#some_page]', rename_some_page, '[#some_page]'), # link to anchor that has same name
2603
c61c10e3fcde 1.6 converter: improve content conversion, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2602
diff changeset
46
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47 # 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
48 ('["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
49 ('[: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
50 ('[: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
51 ('[: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
52 ('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
53 ('wiki:Self:some_page', rename_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
54 # 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
55 ('[wiki: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
56 ('[wiki:Self:some_page some text]', rename_some_page, '["some page" some text]'),
c61c10e3fcde 1.6 converter: improve content conversion, more tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2602
diff changeset
57
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 # 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
59 ('[: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
60 ('[: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
61 ('[: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
62 # FAILS ('Self:CamelCase', {}, 'CamelCase'),
2602
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 # "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
65 ('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
66
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67 # 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
68 ('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
69 ('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
70
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 # 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
72 ('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
73 ('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
74 ('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
75 ('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
76 ]
b601db2e4d34 1.6 converter: improve content conversion, add test for it
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
77 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
78 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
79