annotate tests/test_resolver.py @ 454:07a930afd21a

web: Fix the reference to the Jouvence CSS.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 10 Jan 2018 20:08:26 -0800
parents 666a9d0981bb
children 1dc6a0a74da3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 from tests import WikkedTest, format_link, format_include
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 class ResolverTest(WikkedTest):
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 def testPageInclude(self):
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
6 wiki = self._getWikiFromStructure({
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
7 '/foo.txt': "A test page.\n{{include: trans-desc}}\n",
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
8 '/trans-desc.txt': "BLAH\n"
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 })
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
10 foo = wiki.getPage('/foo')
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
11 self.assertEqual({'include': ['trans-desc']}, foo.getLocalMeta())
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 self.assertEqual(
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 "A test page.\n%s" % format_include('trans-desc'),
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
14 foo.getFormattedText())
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
15 self.assertEqual("A test page.\nBLAH", foo.text)
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 def testPageIncludeWithMeta(self):
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
18 wiki = self._getWikiFromStructure({
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
19 'foo.txt': "A test page.\n{{include: trans-desc}}\n",
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
20 'trans-desc.txt': "BLAH: [[Somewhere]]\n{{bar: 42}}\n{{__secret: love}}\n{{+given: hope}}"
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 })
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
22 foo = wiki.getPage('/foo')
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
23 self.assertEqual([], foo.getLocalLinks())
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
24 self.assertEqual({'include': ['trans-desc']}, foo.getLocalMeta())
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25 self.assertEqual(
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26 "A test page.\n%s" % format_include('trans-desc'),
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
27 foo.getFormattedText())
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 self.assertEqual(
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
29 "A test page.\nBLAH: %s\n\n" % format_link('Somewhere', '/Somewhere', True),
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
30 foo.text)
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
31 self.assertEqual(['/Somewhere'], foo.links)
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
32 self.assertEqual({'bar': ['42'], 'given': ['hope'], 'include': ['trans-desc']}, foo.getMeta())
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
33
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
34 def testPageIncludeWithNamedTemplating(self):
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
35 wiki = self._getWikiFromStructure({
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
36 'foo.txt': "A test page.\n{{include: greeting|name=Dave|what=drink}}\n",
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
37 'greeting.txt': "Hello {{name}}, would you like a {{what}}?"
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
38 })
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
39 foo = wiki.getPage('/foo')
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
40 self.assertEqual(
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
41 "A test page.\n%s" % format_include(
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
42 'greeting',
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
43 '<div class="wiki-param" data-name="name">Dave</div><div class="wiki-param" data-name="what">drink</div>'),
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
44 foo.getFormattedText())
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
45 self.assertEqual("A test page.\nHello Dave, would you like a drink?", foo.text)
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
46
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
47 def testPageIncludeWithNumberedTemplating(self):
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
48 wiki = self._getWikiFromStructure({
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
49 'foo.txt': "A test page.\n{{include: greeting|Dave|Roger|Tom}}\n",
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
50 'greeting.txt': "Hello {{__args[0]}}, {{__args[1]}} and {{__args[2]}}."
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
51 })
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
52 foo = wiki.getPage('/foo')
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
53 self.assertEqual(
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
54 "A test page.\n%s" % format_include(
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
55 'greeting',
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
56 '<div class="wiki-param" data-name="">Dave</div><div class="wiki-param" data-name="">Roger</div><div class="wiki-param" data-name="">Tom</div>'),
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
57 foo.getFormattedText())
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
58 self.assertEqual("A test page.\nHello Dave, Roger and Tom.", foo.text)
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
59
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
60 def testIncludeWithPageReferenceTemplating(self):
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
61 wiki =self._getWikiFromStructure({
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
62 'selfref.txt': "Here is {{read_url(__page.url, __page.title)}}!",
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
63 'foo.txt': "Hello here.\n{{include: selfref}}\n"
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
64 })
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
65 foo = wiki.getPage('/foo')
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
66 self.assertEqual(
357
666a9d0981bb Quick fixes for the unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents: 225
diff changeset
67 'Hello here.\nHere is <a class="wiki-link" data-wiki-url="/foo" href="/read/foo">foo</a>!',
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
68 foo.text
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
69 )
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
70
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
71 def testGivenOnlyInclude(self):
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
72 wiki = self._getWikiFromStructure({
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
73 'Base.txt': "The base page.\n{{include: Template 1}}",
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
74 'Template 1.txt': "TEMPLATE!\n{{+include: Template 2}}",
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
75 'Template 2.txt': "MORE TEMPLATE!"
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
76 })
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
77 tpl1 = wiki.getPage('/Template 1')
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
78 self.assertEqual(
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
79 "TEMPLATE!\n%s" % format_include('Template 2', mod='+'),
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
80 tpl1.getFormattedText())
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
81 self.assertEqual("TEMPLATE!\n", tpl1.text)
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
82 base = wiki.getPage('/Base')
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
83 self.assertEqual("The base page.\nTEMPLATE!\nMORE TEMPLATE!", base.text)
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
84
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
85 def testDoublePageIncludeWithMeta(self):
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
86 return
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
87 wiki = self._getWikiFromStructure({
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
88 'Base.txt': "The base page.\n{{include: Template 1}}",
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
89 'Wrong.txt': "{{include: Template 2}}",
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
90 'Template 1.txt': "{{foo: bar}}\n{{+category: blah}}\n{{+include: Template 2}}\n{{__secret1: ssh}}",
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
91 'Template 2.txt': "{{+category: yolo}}",
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
92 'Query 1.txt': "{{query: category=yolo}}",
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
93 'Query 2.txt': "{{query: category=blah}}"
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
94 })
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
95 base = wiki.getPage('/Base')
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
96 self.assertEqual({
84
ca57fef14d04 Formatter/resolver changes:
Ludovic Chabant <ludovic@chabant.com>
parents: 83
diff changeset
97 'foo': ['bar'],
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
98 'category': ['blah', 'yolo']
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
99 }, base.getMeta())
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
100 tpl1 = wiki.getPage('/Template 1')
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
101 self.assertEqual({
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
102 'foo': ['bar'],
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
103 '+category': ['blah'],
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
104 '+include': ['Template 1'],
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
105 '__secret': ['ssh']
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
106 }, tpl1.getMeta())
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
107 self.assertEqual(
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
108 "\n\n%s\n\n" % format_include('/Template 2'),
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
109 tpl1.text)
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
110 q1 = wiki.getPage('query-1')
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
111 self.assertEqual(
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
112 "<ul>\n<li>%s</li>\n<li>%s</li>\n</ul>" % (format_link('Base', '/Base'), format_link('Wrong', '/Wrong')),
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
113 q1.text)
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
114 q2 = wiki.getPage('query-2')
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
115 self.assertEqual(
225
ebb12ff21cb2 Updated unit tests to be able to run.
Ludovic Chabant <ludovic@chabant.com>
parents: 84
diff changeset
116 "<ul>\n<li>%s</li>\n</ul>" % format_link('Base', '/Base'),
83
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
117 q2.text)
65f83a9b42f1 Added support for numbered template parameters.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
118