39
|
1 import unittest
|
|
2
|
|
3 from trac.wiki.api import WikiSystem
|
|
4 from trac.wiki.model import WikiPage
|
|
5 from trac.wiki.tests import formatter
|
|
6
|
|
7 TEST_CASES=u"""
|
|
8 ============================== wiki: link resolver
|
|
9 wiki:TestPage
|
|
10 wiki:TestPage/
|
|
11 wiki:"Space 1 23"
|
|
12 wiki:"C'est l'\xe9t\xe9"
|
|
13 wiki:MissingPage
|
|
14 wiki:12
|
|
15 wiki:abc
|
|
16 ------------------------------
|
|
17 <p>
|
|
18 <a class="wiki" href="/wiki/TestPage">wiki:TestPage</a>
|
|
19 <a class="wiki" href="/wiki/TestPage">wiki:TestPage/</a>
|
|
20 <a class="wiki" href="/wiki/Space%201%2023">wiki:"Space 1 23"</a>
|
|
21 <a class="wiki" href="/wiki/C%27est%20l%27%C3%A9t%C3%A9">wiki:"C'est l'\xe9t\xe9"</a>
|
|
22 <a class="missing wiki" href="/wiki/MissingPage" rel="nofollow">wiki:MissingPage?</a>
|
|
23 <a class="missing wiki" href="/wiki/12" rel="nofollow">wiki:12?</a>
|
|
24 <a class="missing wiki" href="/wiki/abc" rel="nofollow">wiki:abc?</a>
|
|
25 </p>
|
|
26 ------------------------------
|
|
27 ============================== WikiPageNames conformance
|
|
28 CamelCase AlabamA ABc AlaBamA FooBar
|
|
29 ------------------------------
|
|
30 <p>
|
|
31 <a class="missing wiki" href="/wiki/CamelCase" rel="nofollow">CamelCase?</a> AlabamA ABc AlaBamA <a class="missing wiki" href="/wiki/FooBar" rel="nofollow">FooBar?</a>
|
|
32 </p>
|
|
33 ------------------------------
|
|
34 ============================== More WikiPageNames conformance
|
|
35 CamelCase,CamelCase.CamelCase: CamelCase
|
|
36 ------------------------------
|
|
37 <p>
|
|
38 <a class="missing wiki" href="/wiki/CamelCase" rel="nofollow">CamelCase?</a>,<a class="missing wiki" href="/wiki/CamelCase" rel="nofollow">CamelCase?</a>.<a class="missing wiki" href="/wiki/CamelCase" rel="nofollow">CamelCase?</a>: <a class="missing wiki" href="/wiki/CamelCase" rel="nofollow">CamelCase?</a>
|
|
39 </p>
|
|
40 ------------------------------
|
|
41 ============================== Escaping WikiPageNames
|
|
42 !CamelCase
|
|
43 ------------------------------
|
|
44 <p>
|
|
45 CamelCase
|
|
46 </p>
|
|
47 ------------------------------
|
|
48 ============================== WikiPageNames endings
|
|
49 foo (FooBar)
|
|
50
|
|
51 foo (FooBar )
|
|
52 ------------------------------
|
|
53 <p>
|
|
54 foo (<a class="missing wiki" href="/wiki/FooBar" rel="nofollow">FooBar?</a>)
|
|
55 </p>
|
|
56 <p>
|
|
57 foo (<a class="missing wiki" href="/wiki/FooBar" rel="nofollow">FooBar?</a> )
|
|
58 </p>
|
|
59 ------------------------------
|
|
60 ============================== WikiPageNames counter examples
|
|
61 A0B1, ST62T53C6, IR32V1H000
|
|
62 ------------------------------
|
|
63 <p>
|
|
64 A0B1, ST62T53C6, IR32V1H000
|
|
65 </p>
|
|
66 ------------------------------
|
|
67 ============================== WikiPageNames trailing characters
|
|
68 SandBox SandBox, SandBox; SandBox: SandBox. SandBox? SandBox! (SandBox) {SandBox} [SandBox]
|
|
69 ------------------------------
|
|
70 <p>
|
|
71 <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a> <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>, <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>; <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>: <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>. <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>? <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>! (<a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>) {<a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>} <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>
|
|
72 </p>
|
|
73 ------------------------------
|
|
74 ============================== WikiPageNames counter examples (paths)
|
|
75 /absolute/path/is/NotWiki and relative/path/is/NotWiki
|
|
76 /ThisIsNotWikiEither and /ThisIs/NotWikiEither but ThisIs/SubWiki
|
|
77 ------------------------------
|
|
78 <p>
|
|
79 /absolute/path/is/NotWiki and relative/path/is/NotWiki
|
|
80 /ThisIsNotWikiEither and /ThisIs/NotWikiEither but <a class="missing wiki" href="/wiki/ThisIs/SubWiki" rel="nofollow">ThisIs/SubWiki?</a>
|
|
81 </p>
|
|
82 ------------------------------
|
|
83 ============================== WikiPageNames counter examples (numbers)
|
|
84 8FjBpOmy
|
|
85 anotherWikiPageName
|
|
86 ------------------------------
|
|
87 <p>
|
|
88 8FjBpOmy
|
|
89 anotherWikiPageName
|
|
90 </p>
|
|
91 ------------------------------
|
|
92 8FjBpOmy
|
|
93 anotherWikiPageName
|
|
94 ============================== MoinMoin style forced links
|
|
95 This is a ["Wiki"] page link.
|
|
96 ------------------------------
|
|
97 <p>
|
|
98 This is a <a class="missing wiki" href="/wiki/Wiki" rel="nofollow">Wiki?</a> page link.
|
|
99 </p>
|
|
100 ------------------------------
|
|
101 ============================== InterTrac for wiki
|
|
102 t:wiki:InterTrac
|
|
103 trac:wiki:InterTrac
|
|
104 [t:wiki:InterTrac intertrac]
|
|
105 [trac:wiki:InterTrac intertrac]
|
|
106 ------------------------------
|
|
107 <p>
|
|
108 <a class="ext-link" href="http://projects.edgewall.com/trac/wiki/InterTrac" title="wiki:InterTrac in Trac's Trac"><span class="icon">t:wiki:InterTrac</span></a>
|
|
109 <a class="ext-link" href="http://projects.edgewall.com/trac/wiki/InterTrac" title="wiki:InterTrac in Trac's Trac"><span class="icon">trac:wiki:InterTrac</span></a>
|
|
110 <a class="ext-link" href="http://projects.edgewall.com/trac/wiki/InterTrac" title="wiki:InterTrac in Trac's Trac"><span class="icon">intertrac</span></a>
|
|
111 <a class="ext-link" href="http://projects.edgewall.com/trac/wiki/InterTrac" title="wiki:InterTrac in Trac's Trac"><span class="icon">intertrac</span></a>
|
|
112 </p>
|
|
113 ------------------------------
|
|
114 ============================== Wiki InterTrac shorthands
|
|
115 t:InterTrac
|
|
116 trac:InterTrac
|
|
117 [t:InterTrac intertrac]
|
|
118 [trac:InterTrac intertrac]
|
|
119 ------------------------------
|
|
120 <p>
|
|
121 <a class="ext-link" href="http://projects.edgewall.com/trac/search?q=InterTrac" title="InterTrac in Trac's Trac"><span class="icon">t:InterTrac</span></a>
|
|
122 <a class="ext-link" href="http://projects.edgewall.com/trac/search?q=InterTrac" title="InterTrac in Trac's Trac"><span class="icon">trac:InterTrac</span></a>
|
|
123 <a class="ext-link" href="http://projects.edgewall.com/trac/search?q=InterTrac" title="InterTrac in Trac's Trac"><span class="icon">intertrac</span></a>
|
|
124 <a class="ext-link" href="http://projects.edgewall.com/trac/search?q=InterTrac" title="InterTrac in Trac's Trac"><span class="icon">intertrac</span></a>
|
|
125 </p>
|
|
126 ------------------------------
|
|
127 """
|
|
128
|
|
129 def wiki_setup(tc):
|
|
130 wiki1 = WikiPage(tc.env)
|
|
131 wiki1.name = 'TestPage'
|
|
132 wiki1.text = '--'
|
|
133 wiki1.save('joe', 'normal WikiPageNames', '::1', 42)
|
|
134
|
|
135 wiki2 = WikiPage(tc.env)
|
|
136 wiki2.name = 'Space 1 23'
|
|
137 wiki2.text = '--'
|
|
138 wiki2.save('joe', 'not a WikiPageNames', '::1', 42)
|
|
139
|
|
140 wiki3 = WikiPage(tc.env)
|
|
141 wiki3.name = u"C'est l'\xe9t\xe9"
|
|
142 wiki3.text = '--'
|
|
143 wiki3.save('joe', 'unicode WikiPageNames', '::1', 42)
|
|
144
|
|
145 def suite():
|
|
146 return formatter.suite(TEST_CASES, wiki_setup, __file__)
|
|
147
|
|
148 if __name__ == '__main__':
|
|
149 unittest.main(defaultTest='suite')
|