From: richard Date: Wed, 23 Jan 2002 05:47:57 +0000 (+0000) Subject: more HTML template cleanup and unit tests X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4f7f0e5eca81a2fa52e2a734da1befca904a9cea;p=roundup.git more HTML template cleanup and unit tests git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@589 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index 1590410..6390a2b 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.69 2002-01-23 05:10:27 richard Exp $ +# $Id: htmltemplate.py,v 1.70 2002-01-23 05:47:57 richard Exp $ __doc__ = """ Template engine. @@ -420,7 +420,7 @@ class TemplateFunctions: l = [] k = linkcl.labelprop() for optionid in linkcl.list(): - option = linkcl.get(optionid, k) + option = cgi.escape(linkcl.get(optionid, k)) if optionid in value or option in value: checked = 'checked' else: @@ -454,7 +454,11 @@ class TemplateFunctions: propcl = self.properties[property] if not isinstance(propcl, hyperdb.Multilink): return _('[List: not a Multilink]') - value = self.cl.get(self.nodeid, property) + + value = self.determine_value(property) + if not value: + return '' + value.sort() if reverse: value.reverse() @@ -1036,6 +1040,11 @@ class NewItemTemplate(TemplateFunctions): # # $Log: not supported by cvs2svn $ +# Revision 1.69 2002/01/23 05:10:27 richard +# More HTML template cleanup and unit tests. +# - download() now implemented correctly, replacing link(is_download=1) [fixed in the +# templates, but link(is_download=1) will still work for existing templates] +# # Revision 1.68 2002/01/22 22:55:28 richard # . htmltemplate list() wasn't sorting... # diff --git a/test/test_htmltemplate.py b/test/test_htmltemplate.py index d7b15f0..d72fda3 100644 --- a/test/test_htmltemplate.py +++ b/test/test_htmltemplate.py @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_htmltemplate.py,v 1.5 2002-01-23 05:10:28 richard Exp $ +# $Id: test_htmltemplate.py,v 1.6 2002-01-23 05:47:57 richard Exp $ import unittest, cgi @@ -34,7 +34,7 @@ class Class: elif attribute == 'password': return password.Password('sekrit') elif attribute == 'key': - return 'the key' + return 'the key'+nodeid elif attribute == 'html': return 'hello, I am HTML' def list(self): @@ -54,6 +54,9 @@ class Database: def __getattr(self, name): return Class() +class Client: + write = None + class NodeCase(unittest.TestCase): def setUp(self): ''' Set up the harness for calling the individual tests @@ -86,7 +89,7 @@ class NodeCase(unittest.TestCase): self.assertEqual(self.tf.do_plain('interval'), '- 3d') def testPlain_link(self): - self.assertEqual(self.tf.do_plain('link'), 'the key') + self.assertEqual(self.tf.do_plain('link'), 'the key1') def testPlain_multilink(self): self.assertEqual(self.tf.do_plain('multilink'), '1, 2') @@ -127,15 +130,15 @@ class NodeCase(unittest.TestCase): def testField_link(self): self.assertEqual(self.tf.do_field('link'), '''''') def testField_multilink(self): self.assertEqual(self.tf.do_field('multilink'), - '') + '') self.assertEqual(self.tf.do_field('multilink', size=10), - '') + '') # def do_menu(self, property, size=None, height=None, showid=0): def testMenu_nonlinks(self): @@ -148,8 +151,8 @@ class NodeCase(unittest.TestCase): def testMenu_link(self): self.assertEqual(self.tf.do_menu('link'), '''''') self.assertEqual(self.tf.do_menu('link', size=6), ''' - - + + ''') def testMenu_multilink(self): self.assertEqual(self.tf.do_menu('multilink', height=10), '''''') self.assertEqual(self.tf.do_menu('multilink', size=6, height=10), '''''') self.assertEqual(self.tf.do_menu('multilink', showid=1), '''''') # def do_link(self, property=None, is_download=0): @@ -204,11 +207,11 @@ class NodeCase(unittest.TestCase): def testLink_link(self): self.assertEqual(self.tf.do_link('link'), - 'the key') + 'the key1') def testLink_multilink(self): self.assertEqual(self.tf.do_link('multilink'), - 'the key, the key') + 'the key1, the key2') # def do_count(self, property, **args): def testCount_nonlinks(self): @@ -260,12 +263,50 @@ class NodeCase(unittest.TestCase): def testDownload_link(self): self.assertEqual(self.tf.do_download('link'), - 'the key') + 'the key1') def testDownload_multilink(self): self.assertEqual(self.tf.do_download('multilink'), - 'the key, ' - 'the key') + 'the key1, ' + 'the key2') + +# def do_checklist(self, property, reverse=0): + def testChecklink_nonlinks(self): + s = _('[Checklist: not a link]') + self.assertEqual(self.tf.do_checklist('string'), s) + self.assertEqual(self.tf.do_checklist('date'), s) + self.assertEqual(self.tf.do_checklist('interval'), s) + self.assertEqual(self.tf.do_checklist('password'), s) + + def testChecklink_link(self): + self.assertEqual(self.tf.do_checklist('link'), + '''the key1: +the key2: +[unselected]:''') + + def testChecklink_multilink(self): + self.assertEqual(self.tf.do_checklist('multilink'), + '''the key1: +the key2:''') + +# def do_note(self, rows=5, cols=80): + def testNote(self): + self.assertEqual(self.tf.do_note(), '') + +# def do_list(self, property, reverse=0): + def testList_nonlinks(self): + s = _('[List: not a Multilink]') + self.assertEqual(self.tf.do_list('string'), s) + self.assertEqual(self.tf.do_list('date'), s) + self.assertEqual(self.tf.do_list('interval'), s) + self.assertEqual(self.tf.do_list('password'), s) + self.assertEqual(self.tf.do_list('link'), s) + + def testList_multilink(self): + # TODO: test this (needs to have lots and lots of support! + #self.assertEqual(self.tf.do_list('multilink'),'') + pass def suite(): return unittest.makeSuite(NodeCase, 'test') @@ -273,6 +314,11 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.5 2002/01/23 05:10:28 richard +# More HTML template cleanup and unit tests. +# - download() now implemented correctly, replacing link(is_download=1) [fixed in the +# templates, but link(is_download=1) will still work for existing templates] +# # Revision 1.4 2002/01/22 22:46:22 richard # more htmltemplate cleanups and unit tests #