comparison test/test_templating.py @ 5157:ae2a5d1afdd5

adding tests for some StringHTMLProperty methods.
author John Rouillard <rouilj@ieee.org>
date Fri, 22 Jul 2016 16:10:42 -0400
parents 882fa4d9bead
children 89b1870b1bc9
comparison
equal deleted inserted replaced
5156:882fa4d9bead 5157:ae2a5d1afdd5
106 106
107 def test_string_url_quote(self): 107 def test_string_url_quote(self):
108 ''' test that urlquote quotes the string ''' 108 ''' test that urlquote quotes the string '''
109 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'test string< foo@bar') 109 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'test string< foo@bar')
110 self.assertEqual(p.url_quote(), 'test%20string%3C%20foo%40bar') 110 self.assertEqual(p.url_quote(), 'test%20string%3C%20foo%40bar')
111
112 def test_string_email(self):
113 ''' test that email obscures the email '''
114 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'rouilj@foo.example.com')
115 self.assertEqual(p.email(), 'rouilj at foo example ...')
116
117 def test_string_plain_or_hyperlinked(self):
118 ''' test that email obscures the email '''
119 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded &lt; html</b>')
120 self.assertEqual(p.plain(), 'A string <b> with rouilj@example.com embedded &lt; html</b>')
121 self.assertEqual(p.plain(escape=1), 'A string &lt;b&gt; with rouilj@example.com embedded &amp;lt; html&lt;/b&gt;')
122 self.assertEqual(p.plain(hyperlink=1), 'A string &lt;b&gt; with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &amp;lt; html&lt;/b&gt;')
123 self.assertEqual(p.plain(escape=1, hyperlink=1), 'A string &lt;b&gt; with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &amp;lt; html&lt;/b&gt;')
124
125 self.assertEqual(p.hyperlinked(), 'A string &lt;b&gt; with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &amp;lt; html&lt;/b&gt;')
126
127 def test_string_field(self):
128 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded &lt; html</b>')
129 self.assertEqual(p.field(), '<input type="text" name="test1@test" value="A string &lt;b&gt; with rouilj@example.com embedded &amp;lt; html&lt;/b&gt;" size="30">')
130
131 def test_string_multiline(self):
132 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded &lt; html</b>')
133 self.assertEqual(p.multiline(), '<textarea name="test1@test" id="test1@test" rows="5" cols="40">A string &lt;b&gt; with rouilj@example.com embedded &amp;lt; html&lt;/b&gt;</textarea>')
134 self.assertEqual(p.multiline(rows=300, cols=100, **{'class':'css_class'}), '<textarea class="css_class" name="test1@test" id="test1@test" rows="300" cols="100">A string &lt;b&gt; with rouilj@example.com embedded &amp;lt; html&lt;/b&gt;</textarea>')
111 135
112 def test_url_match(self): 136 def test_url_match(self):
113 '''Test the URL regular expression in StringHTMLProperty. 137 '''Test the URL regular expression in StringHTMLProperty.
114 ''' 138 '''
115 def t(s, nothing=False, **groups): 139 def t(s, nothing=False, **groups):

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