summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f2361f4)
raw | patch | inline | side by side (parent: f2361f4)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 22 Jan 2002 22:46:22 +0000 (22:46 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 22 Jan 2002 22:46:22 +0000 (22:46 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@586 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/htmltemplate.py | patch | blob | history | |
test/test_htmltemplate.py | patch | blob | history |
index 604b6645f4643a99f565359d3f553a2226fabfb7..ff0276fbf09c82f1cf3be6dcfce85aaaf3c5a618 100644 (file)
--- a/roundup/htmltemplate.py
+++ b/roundup/htmltemplate.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: htmltemplate.py,v 1.66 2002-01-22 06:35:40 richard Exp $
+# $Id: htmltemplate.py,v 1.67 2002-01-22 22:46:22 richard Exp $
__doc__ = """
Template engine.
# get the value
value = self.determine_value(property)
- if not value:
- return _('[no %(propname)s]')%{'propname':property.capitalize()}
+ if not value:
+ return _('[no %(propname)s]')%{'propname':property.capitalize()}
propclass = self.properties[property]
if isinstance(propclass, hyperdb.Link):
'''
if not self.nodeid:
return _('[Count: not called from item]')
+
propclass = self.properties[property]
+ if not isinstance(propclass, hyperdb.Multilink):
+ return _('[Count: not a Multilink]')
+
+ # figure the length then...
value = self.cl.get(self.nodeid, property)
- if isinstance(propclass, hyperdb.Multilink):
- return str(len(value))
- return _('[Count: not a Multilink]')
+ return str(len(value))
# XXX pretty is definitely new ;)
def do_reldate(self, property, pretty=0):
'''
if not self.nodeid and self.form is None:
return _('[Reldate: not called from item]')
+
propclass = self.properties[property]
- if isinstance(not propclass, hyperdb.Date):
+ if not isinstance(propclass, hyperdb.Date):
return _('[Reldate: not a Date]')
+
if self.nodeid:
value = self.cl.get(self.nodeid, property)
else:
- value = date.Date('.')
+ return ''
+ if not value:
+ return ''
+
+ # figure the interval
interval = value - date.Date('.')
if pretty:
if not self.nodeid:
#
# $Log: not supported by cvs2svn $
+# Revision 1.66 2002/01/22 06:35:40 richard
+# more htmltemplate tests and cleanup
+#
# Revision 1.65 2002/01/22 00:12:06 richard
# Wrote more unit tests for htmltemplate, and while I was at it, I polished
# off the implementation of some of the functions so they behave sanely.
index 0285a71cc7b58bbf737bcbb73dae2759c3c4f36c..37572394865abfc0d1400511246e848d8287c887 100644 (file)
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: test_htmltemplate.py,v 1.3 2002-01-22 06:35:40 richard Exp $
+# $Id: test_htmltemplate.py,v 1.4 2002-01-22 22:46:22 richard Exp $
import unittest, cgi
# def do_link(self, property=None, is_download=0):
def testLink_novalue(self):
self.assertEqual(self.tf.do_link('novalue'),
- _('[no %(propname)s]')%{'propname':'novalue'.capitalize()})
+ _('[no %(propname)s]')%{'propname':'novalue'.capitalize()})
def testLink_string(self):
self.assertEqual(self.tf.do_link('string'),
self.assertEqual(self.tf.do_link('multilink'),
'<a href="other1">the key</a>, <a href="other2">the key</a>')
+# def do_count(self, property, **args):
+ def testCount_nonlinks(self):
+ s = _('[Count: not a Multilink]')
+ self.assertEqual(self.tf.do_count('string'), s)
+ self.assertEqual(self.tf.do_count('date'), s)
+ self.assertEqual(self.tf.do_count('interval'), s)
+ self.assertEqual(self.tf.do_count('password'), s)
+ self.assertEqual(self.tf.do_count('link'), s)
+
+ def testCount_multilink(self):
+ self.assertEqual(self.tf.do_count('multilink'), '2')
+
+# def do_reldate(self, property, pretty=0):
+ def testReldate_nondate(self):
+ s = _('[Reldate: not a Date]')
+ self.assertEqual(self.tf.do_reldate('string'), s)
+ self.assertEqual(self.tf.do_reldate('interval'), s)
+ self.assertEqual(self.tf.do_reldate('password'), s)
+ self.assertEqual(self.tf.do_reldate('link'), s)
+ self.assertEqual(self.tf.do_reldate('multilink'), s)
+
+ def testReldate_date(self):
+ self.assertEqual(self.tf.do_reldate('date'), '- 2y 1m')
+ self.assertEqual(self.tf.do_reldate('date', pretty=1),
+ ' 1 January 2000')
+
def suite():
return unittest.makeSuite(NodeCase, 'test')
#
# $Log: not supported by cvs2svn $
+# Revision 1.3 2002/01/22 06:35:40 richard
+# more htmltemplate tests and cleanup
+#
# Revision 1.2 2002/01/22 00:12:07 richard
# Wrote more unit tests for htmltemplate, and while I was at it, I polished
# off the implementation of some of the functions so they behave sanely.