index 80bae0efded1cb673c1ef865946d6e8accf8709c..a4c531b9257b07edc2a13332a9782c83cab17d1d 100644 (file)
--- a/test/test_templating.py
+++ b/test/test_templating.py
class HTMLClassTestCase(TemplatingTestCase) :
+ def test_link(self):
+ """Make sure lookup of a Link property works even in the
+ presence of multiple values in the form."""
+ def lookup(key) :
+ self.assertEqual(key, key.strip())
+ return "Status%s"%key
+ self.form.list.append(MiniFieldStorage("status", "1"))
+ self.form.list.append(MiniFieldStorage("status", "2"))
+ status = hyperdb.Link("status")
+ self.client.db.classes = dict \
+ ( issue = MockNull(getprops = lambda : dict(status = status))
+ , status = MockNull(get = lambda id, name : id, lookup = lookup)
+ )
+ cls = HTMLClass(self.client, "issue")
+ cls["status"]
+
def test_multilink(self):
"""`lookup` of an item will fail if leading or trailing whitespace
has not been stripped.
def test_url_replace(self):
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '')
def t(s): return p.hyper_re.sub(p._hyper_repl, s)
- ae = self.assertEquals
- ae(t('http://roundup.net/'), '<a href="http://roundup.net/">http://roundup.net/</a>')
- ae(t('<HTTP://roundup.net/>'), '<<a href="HTTP://roundup.net/">HTTP://roundup.net/</a>>')
- ae(t('<www.roundup.net>'), '<<a href="http://www.roundup.net">www.roundup.net</a>>')
+ ae = self.assertEqual
+ ae(t('item123123123123'), 'item123123123123')
+ ae(t('http://roundup.net/'),
+ '<a href="http://roundup.net/">http://roundup.net/</a>')
+ ae(t('<HTTP://roundup.net/>'),
+ '<<a href="HTTP://roundup.net/">HTTP://roundup.net/</a>>')
+ ae(t('<http://roundup.net/>.'),
+ '<<a href="http://roundup.net/">http://roundup.net/</a>>.')
+ ae(t('<www.roundup.net>'),
+ '<<a href="http://www.roundup.net">www.roundup.net</a>>')
+ ae(t('(www.roundup.net)'),
+ '(<a href="http://www.roundup.net">www.roundup.net</a>)')
+ ae(t('foo http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx bar'),
+ 'foo <a href="http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx">'
+ 'http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx</a> bar')
+ ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))'),
+ '(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
+ 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)')
+ ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language)).'),
+ '(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
+ 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>).')
+ ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))>.'),
+ '(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
+ 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)>.')
+ ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language>)).'),
+ '(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language">'
+ 'http://en.wikipedia.org/wiki/Python_(programming_language</a>>)).')
'''
class HTMLPermissions: