comparison test/test_htmltemplate.py @ 640:7dd13fd5d8ea

fixed some problems in date calculations (calendar.py doesn't handle over- and under-flow). Also, hour/minute/second intervals may now be more than 99 each.
author Richard Jones <richard@users.sourceforge.net>
date Thu, 21 Feb 2002 23:11:45 +0000
parents 3d61b5d2243e
children d92e06a3a56e
comparison
equal deleted inserted replaced
639:2f3e82a69eb5 640:7dd13fd5d8ea
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.10 2002-02-21 06:57:39 richard Exp $ 11 # $Id: test_htmltemplate.py,v 1.11 2002-02-21 23:11: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
22 if attribute == 'string': 22 if attribute == 'string':
23 return 'Node %s: I am a string'%nodeid 23 return 'Node %s: I am a string'%nodeid
24 elif attribute == 'filename': 24 elif attribute == 'filename':
25 return 'file.foo' 25 return 'file.foo'
26 elif attribute == 'date': 26 elif attribute == 'date':
27 return date.Date() + date.Interval('- 2y 2m') 27 return date.Date('2000-01-01')
28 elif attribute == 'reldate':
29 return date.Date() + date.Interval('- 2y 1m')
28 elif attribute == 'interval': 30 elif attribute == 'interval':
29 return date.Interval('-3d') 31 return date.Interval('-3d')
30 elif attribute == 'link': 32 elif attribute == 'link':
31 return '1' 33 return '1'
32 elif attribute == 'multilink': 34 elif attribute == 'multilink':
43 return ['1', '2'] 45 return ['1', '2']
44 def getprops(self): 46 def getprops(self):
45 return {'string': String(), 'date': Date(), 'interval': Interval(), 47 return {'string': String(), 'date': Date(), 'interval': Interval(),
46 'link': Link('other'), 'multilink': Multilink('other'), 48 'link': Link('other'), 'multilink': Multilink('other'),
47 'password': Password(), 'html': String(), 'key': String(), 49 'password': Password(), 'html': String(), 'key': String(),
48 'novalue': String(), 'filename': String(), 'multiline': String()} 50 'novalue': String(), 'filename': String(), 'multiline': String(),
51 'reldate': Date()}
49 def labelprop(self): 52 def labelprop(self):
50 return 'key' 53 return 'key'
51 54
52 class Database: 55 class Database:
53 classes = {'other': Class()} 56 classes = {'other': Class()}
255 self.assertEqual(self.tf.do_reldate('password'), s) 258 self.assertEqual(self.tf.do_reldate('password'), s)
256 self.assertEqual(self.tf.do_reldate('link'), s) 259 self.assertEqual(self.tf.do_reldate('link'), s)
257 self.assertEqual(self.tf.do_reldate('multilink'), s) 260 self.assertEqual(self.tf.do_reldate('multilink'), s)
258 261
259 def testReldate_date(self): 262 def testReldate_date(self):
260 self.assertEqual(self.tf.do_reldate('date'), '- 2y 1m') 263 self.assertEqual(self.tf.do_reldate('reldate'), '- 2y 1m')
261 date = self.tf.cl.get('1', 'date') 264 date = self.tf.cl.get('1', 'reldate')
262 self.assertEqual(self.tf.do_reldate('date', pretty=1), date.pretty()) 265 self.assertEqual(self.tf.do_reldate('reldate', pretty=1), date.pretty())
263 266
264 # def do_download(self, property): 267 # def do_download(self, property):
265 def testDownload_novalue(self): 268 def testDownload_novalue(self):
266 self.assertEqual(self.tf.do_download('novalue'), 269 self.assertEqual(self.tf.do_download('novalue'),
267 _('[no %(propname)s]')%{'propname':'novalue'.capitalize()}) 270 _('[no %(propname)s]')%{'propname':'novalue'.capitalize()})
331 pass 334 pass
332 335
333 def testClasshelp(self): 336 def testClasshelp(self):
334 self.assertEqual(self.tf.do_classhelp('theclass', 'prop1,prop2'), 337 self.assertEqual(self.tf.do_classhelp('theclass', 'prop1,prop2'),
335 '<a href="javascript:help_window(\'classhelp?classname=theclass' 338 '<a href="javascript:help_window(\'classhelp?classname=theclass'
336 '&properties=prop1,prop2\')"><b>(?)</b></a>') 339 '&properties=prop1,prop2\', \'400\', \'400\')"><b>(?)</b></a>')
337 340
338 def suite(): 341 def suite():
339 return unittest.makeSuite(NodeCase, 'test') 342 return unittest.makeSuite(NodeCase, 'test')
340 343
341 344
342 # 345 #
343 # $Log: not supported by cvs2svn $ 346 # $Log: not supported by cvs2svn $
347 # Revision 1.10 2002/02/21 06:57:39 richard
348 # . Added popup help for classes using the classhelp html template function.
349 # - add <display call="classhelp('priority', 'id,name,description')">
350 # to an item page, and it generates a link to a popup window which displays
351 # the id, name and description for the priority class. The description
352 # field won't exist in most installations, but it will be added to the
353 # default templates.
354 #
344 # Revision 1.9 2002/02/15 07:08:45 richard 355 # Revision 1.9 2002/02/15 07:08:45 richard
345 # . Alternate email addresses are now available for users. See the MIGRATION 356 # . Alternate email addresses are now available for users. See the MIGRATION
346 # file for info on how to activate the feature. 357 # file for info on how to activate the feature.
347 # 358 #
348 # Revision 1.8 2002/02/06 03:47:16 richard 359 # Revision 1.8 2002/02/06 03:47:16 richard

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