comparison test/test_htmltemplate.py @ 829:37ce3f2e05b2

added email display function mangles email addrs so they're not so easily scraped from the web
author Richard Jones <richard@users.sourceforge.net>
date Tue, 09 Jul 2002 05:20:09 +0000
parents 9a17342a9e04
children a568596dbea7
comparison
equal deleted inserted replaced
828:c01725aebebb 829:37ce3f2e05b2
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.15 2002-07-08 06:39:00 richard Exp $ 11 # $Id: test_htmltemplate.py,v 1.16 2002-07-09 05:20:09 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
39 return 'the key'+nodeid 39 return 'the key'+nodeid
40 elif attribute == 'html': 40 elif attribute == 'html':
41 return '<html>hello, I am HTML</html>' 41 return '<html>hello, I am HTML</html>'
42 elif attribute == 'multiline': 42 elif attribute == 'multiline':
43 return 'hello\nworld' 43 return 'hello\nworld'
44 elif attribute == 'email':
45 return 'test@foo.domain.example'
44 def list(self): 46 def list(self):
45 return ['1', '2'] 47 return ['1', '2']
46 def filter(self, search_matches, filterspec, sort, group): 48 def filter(self, search_matches, filterspec, sort, group):
47 return ['1', '2'] 49 return ['1', '2']
48 def getprops(self): 50 def getprops(self):
49 return {'string': String(), 'date': Date(), 'interval': Interval(), 51 return {'string': String(), 'date': Date(), 'interval': Interval(),
50 'link': Link('other'), 'multilink': Multilink('other'), 52 'link': Link('other'), 'multilink': Multilink('other'),
51 'password': Password(), 'html': String(), 'key': String(), 53 'password': Password(), 'html': String(), 'key': String(),
52 'novalue': String(), 'filename': String(), 'multiline': String(), 54 'novalue': String(), 'filename': String(), 'multiline': String(),
53 'reldate': Date()} 55 'reldate': Date(), 'email': String()}
54 def labelprop(self, default_to_id=0): 56 def labelprop(self, default_to_id=0):
55 return 'key' 57 return 'key'
56 58
57 class Database: 59 class Database:
58 classes = {'other': Class()} 60 classes = {'other': Class()}
347 def testClasshelp(self): 349 def testClasshelp(self):
348 self.assertEqual(self.tf.do_classhelp('theclass', 'prop1,prop2'), 350 self.assertEqual(self.tf.do_classhelp('theclass', 'prop1,prop2'),
349 '<a href="javascript:help_window(\'classhelp?classname=theclass' 351 '<a href="javascript:help_window(\'classhelp?classname=theclass'
350 '&properties=prop1,prop2\', \'400\', \'400\')"><b>(?)</b></a>') 352 '&properties=prop1,prop2\', \'400\', \'400\')"><b>(?)</b></a>')
351 353
354 # def do_multiline(self, property, rows=5, cols=40)
355 def testEmail_string(self):
356 self.assertEqual(self.tf.do_email('email'), 'test at foo domain example')
357
358 def testEmail_nonstring(self):
359 s = _('[Email: not a string]')
360 self.assertEqual(self.tf.do_email('date'), s)
361 self.assertEqual(self.tf.do_email('interval'), s)
362 self.assertEqual(self.tf.do_email('password'), s)
363 self.assertEqual(self.tf.do_email('link'), s)
364 self.assertEqual(self.tf.do_email('multilink'), s)
365
352 def suite(): 366 def suite():
353 return unittest.makeSuite(NodeCase, 'test') 367 return unittest.makeSuite(NodeCase, 'test')
354 368
355 369
356 # 370 #
357 # $Log: not supported by cvs2svn $ 371 # $Log: not supported by cvs2svn $
372 # Revision 1.15 2002/07/08 06:39:00 richard
373 # Fixed unit test support class so the tests ran again.
374 #
358 # Revision 1.14 2002/05/15 06:37:31 richard 375 # Revision 1.14 2002/05/15 06:37:31 richard
359 # ehem and the unit test 376 # ehem and the unit test
360 # 377 #
361 # Revision 1.13 2002/04/03 05:54:31 richard 378 # Revision 1.13 2002/04/03 05:54:31 richard
362 # Fixed serialisation problem by moving the serialisation step out of the 379 # Fixed serialisation problem by moving the serialisation step out of the

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