diff 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
line wrap: on
line diff
--- a/test/test_templating.py	Fri Jul 22 15:48:57 2016 -0400
+++ b/test/test_templating.py	Fri Jul 22 16:10:42 2016 -0400
@@ -109,6 +109,30 @@
         p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'test string< foo@bar')
         self.assertEqual(p.url_quote(), 'test%20string%3C%20foo%40bar')
 
+    def test_string_email(self):
+        ''' test that email obscures the email '''
+        p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'rouilj@foo.example.com')
+        self.assertEqual(p.email(), 'rouilj at foo example ...')
+
+    def test_string_plain_or_hyperlinked(self):
+        ''' test that email obscures the email '''
+        p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded &lt; html</b>')
+        self.assertEqual(p.plain(), 'A string <b> with rouilj@example.com embedded &lt; html</b>')
+        self.assertEqual(p.plain(escape=1), 'A string &lt;b&gt; with rouilj@example.com embedded &amp;lt; html&lt;/b&gt;')
+        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;')
+        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;')
+
+        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;')
+
+    def test_string_field(self):
+        p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded &lt; html</b>')
+        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">')
+
+    def test_string_multiline(self):
+        p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded &lt; html</b>')
+        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>')
+        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>')
+
     def test_url_match(self):
         '''Test the URL regular expression in StringHTMLProperty.
         '''

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