Mercurial > p > roundup > code
comparison test/test_templating.py @ 3991:13161539e5bd
improved URL matching
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 18 Aug 2008 06:03:06 +0000 |
| parents | eee76dd4a09f |
| children | e335ce40d6c8 |
comparison
equal
deleted
inserted
replaced
| 3990:0728808fdf5c | 3991:13161539e5bd |
|---|---|
| 85 ( issue = MockNull(getprops = lambda : dict(nosy = nosy)) | 85 ( issue = MockNull(getprops = lambda : dict(nosy = nosy)) |
| 86 , user = MockNull(get = lambda id, name : id, lookup = lookup) | 86 , user = MockNull(get = lambda id, name : id, lookup = lookup) |
| 87 ) | 87 ) |
| 88 cls = HTMLClass(self.client, "issue") | 88 cls = HTMLClass(self.client, "issue") |
| 89 cls["nosy"] | 89 cls["nosy"] |
| 90 | |
| 91 def test_url_match(self): | |
| 92 '''Test the URL regular expression in StringHTMLProperty. | |
| 93 ''' | |
| 94 def t(s, **groups): | |
| 95 m = StringHTMLProperty.hyper_re.search(s) | |
| 96 self.assertNotEquals(m, None, '%r did not match'%s) | |
| 97 d = m.groupdict() | |
| 98 for g in groups: | |
| 99 self.assertEquals(d[g], groups[g], '%s %r != %r in %r'%(g, d[g], | |
| 100 groups[g], s)) | |
| 101 | |
| 102 #t('123.321.123.321', 'url') | |
| 103 t('http://roundup.net/', url='http://roundup.net/') | |
| 104 t('<HTTP://roundup.net/>', url='HTTP://roundup.net/') | |
| 105 t('www.a.ex', url='www.a.ex') | |
| 106 t('http://a.ex', url='http://a.ex') | |
| 107 t('http://a.ex/?foo&bar=baz\\.@!$%()qwerty', | |
| 108 url='http://a.ex/?foo&bar=baz\\.@!$%()qwerty') | |
| 109 t('www.net', url='www.net') | |
| 110 t('richard@com.example', email='richard@com.example') | |
| 111 t('r@a.com', email='r@a.com') | |
| 112 t('i1', **{'class':'i', 'id':'1'}) | |
| 113 t('item123', **{'class':'item', 'id':'123'}) | |
| 114 | |
| 115 def test_url_replace(self): | |
| 116 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '') | |
| 117 def t(s): return p.hyper_re.sub(p._hyper_repl, s) | |
| 118 ae = self.assertEquals | |
| 119 ae(t('http://roundup.net/'), '<a href="http://roundup.net/">http://roundup.net/</a>') | |
| 120 ae(t('<HTTP://roundup.net/>'), '<<a href="HTTP://roundup.net/">HTTP://roundup.net/</a>>') | |
| 121 ae(t('<www.roundup.net>'), '<<a href="http://www.roundup.net">www.roundup.net</a>>') | |
| 90 | 122 |
| 91 ''' | 123 ''' |
| 92 class HTMLPermissions: | 124 class HTMLPermissions: |
| 93 def is_edit_ok(self): | 125 def is_edit_ok(self): |
| 94 def is_view_ok(self): | 126 def is_view_ok(self): |
