Skip to content

Commit ece77ca

Browse files
committed
adding tests for some StringHTMLProperty methods.
1 parent 2620bcb commit ece77ca

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/test_templating.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,30 @@ def test_string_url_quote(self):
109109
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'test string< foo@bar')
110110
self.assertEqual(p.url_quote(), 'test%20string%3C%20foo%40bar')
111111

112+
def test_string_email(self):
113+
''' test that email obscures the email '''
114+
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '[email protected]')
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 [email protected] embedded &lt; html</b>')
120+
self.assertEqual(p.plain(), 'A string <b> with [email protected] embedded &lt; html</b>')
121+
self.assertEqual(p.plain(escape=1), 'A string &lt;b&gt; with [email protected] embedded &amp;lt; html&lt;/b&gt;')
122+
self.assertEqual(p.plain(hyperlink=1), 'A string &lt;b&gt; with <a href="mailto:[email protected]">[email protected]</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:[email protected]">[email protected]</a> embedded &amp;lt; html&lt;/b&gt;')
124+
125+
self.assertEqual(p.hyperlinked(), 'A string &lt;b&gt; with <a href="mailto:[email protected]">[email protected]</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 [email protected] embedded &lt; html</b>')
129+
self.assertEqual(p.field(), '<input type="text" name="test1@test" value="A string &lt;b&gt; with [email protected] 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 [email protected] 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 [email protected] 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 [email protected] embedded &amp;lt; html&lt;/b&gt;</textarea>')
135+
112136
def test_url_match(self):
113137
'''Test the URL regular expression in StringHTMLProperty.
114138
'''

0 commit comments

Comments
 (0)