annotate test/test_htmltemplate.py @ 1018:b0527d9c8e11

call the cookie something else since it changed
author Richard Jones <richard@users.sourceforge.net>
date Tue, 03 Sep 2002 03:23:56 +0000
parents fdcf16b444a9
children 9b910e8d987d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
1 #
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
2 # Copyright (c) 2001 Richard Jones
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
3 # This module is free software, and you may redistribute it and/or modify
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
4 # under the same terms as Python, so long as this copyright message and
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
5 # disclaimer are retained in their original form.
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
6 #
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
7 # This module is distributed in the hope that it will be useful,
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
10 #
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
11 # $Id: test_htmltemplate.py,v 1.20 2002-08-13 20:16:10 gmcm Exp $
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
12
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
13 import unittest, cgi, time, os, shutil
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
14
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
15 from roundup import date, password
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
16 from roundup.htmltemplate import IndexTemplate, ItemTemplate
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
17 from roundup import template_funcs
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
18 tf = template_funcs
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
19 from roundup.i18n import _
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
20 from roundup.hyperdb import String, Password, Date, Interval, Link, \
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
21 Multilink, Boolean, Number
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
22
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
23 class TestClass:
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
24 def get(self, nodeid, attribute, default=None):
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
25 if attribute == 'string':
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
26 return 'Node %s: I am a string'%nodeid
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
27 elif attribute == 'filename':
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
28 return 'file.foo'
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
29 elif attribute == 'date':
640
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
30 return date.Date('2000-01-01')
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
31 elif attribute == 'boolean':
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
32 return 0
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
33 elif attribute == 'number':
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
34 return 1234
640
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
35 elif attribute == 'reldate':
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
36 return date.Date() + date.Interval('- 2y 1m')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
37 elif attribute == 'interval':
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
38 return date.Interval('-3d')
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
39 elif attribute == 'link':
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
40 return '1'
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
41 elif attribute == 'multilink':
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
42 return ['1', '2']
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
43 elif attribute == 'password':
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
44 return password.Password('sekrit')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
45 elif attribute == 'key':
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
46 return 'the key'+nodeid
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
47 elif attribute == 'html':
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
48 return '<html>hello, I am HTML</html>'
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
49 elif attribute == 'multiline':
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
50 return 'hello\nworld'
829
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
51 elif attribute == 'email':
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
52 return 'test@foo.domain.example'
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
53 def list(self):
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
54 return ['1', '2']
814
9a17342a9e04 Fixed unit test support class so the tests ran again.
Richard Jones <richard@users.sourceforge.net>
parents: 722
diff changeset
55 def filter(self, search_matches, filterspec, sort, group):
9a17342a9e04 Fixed unit test support class so the tests ran again.
Richard Jones <richard@users.sourceforge.net>
parents: 722
diff changeset
56 return ['1', '2']
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
57 def getprops(self):
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
58 return {'string': String(), 'date': Date(), 'interval': Interval(),
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
59 'link': Link('other'), 'multilink': Multilink('other'),
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
60 'password': Password(), 'html': String(), 'key': String(),
640
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
61 'novalue': String(), 'filename': String(), 'multiline': String(),
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
62 'reldate': Date(), 'email': String(), 'boolean': Boolean(),
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
63 'number': Number()}
814
9a17342a9e04 Fixed unit test support class so the tests ran again.
Richard Jones <richard@users.sourceforge.net>
parents: 722
diff changeset
64 def labelprop(self, default_to_id=0):
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
65 return 'key'
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
66
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
67 class TestDatabase:
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
68 classes = {'other': TestClass()}
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
69 def getclass(self, name):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
70 return TestClass()
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
71 def __getattr(self, name):
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
72 return Class()
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
73
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
74 class TestClient:
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
75 def __init__(self):
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
76 self.db = None
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
77 self.form = None
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
78 self.write = None
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
79
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
80 class FunctionCase(unittest.TestCase):
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
81 def setUp(self):
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
82 ''' Set up the harness for calling the individual tests
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
83 '''
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
84 client = TestClient()
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
85 client.db = TestDatabase()
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
86 cl = TestClass()
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
87 self.args = (client, 'test_class', cl, cl.getprops(), '1', None)
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
88
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
89 def call(self, func, *args, **kws):
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
90 args = self.args + args
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
91 return func(*args, **kws)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
92
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
93 # def do_plain(self, property, escape=0):
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
94 def testPlain_string(self):
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
95 s = 'Node 1: I am a string'
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
96 self.assertEqual(self.call(tf.do_plain, 'string'), s)
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
97
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
98 def testPlain_password(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
99 self.assertEqual(self.call(tf.do_plain, 'password'), '*encrypted*')
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
100
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
101 def testPlain_html(self):
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
102 s = '<html>hello, I am HTML</html>'
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
103 self.assertEqual(self.call(tf.do_plain, 'html', escape=0), s)
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
104 s = cgi.escape(s)
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
105 self.assertEqual(self.call(tf.do_plain, 'html', escape=1), s)
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
106
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
107 def testPlain_date(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
108 self.assertEqual(self.call(tf.do_plain, 'date'), '2000-01-01.00:00:00')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
109
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
110 def testPlain_interval(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
111 self.assertEqual(self.call(tf.do_plain, 'interval'), '- 3d')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
112
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
113 def testPlain_link(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
114 self.assertEqual(self.call(tf.do_plain, 'link'), 'the key1')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
115
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
116 def testPlain_multilink(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
117 self.assertEqual(self.call(tf.do_plain, 'multilink'), 'the key1, the key2')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
118
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
119 def testPlain_boolean(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
120 self.assertEqual(self.call(tf.do_plain, 'boolean'), 'No')
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
121
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
122 def testPlain_number(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
123 self.assertEqual(self.call(tf.do_plain,'number'), '1234')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
124
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
125 # def do_field(self, property, size=None, showid=0):
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
126 def testField_string(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
127 self.assertEqual(self.call(tf.do_field, 'string'),
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
128 '<input name="string" value="Node 1: I am a string" size="30">')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
129 self.assertEqual(self.call(tf.do_field, 'string', size=10),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
130 '<input name="string" value="Node 1: I am a string" size="10">')
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
131
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
132 def testField_password(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
133 self.assertEqual(self.call(tf.do_field, 'password'),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
134 '<input type="password" name="password" size="30">')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
135 self.assertEqual(self.call(tf.do_field,'password', size=10),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
136 '<input type="password" name="password" size="10">')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
137
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
138 def testField_html(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
139 self.assertEqual(self.call(tf.do_field, 'html'), '<input name="html" '
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
140 'value="&lt;html&gt;hello, I am HTML&lt;/html&gt;" size="30">')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
141 self.assertEqual(self.call(tf.do_field, 'html', size=10),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
142 '<input name="html" value="&lt;html&gt;hello, I am '
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
143 'HTML&lt;/html&gt;" size="10">')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
144
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
145 def testField_date(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
146 self.assertEqual(self.call(tf.do_field, 'date'),
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
147 '<input name="date" value="2000-01-01.00:00:00" size="30">')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
148 self.assertEqual(self.call(tf.do_field, 'date', size=10),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
149 '<input name="date" value="2000-01-01.00:00:00" size="10">')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
150
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
151 def testField_interval(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
152 self.assertEqual(self.call(tf.do_field,'interval'),
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
153 '<input name="interval" value="- 3d" size="30">')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
154 self.assertEqual(self.call(tf.do_field, 'interval', size=10),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
155 '<input name="interval" value="- 3d" size="10">')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
156
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
157 def testField_link(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
158 self.assertEqual(self.call(tf.do_field, 'link'), '''<select name="link">
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
159 <option value="-1">- no selection -</option>
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
160 <option selected value="1">the key1</option>
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
161 <option value="2">the key2</option>
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
162 </select>''')
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
163
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
164 def testField_multilink(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
165 self.assertEqual(self.call(tf.do_field,'multilink'),
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
166 '<input name="multilink" size="30" value="the key1,the key2">')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
167 self.assertEqual(self.call(tf.do_field, 'multilink', size=10),
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
168 '<input name="multilink" size="10" value="the key1,the key2">')
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
169
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
170 def testField_boolean(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
171 self.assertEqual(self.call(tf.do_field, 'boolean'),
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
172 '<input type="radio" name="boolean" value="yes" >Yes<input type="radio" name="boolean" value="no" checked>No')
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
173
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
174 def testField_number(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
175 self.assertEqual(self.call(tf.do_field, 'number'),
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
176 '<input name="number" value="1234" size="30">')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
177 self.assertEqual(self.call(tf.do_field, 'number', size=10),
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
178 '<input name="number" value="1234" size="10">')
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
179
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
180 # def do_multiline(self, property, rows=5, cols=40)
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
181 def testMultiline_string(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
182 self.assertEqual(self.call(tf.do_multiline, 'multiline'),
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
183 '<textarea name="multiline" rows="5" cols="40">'
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
184 'hello\nworld</textarea>')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
185 self.assertEqual(self.call(tf.do_multiline, 'multiline', rows=10),
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
186 '<textarea name="multiline" rows="10" cols="40">'
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
187 'hello\nworld</textarea>')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
188 self.assertEqual(self.call(tf.do_multiline, 'multiline', cols=10),
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
189 '<textarea name="multiline" rows="5" cols="10">'
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
190 'hello\nworld</textarea>')
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
191
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
192 def testMultiline_nonstring(self):
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
193 s = _('[Multiline: not a string]')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
194 self.assertEqual(self.call(tf.do_multiline, 'date'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
195 self.assertEqual(self.call(tf.do_multiline, 'interval'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
196 self.assertEqual(self.call(tf.do_multiline, 'password'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
197 self.assertEqual(self.call(tf.do_multiline, 'link'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
198 self.assertEqual(self.call(tf.do_multiline, 'multilink'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
199 self.assertEqual(self.call(tf.do_multiline, 'boolean'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
200 self.assertEqual(self.call(tf.do_multiline, 'number'), s)
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
201
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
202 # def do_menu(self, property, size=None, height=None, showid=0):
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
203 def testMenu_nonlinks(self):
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
204 s = _('[Menu: not a link]')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
205 self.assertEqual(self.call(tf.do_menu, 'string'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
206 self.assertEqual(self.call(tf.do_menu, 'date'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
207 self.assertEqual(self.call(tf.do_menu, 'interval'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
208 self.assertEqual(self.call(tf.do_menu, 'password'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
209 self.assertEqual(self.call(tf.do_menu, 'boolean'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
210 self.assertEqual(self.call(tf.do_menu, 'number'), s)
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
211
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
212 def testMenu_link(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
213 self.assertEqual(self.call(tf.do_menu, 'link'), '''<select name="link">
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
214 <option value="-1">- no selection -</option>
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
215 <option selected value="1">the key1</option>
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
216 <option value="2">the key2</option>
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
217 </select>''')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
218 self.assertEqual(self.call(tf.do_menu, 'link', size=6),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
219 '''<select name="link">
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
220 <option value="-1">- no selection -</option>
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
221 <option selected value="1">the...</option>
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
222 <option value="2">the...</option>
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
223 </select>''')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
224 self.assertEqual(self.call(tf.do_menu, 'link', showid=1),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
225 '''<select name="link">
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
226 <option value="-1">- no selection -</option>
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
227 <option selected value="1">other1: the key1</option>
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
228 <option value="2">other2: the key2</option>
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
229 </select>''')
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
230
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
231 def testMenu_multilink(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
232 self.assertEqual(self.call(tf.do_menu, 'multilink', height=10),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
233 '''<select multiple name="multilink" size="10">
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
234 <option selected value="1">the key1</option>
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
235 <option selected value="2">the key2</option>
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
236 </select>''')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
237 self.assertEqual(self.call(tf.do_menu, 'multilink', size=6, height=10),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
238 '''<select multiple name="multilink" size="10">
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
239 <option selected value="1">the...</option>
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
240 <option selected value="2">the...</option>
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
241 </select>''')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
242 self.assertEqual(self.call(tf.do_menu, 'multilink', showid=1),
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
243 '''<select multiple name="multilink" size="2">
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
244 <option selected value="1">other1: the key1</option>
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
245 <option selected value="2">other2: the key2</option>
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
246 </select>''')
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
247
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
248 # def do_link(self, property=None, is_download=0):
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
249 def testLink_novalue(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
250 self.assertEqual(self.call(tf.do_link, 'novalue'),
574
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
251 _('[no %(propname)s]')%{'propname':'novalue'.capitalize()})
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
252
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
253 def testLink_string(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
254 self.assertEqual(self.call(tf.do_link, 'string'),
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
255 '<a href="test_class1">Node 1: I am a string</a>')
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
256
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
257 def testLink_file(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
258 self.assertEqual(self.call(tf.do_link, 'filename', is_download=1),
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
259 '<a href="test_class1/file.foo">file.foo</a>')
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
260
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
261 def testLink_date(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
262 self.assertEqual(self.call(tf.do_link, 'date'),
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
263 '<a href="test_class1">2000-01-01.00:00:00</a>')
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
264
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
265 def testLink_interval(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
266 self.assertEqual(self.call(tf.do_link, 'interval'),
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
267 '<a href="test_class1">- 3d</a>')
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
268
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
269 def testLink_link(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
270 self.assertEqual(self.call(tf.do_link, 'link'),
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
271 '<a href="other1">the key1</a>')
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
272
676
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
273 def testLink_link_id(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
274 self.assertEqual(self.call(tf.do_link, 'link', showid=1),
676
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
275 '<a href="other1" title="the key1">1</a>')
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
276
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
277 def testLink_multilink(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
278 self.assertEqual(self.call(tf.do_link, 'multilink'),
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
279 '<a href="other1">the key1</a>, <a href="other2">the key2</a>')
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
280
676
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
281 def testLink_multilink_id(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
282 self.assertEqual(self.call(tf.do_link, 'multilink', showid=1),
676
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
283 '<a href="other1" title="the key1">1</a>, <a href="other2" title="the key2">2</a>')
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
284
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
285 def testLink_boolean(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
286 self.assertEqual(self.call(tf.do_link, 'boolean'),
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
287 '<a href="test_class1">No</a>')
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
288
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
289 def testLink_number(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
290 self.assertEqual(self.call(tf.do_link, 'number'),
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
291 '<a href="test_class1">1234</a>')
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
292
574
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
293 # def do_count(self, property, **args):
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
294 def testCount_nonlinks(self):
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
295 s = _('[Count: not a Multilink]')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
296 self.assertEqual(self.call(tf.do_count, 'string'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
297 self.assertEqual(self.call(tf.do_count, 'date'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
298 self.assertEqual(self.call(tf.do_count, 'interval'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
299 self.assertEqual(self.call(tf.do_count, 'password'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
300 self.assertEqual(self.call(tf.do_count, 'link'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
301 self.assertEqual(self.call(tf.do_count, 'boolean'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
302 self.assertEqual(self.call(tf.do_count, 'number'), s)
574
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
303
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
304 def testCount_multilink(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
305 self.assertEqual(self.call(tf.do_count, 'multilink'), '2')
574
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
306
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
307 # def do_reldate(self, property, pretty=0):
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
308 def testReldate_nondate(self):
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
309 s = _('[Reldate: not a Date]')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
310 self.assertEqual(self.call(tf.do_reldate, 'string'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
311 self.assertEqual(self.call(tf.do_reldate, 'interval'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
312 self.assertEqual(self.call(tf.do_reldate, 'password'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
313 self.assertEqual(self.call(tf.do_reldate, 'link'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
314 self.assertEqual(self.call(tf.do_reldate, 'multilink'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
315 self.assertEqual(self.call(tf.do_reldate, 'boolean'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
316 self.assertEqual(self.call(tf.do_reldate, 'number'), s)
574
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
317
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
318 def testReldate_date(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
319 self.assertEqual(self.call(tf.do_reldate, 'reldate'), '- 2y 1m')
722
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
320 interval = date.Interval('- 2y 1m')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
321 self.assertEqual(self.call(tf.do_reldate, 'reldate', pretty=1),
722
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
322 interval.pretty())
574
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
323
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
324 # def do_download(self, property):
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
325 def testDownload_novalue(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
326 self.assertEqual(self.call(tf.do_download, 'novalue'),
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
327 _('[no %(propname)s]')%{'propname':'novalue'.capitalize()})
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
328
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
329 def testDownload_string(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
330 self.assertEqual(self.call(tf.do_download, 'string'),
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
331 '<a href="test_class1/Node 1: I am a string">Node 1: '
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
332 'I am a string</a>')
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
333
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
334 def testDownload_file(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
335 self.assertEqual(self.call(tf.do_download, 'filename', is_download=1),
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
336 '<a href="test_class1/file.foo">file.foo</a>')
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
337
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
338 def testDownload_date(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
339 self.assertEqual(self.call(tf.do_download, 'date'),
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
340 '<a href="test_class1/2000-01-01.00:00:00">2000-01-01.00:00:00</a>')
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
341
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
342 def testDownload_interval(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
343 self.assertEqual(self.call(tf.do_download, 'interval'),
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
344 '<a href="test_class1/- 3d">- 3d</a>')
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
345
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
346 def testDownload_link(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
347 self.assertEqual(self.call(tf.do_download, 'link'),
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
348 '<a href="other1/the key1">the key1</a>')
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
349
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
350 def testDownload_multilink(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
351 self.assertEqual(self.call(tf.do_download, 'multilink'),
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
352 '<a href="other1/the key1">the key1</a>, '
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
353 '<a href="other2/the key2">the key2</a>')
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
354
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
355 def testDownload_boolean(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
356 self.assertEqual(self.call(tf.do_download, 'boolean'),
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
357 '<a href="test_class1/No">No</a>')
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
358
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
359 def testDownload_number(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
360 self.assertEqual(self.call(tf.do_download, 'number'),
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
361 '<a href="test_class1/1234">1234</a>')
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
362
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
363 # def do_checklist(self, property, reverse=0):
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
364 def testChecklist_nonlinks(self):
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
365 s = _('[Checklist: not a link]')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
366 self.assertEqual(self.call(tf.do_checklist, 'string'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
367 self.assertEqual(self.call(tf.do_checklist, 'date'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
368 self.assertEqual(self.call(tf.do_checklist, 'interval'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
369 self.assertEqual(self.call(tf.do_checklist, 'password'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
370 self.assertEqual(self.call(tf.do_checklist, 'boolean'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
371 self.assertEqual(self.call(tf.do_checklist, 'number'), s)
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
372
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
373 def testChecklstk_link(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
374 self.assertEqual(self.call(tf.do_checklist, 'link'),
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
375 '''the key1:<input type="checkbox" checked name="link" value="the key1">
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
376 the key2:<input type="checkbox" name="link" value="the key2">
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
377 [unselected]:<input type="checkbox" name="link" value="-1">''')
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
378
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
379 def testChecklink_multilink(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
380 self.assertEqual(self.call(tf.do_checklist, 'multilink'),
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
381 '''the key1:<input type="checkbox" checked name="multilink" value="the key1">
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
382 the key2:<input type="checkbox" checked name="multilink" value="the key2">''')
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
383
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
384 # def do_note(self, rows=5, cols=80):
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
385 def testNote(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
386 self.assertEqual(self.call(tf.do_note), '<textarea name="__note" '
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
387 'wrap="hard" rows=5 cols=80></textarea>')
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
388
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
389 # def do_list(self, property, reverse=0):
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
390 def testList_nonlinks(self):
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
391 s = _('[List: not a Multilink]')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
392 self.assertEqual(self.call(tf.do_list, 'string'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
393 self.assertEqual(self.call(tf.do_list, 'date'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
394 self.assertEqual(self.call(tf.do_list, 'interval'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
395 self.assertEqual(self.call(tf.do_list, 'password'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
396 self.assertEqual(self.call(tf.do_list, 'link'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
397 self.assertEqual(self.call(tf.do_list, 'boolean'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
398 self.assertEqual(self.call(tf.do_list, 'number'), s)
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
399
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
400 def testList_multilink(self):
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
401 # TODO: test this (needs to have lots and lots of support!
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
402 #self.assertEqual(self.tf.do_list('multilink'),'')
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
403 pass
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
404
635
3d61b5d2243e Added popup help for classes using the classhelp html template function.
Richard Jones <richard@users.sourceforge.net>
parents: 617
diff changeset
405 def testClasshelp(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
406 self.assertEqual(self.call(tf.do_classhelp, 'theclass', 'prop1,prop2'),
635
3d61b5d2243e Added popup help for classes using the classhelp html template function.
Richard Jones <richard@users.sourceforge.net>
parents: 617
diff changeset
407 '<a href="javascript:help_window(\'classhelp?classname=theclass'
640
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
408 '&properties=prop1,prop2\', \'400\', \'400\')"><b>(?)</b></a>')
635
3d61b5d2243e Added popup help for classes using the classhelp html template function.
Richard Jones <richard@users.sourceforge.net>
parents: 617
diff changeset
409
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
410 # def do_email(self, property, rows=5, cols=40)
829
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
411 def testEmail_string(self):
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
412 self.assertEqual(self.call(tf.do_email, 'email'), 'test at foo domain example')
829
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
413
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
414 def testEmail_nonstring(self):
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
415 s = _('[Email: not a string]')
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
416 self.assertEqual(self.call(tf.do_email, 'date'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
417 self.assertEqual(self.call(tf.do_email, 'interval'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
418 self.assertEqual(self.call(tf.do_email, 'password'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
419 self.assertEqual(self.call(tf.do_email, 'link'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
420 self.assertEqual(self.call(tf.do_email, 'multilink'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
421 self.assertEqual(self.call(tf.do_email, 'boolean'), s)
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
422 self.assertEqual(self.call(tf.do_email, 'number'), s)
829
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
423
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
424
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
425 from test_db import setupSchema, MyTestCase, config
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
426
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
427 class Client:
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
428 user = 'admin'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
429
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
430 class IndexTemplateCase(unittest.TestCase):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
431 def setUp(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
432 from roundup.backends import anydbm
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
433 # remove previous test, ignore errors
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
434 if os.path.exists(config.DATABASE):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
435 shutil.rmtree(config.DATABASE)
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
436 os.makedirs(config.DATABASE + '/files')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
437 self.db = anydbm.Database(config, 'test')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
438 setupSchema(self.db, 1, anydbm)
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
439
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
440 client = Client()
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
441 client.db = self.db
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
442 client.instance = None
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
443 self.tf = tf = IndexTemplate(client, '', 'issue')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
444 tf.props = ['title']
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
445
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
446 # admin user
905
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
447 self.db.user.create(username="admin", roles='Admin')
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
448 self.db.user.create(username="anonymous", roles='User')
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
449
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
450 def testBasic(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
451 self.assertEqual(self.tf.execute_template('hello'), 'hello')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
452
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
453 def testValue(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
454 self.tf.nodeid = self.db.issue.create(title="spam", status='1')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
455 self.assertEqual(self.tf.execute_template('<display call="plain(\'title\')">'), 'spam')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
456
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
457 def testColumnSelection(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
458 self.tf.nodeid = self.db.issue.create(title="spam", status='1')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
459 self.assertEqual(self.tf.execute_template('<property name="title">'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
460 '<display call="plain(\'title\')"></property>'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
461 '<property name="bar">hello</property>'), 'spam')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
462 self.tf.props = ['bar']
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
463 self.assertEqual(self.tf.execute_template('<property name="title">'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
464 '<display call="plain(\'title\')"></property>'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
465 '<property name="bar">hello</property>'), 'hello')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
466
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
467 def testSecurityPass(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
468 self.assertEqual(self.tf.execute_template(
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
469 '<require permission="Edit">hello<else>foo</require>'), 'hello')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
470
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
471 def testSecurityPassValue(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
472 self.tf.nodeid = self.db.issue.create(title="spam", status='1')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
473 self.assertEqual(self.tf.execute_template(
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
474 '<require permission="Edit">'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
475 '<display call="plain(\'title\')">'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
476 '<else>not allowed</require>'), 'spam')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
477
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
478 def testSecurityFail(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
479 self.tf.client.user = 'anonymous'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
480 self.assertEqual(self.tf.execute_template(
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
481 '<require permission="Edit">hello<else>foo</require>'), 'foo')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
482
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
483 def testSecurityFailValue(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
484 self.tf.nodeid = self.db.issue.create(title="spam", status='1')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
485 self.tf.client.user = 'anonymous'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
486 self.assertEqual(self.tf.execute_template(
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
487 '<require permission="Edit">allowed<else>'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
488 '<display call="plain(\'title\')"></require>'), 'spam')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
489
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
490 def tearDown(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
491 if os.path.exists('_test_dir'):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
492 shutil.rmtree('_test_dir')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
493
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
494
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
495 class ItemTemplateCase(unittest.TestCase):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
496 def setUp(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
497 ''' Set up the harness for calling the individual tests
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
498 '''
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
499 from roundup.backends import anydbm
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
500 # remove previous test, ignore errors
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
501 if os.path.exists(config.DATABASE):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
502 shutil.rmtree(config.DATABASE)
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
503 os.makedirs(config.DATABASE + '/files')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
504 self.db = anydbm.Database(config, 'test')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
505 setupSchema(self.db, 1, anydbm)
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
506
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
507 client = Client()
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
508 client.db = self.db
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
509 client.instance = None
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
510 self.tf = tf = IndexTemplate(client, '', 'issue')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
511 tf.nodeid = self.db.issue.create(title="spam", status='1')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
512
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
513 # admin user
905
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
514 self.db.user.create(username="admin", roles='Admin')
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
515 self.db.user.create(username="anonymous", roles='User')
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
516
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
517 def testBasic(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
518 self.assertEqual(self.tf.execute_template('hello'), 'hello')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
519
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
520 def testValue(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
521 self.assertEqual(self.tf.execute_template('<display call="plain(\'title\')">'), 'spam')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
522
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
523 def testSecurityPass(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
524 self.assertEqual(self.tf.execute_template(
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
525 '<require permission="Edit">hello<else>foo</require>'), 'hello')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
526
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
527 def testSecurityPassValue(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
528 self.assertEqual(self.tf.execute_template(
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
529 '<require permission="Edit">'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
530 '<display call="plain(\'title\')">'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
531 '<else>not allowed</require>'), 'spam')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
532
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
533 def testSecurityFail(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
534 self.tf.client.user = 'anonymous'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
535 self.assertEqual(self.tf.execute_template(
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
536 '<require permission="Edit">hello<else>foo</require>'), 'foo')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
537
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
538 def testSecurityFailValue(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
539 self.tf.client.user = 'anonymous'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
540 self.assertEqual(self.tf.execute_template(
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
541 '<require permission="Edit">allowed<else>'
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
542 '<display call="plain(\'title\')"></require>'), 'spam')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
543
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
544 def tearDown(self):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
545 if os.path.exists('_test_dir'):
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
546 shutil.rmtree('_test_dir')
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
547
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
548 def suite():
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
549 return unittest.TestSuite([
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
550 unittest.makeSuite(FunctionCase, 'test'),
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
551 #unittest.makeSuite(IndexTemplateCase, 'test'),
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
552 #unittest.makeSuite(ItemTemplateCase, 'test'),
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
553 ])
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
554
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
555
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
556 #
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
557 # $Log: not supported by cvs2svn $
934
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
558 # Revision 1.19 2002/07/26 08:27:00 richard
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
559 # Very close now. The cgi and mailgw now use the new security API. The two
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
560 # templates have been migrated to that setup. Lots of unit tests. Still some
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
561 # issue in the web form for editing Roles assigned to users.
fdcf16b444a9 Use a real parser for templates.
Gordon B. McMillan <gmcm@users.sourceforge.net>
parents: 905
diff changeset
562 #
905
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
563 # Revision 1.18 2002/07/25 07:14:06 richard
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
564 # Bugger it. Here's the current shape of the new security implementation.
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
565 # Still to do:
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
566 # . call the security funcs from cgi and mailgw
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
567 # . change shipped templates to include correct initialisation and remove
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
568 # the old config vars
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
569 # ... that seems like a lot. The bulk of the work has been done though. Honest :)
502a5ae11cc5 Very close now. The cgi and mailgw now use the new security API.
Richard Jones <richard@users.sourceforge.net>
parents: 902
diff changeset
570 #
902
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
571 # Revision 1.17 2002/07/18 23:07:07 richard
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
572 # Unit tests and a few fixes.
b0d3d3535998 Bugger it. Here's the current shape of the new security implementation.
Richard Jones <richard@users.sourceforge.net>
parents: 890
diff changeset
573 #
890
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
574 # Revision 1.16 2002/07/09 05:20:09 richard
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
575 # . added email display function - mangles email addrs so they're not so easily
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
576 # scraped from the web
a568596dbea7 Unit tests and a few fixes.
Richard Jones <richard@users.sourceforge.net>
parents: 829
diff changeset
577 #
829
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
578 # Revision 1.15 2002/07/08 06:39:00 richard
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
579 # Fixed unit test support class so the tests ran again.
37ce3f2e05b2 added email display function
Richard Jones <richard@users.sourceforge.net>
parents: 814
diff changeset
580 #
814
9a17342a9e04 Fixed unit test support class so the tests ran again.
Richard Jones <richard@users.sourceforge.net>
parents: 722
diff changeset
581 # Revision 1.14 2002/05/15 06:37:31 richard
9a17342a9e04 Fixed unit test support class so the tests ran again.
Richard Jones <richard@users.sourceforge.net>
parents: 722
diff changeset
582 # ehem and the unit test
9a17342a9e04 Fixed unit test support class so the tests ran again.
Richard Jones <richard@users.sourceforge.net>
parents: 722
diff changeset
583 #
722
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
584 # Revision 1.13 2002/04/03 05:54:31 richard
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
585 # Fixed serialisation problem by moving the serialisation step out of the
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
586 # hyperdb.Class (get, set) into the hyperdb.Database.
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
587 #
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
588 # Also fixed htmltemplate after the showid changes I made yesterday.
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
589 #
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
590 # Unit tests for all of the above written.
431c3f9c8ac9 ehem and the unit test
Richard Jones <richard@users.sourceforge.net>
parents: 676
diff changeset
591 #
676
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
592 # Revision 1.12 2002/03/29 19:41:48 rochecompaan
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
593 # . Fixed display of mutlilink properties when using the template
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
594 # functions, menu and plain.
bc46480e2a2b Fixed serialisation problem...
Richard Jones <richard@users.sourceforge.net>
parents: 672
diff changeset
595 #
672
d92e06a3a56e Fixed display of mutlilink properties...
Roche Compaan <rochecompaan@users.sourceforge.net>
parents: 640
diff changeset
596 # Revision 1.11 2002/02/21 23:11:45 richard
d92e06a3a56e Fixed display of mutlilink properties...
Roche Compaan <rochecompaan@users.sourceforge.net>
parents: 640
diff changeset
597 # . fixed some problems in date calculations (calendar.py doesn't handle over-
d92e06a3a56e Fixed display of mutlilink properties...
Roche Compaan <rochecompaan@users.sourceforge.net>
parents: 640
diff changeset
598 # and under-flow). Also, hour/minute/second intervals may now be more than
d92e06a3a56e Fixed display of mutlilink properties...
Roche Compaan <rochecompaan@users.sourceforge.net>
parents: 640
diff changeset
599 # 99 each.
d92e06a3a56e Fixed display of mutlilink properties...
Roche Compaan <rochecompaan@users.sourceforge.net>
parents: 640
diff changeset
600 #
640
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
601 # Revision 1.10 2002/02/21 06:57:39 richard
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
602 # . Added popup help for classes using the classhelp html template function.
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
603 # - add <display call="classhelp('priority', 'id,name,description')">
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
604 # to an item page, and it generates a link to a popup window which displays
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
605 # the id, name and description for the priority class. The description
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
606 # field won't exist in most installations, but it will be added to the
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
607 # default templates.
7dd13fd5d8ea fixed some problems in date calculations
Richard Jones <richard@users.sourceforge.net>
parents: 635
diff changeset
608 #
635
3d61b5d2243e Added popup help for classes using the classhelp html template function.
Richard Jones <richard@users.sourceforge.net>
parents: 617
diff changeset
609 # Revision 1.9 2002/02/15 07:08:45 richard
3d61b5d2243e Added popup help for classes using the classhelp html template function.
Richard Jones <richard@users.sourceforge.net>
parents: 617
diff changeset
610 # . Alternate email addresses are now available for users. See the MIGRATION
3d61b5d2243e Added popup help for classes using the classhelp html template function.
Richard Jones <richard@users.sourceforge.net>
parents: 617
diff changeset
611 # file for info on how to activate the feature.
3d61b5d2243e Added popup help for classes using the classhelp html template function.
Richard Jones <richard@users.sourceforge.net>
parents: 617
diff changeset
612 #
617
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
613 # Revision 1.8 2002/02/06 03:47:16 richard
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
614 # . #511586 ] unittest FAIL: testReldate_date
edd210915e64 Alternate email addresses are now available for users.
Richard Jones <richard@users.sourceforge.net>
parents: 600
diff changeset
615 #
600
a4c32558d345 [SF#511586] unittest FAIL: testReldate_date
Richard Jones <richard@users.sourceforge.net>
parents: 586
diff changeset
616 # Revision 1.7 2002/01/23 20:09:41 jhermann
a4c32558d345 [SF#511586] unittest FAIL: testReldate_date
Richard Jones <richard@users.sourceforge.net>
parents: 586
diff changeset
617 # Proper fix for failing test
a4c32558d345 [SF#511586] unittest FAIL: testReldate_date
Richard Jones <richard@users.sourceforge.net>
parents: 586
diff changeset
618 #
586
50fcb1357967 Proper fix for failing test
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 577
diff changeset
619 # Revision 1.6 2002/01/23 05:47:57 richard
50fcb1357967 Proper fix for failing test
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 577
diff changeset
620 # more HTML template cleanup and unit tests
50fcb1357967 Proper fix for failing test
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 577
diff changeset
621 #
577
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
622 # Revision 1.5 2002/01/23 05:10:28 richard
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
623 # More HTML template cleanup and unit tests.
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
624 # - download() now implemented correctly, replacing link(is_download=1) [fixed in the
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
625 # templates, but link(is_download=1) will still work for existing templates]
334ae707ebfc more HTML template cleanup and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 576
diff changeset
626 #
576
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
627 # Revision 1.4 2002/01/22 22:46:22 richard
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
628 # more htmltemplate cleanups and unit tests
f98f37697f4c More HTML template cleanup and unit tests.
Richard Jones <richard@users.sourceforge.net>
parents: 574
diff changeset
629 #
574
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
630 # Revision 1.3 2002/01/22 06:35:40 richard
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
631 # more htmltemplate tests and cleanup
d41d94511170 more htmltemplate cleanups and unit tests
Richard Jones <richard@users.sourceforge.net>
parents: 568
diff changeset
632 #
568
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
633 # Revision 1.2 2002/01/22 00:12:07 richard
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
634 # Wrote more unit tests for htmltemplate, and while I was at it, I polished
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
635 # off the implementation of some of the functions so they behave sanely.
c7ead967db85 more htmltemplate tests and cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 563
diff changeset
636 #
563
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
637 # Revision 1.1 2002/01/21 11:05:48 richard
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
638 # New tests for htmltemplate (well, it's a beginning)
0f58d6a35a8b Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents: 561
diff changeset
639 #
561
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
640 #
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
641 #
13df980755fa New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
642 # vim: set filetype=python ts=4 sw=4 et si

Roundup Issue Tracker: http://roundup-tracker.org/