comparison test/test_htmltemplate.py @ 617:edd210915e64

Alternate email addresses are now available for users. See the MIGRATION file for info on how to activate the feature.
author Richard Jones <richard@users.sourceforge.net>
date Fri, 15 Feb 2002 07:08:45 +0000
parents a4c32558d345
children 3d61b5d2243e
comparison
equal deleted inserted replaced
616:08abec25b2c6 617:edd210915e64
6 # 6 #
7 # This module is distributed in the hope that it will be useful, 7 # This module is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # 10 #
11 # $Id: test_htmltemplate.py,v 1.8 2002-02-06 03:47:16 richard Exp $ 11 # $Id: test_htmltemplate.py,v 1.9 2002-02-15 07:08:45 richard Exp $
12 12
13 import unittest, cgi, time 13 import unittest, cgi, time
14 14
15 from roundup import date, password 15 from roundup import date, password
16 from roundup.htmltemplate import TemplateFunctions 16 from roundup.htmltemplate import TemplateFunctions
35 return password.Password('sekrit') 35 return password.Password('sekrit')
36 elif attribute == 'key': 36 elif attribute == 'key':
37 return 'the key'+nodeid 37 return 'the key'+nodeid
38 elif attribute == 'html': 38 elif attribute == 'html':
39 return '<html>hello, I am HTML</html>' 39 return '<html>hello, I am HTML</html>'
40 elif attribute == 'multiline':
41 return 'hello\nworld'
40 def list(self): 42 def list(self):
41 return ['1', '2'] 43 return ['1', '2']
42 def getprops(self): 44 def getprops(self):
43 return {'string': String(), 'date': Date(), 'interval': Interval(), 45 return {'string': String(), 'date': Date(), 'interval': Interval(),
44 'link': Link('other'), 'multilink': Multilink('other'), 46 'link': Link('other'), 'multilink': Multilink('other'),
45 'password': Password(), 'html': String(), 'key': String(), 47 'password': Password(), 'html': String(), 'key': String(),
46 'novalue': String(), 'filename': String()} 48 'novalue': String(), 'filename': String(), 'multiline': String()}
47 def labelprop(self): 49 def labelprop(self):
48 return 'key' 50 return 'key'
49 51
50 class Database: 52 class Database:
51 classes = {'other': Class()} 53 classes = {'other': Class()}
138 self.assertEqual(self.tf.do_field('multilink'), 140 self.assertEqual(self.tf.do_field('multilink'),
139 '<input name="multilink" size="30" value="the key1,the key2">') 141 '<input name="multilink" size="30" value="the key1,the key2">')
140 self.assertEqual(self.tf.do_field('multilink', size=10), 142 self.assertEqual(self.tf.do_field('multilink', size=10),
141 '<input name="multilink" size="10" value="the key1,the key2">') 143 '<input name="multilink" size="10" value="the key1,the key2">')
142 144
145 # def do_multiline(self, property, rows=5, cols=40)
146 def testMultiline_string(self):
147 self.assertEqual(self.tf.do_multiline('multiline'),
148 '<textarea name="multiline" rows="5" cols="40">'
149 'hello\nworld</textarea>')
150 self.assertEqual(self.tf.do_multiline('multiline', rows=10),
151 '<textarea name="multiline" rows="10" cols="40">'
152 'hello\nworld</textarea>')
153 self.assertEqual(self.tf.do_multiline('multiline', cols=10),
154 '<textarea name="multiline" rows="5" cols="10">'
155 'hello\nworld</textarea>')
156
157 def testMultiline_nonstring(self):
158 s = _('[Multiline: not a string]')
159 self.assertEqual(self.tf.do_multiline('date'), s)
160 self.assertEqual(self.tf.do_multiline('interval'), s)
161 self.assertEqual(self.tf.do_multiline('password'), s)
162 self.assertEqual(self.tf.do_multiline('link'), s)
163 self.assertEqual(self.tf.do_multiline('multilink'), s)
164
143 # def do_menu(self, property, size=None, height=None, showid=0): 165 # def do_menu(self, property, size=None, height=None, showid=0):
144 def testMenu_nonlinks(self): 166 def testMenu_nonlinks(self):
145 s = _('[Menu: not a link]') 167 s = _('[Menu: not a link]')
146 self.assertEqual(self.tf.do_menu('string'), s) 168 self.assertEqual(self.tf.do_menu('string'), s)
147 self.assertEqual(self.tf.do_menu('date'), s) 169 self.assertEqual(self.tf.do_menu('date'), s)
148 self.assertEqual(self.tf.do_menu('interval'), s) 170 self.assertEqual(self.tf.do_menu('interval'), s)
149 self.assertEqual(self.tf.do_menu('password'), s) 171 self.assertEqual(self.tf.do_menu('password'), s)
150 172
234 self.assertEqual(self.tf.do_reldate('link'), s) 256 self.assertEqual(self.tf.do_reldate('link'), s)
235 self.assertEqual(self.tf.do_reldate('multilink'), s) 257 self.assertEqual(self.tf.do_reldate('multilink'), s)
236 258
237 def testReldate_date(self): 259 def testReldate_date(self):
238 self.assertEqual(self.tf.do_reldate('date'), '- 2y 1m') 260 self.assertEqual(self.tf.do_reldate('date'), '- 2y 1m')
239 date = self.tf.cl.get('1', 'date') 261 date = self.tf.cl.get('1', 'date')
240 self.assertEqual(self.tf.do_reldate('date', pretty=1), date.pretty()) 262 self.assertEqual(self.tf.do_reldate('date', pretty=1), date.pretty())
241 263
242 # def do_download(self, property): 264 # def do_download(self, property):
243 def testDownload_novalue(self): 265 def testDownload_novalue(self):
244 self.assertEqual(self.tf.do_download('novalue'), 266 self.assertEqual(self.tf.do_download('novalue'),
245 _('[no %(propname)s]')%{'propname':'novalue'.capitalize()}) 267 _('[no %(propname)s]')%{'propname':'novalue'.capitalize()})
246 268
247 def testDownload_string(self): 269 def testDownload_string(self):
248 self.assertEqual(self.tf.do_download('string'), 270 self.assertEqual(self.tf.do_download('string'),
249 '<a href="test_class1/Node 1: I am a string">Node 1: ' 271 '<a href="test_class1/Node 1: I am a string">Node 1: '
250 'I am a string</a>') 272 'I am a string</a>')
251 273
252 def testDownload_file(self): 274 def testDownload_file(self):
253 self.assertEqual(self.tf.do_download('filename', is_download=1), 275 self.assertEqual(self.tf.do_download('filename', is_download=1),
254 '<a href="test_class1/file.foo">file.foo</a>') 276 '<a href="test_class1/file.foo">file.foo</a>')
255 277
266 '<a href="other1/the key1">the key1</a>') 288 '<a href="other1/the key1">the key1</a>')
267 289
268 def testDownload_multilink(self): 290 def testDownload_multilink(self):
269 self.assertEqual(self.tf.do_download('multilink'), 291 self.assertEqual(self.tf.do_download('multilink'),
270 '<a href="other1/the key1">the key1</a>, ' 292 '<a href="other1/the key1">the key1</a>, '
271 '<a href="other2/the key2">the key2</a>') 293 '<a href="other2/the key2">the key2</a>')
272 294
273 # def do_checklist(self, property, reverse=0): 295 # def do_checklist(self, property, reverse=0):
274 def testChecklink_nonlinks(self): 296 def testChecklink_nonlinks(self):
275 s = _('[Checklist: not a link]') 297 s = _('[Checklist: not a link]')
276 self.assertEqual(self.tf.do_checklist('string'), s) 298 self.assertEqual(self.tf.do_checklist('string'), s)
312 return unittest.makeSuite(NodeCase, 'test') 334 return unittest.makeSuite(NodeCase, 'test')
313 335
314 336
315 # 337 #
316 # $Log: not supported by cvs2svn $ 338 # $Log: not supported by cvs2svn $
339 # Revision 1.8 2002/02/06 03:47:16 richard
340 # . #511586 ] unittest FAIL: testReldate_date
341 #
317 # Revision 1.7 2002/01/23 20:09:41 jhermann 342 # Revision 1.7 2002/01/23 20:09:41 jhermann
318 # Proper fix for failing test 343 # Proper fix for failing test
319 # 344 #
320 # Revision 1.6 2002/01/23 05:47:57 richard 345 # Revision 1.6 2002/01/23 05:47:57 richard
321 # more HTML template cleanup and unit tests 346 # more HTML template cleanup and unit tests

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