Skip to content

Commit 520c122

Browse files
committed
Test StringHTMLProperty.wrapped(); test url, plain text for rst
1 parent 4b93436 commit 520c122

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/test_templating.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,25 @@ def test_string_email(self):
243243
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '[email protected]')
244244
self.assertEqual(p.email(), 'rouilj at foo example ...')
245245

246+
def test_string_wrapped(self):
247+
test_string = ('A long string that needs to be wrapped to'
248+
' 80 characters and no more. Put in a link issue1.'
249+
' Put in <html> to be escaped. Put in a'
250+
' https://example.com/link as well. Let us see if'
251+
' it will wrap properly.' )
252+
test_result = ('A long string that needs to be wrapped to 80'
253+
' characters and no more. Put in a\n'
254+
'link <a href="issue1">issue1</a>. Put in'
255+
' &lt;html&gt; to be escaped. Put in a <a'
256+
' href="https://example.com/link"'
257+
' rel="nofollow noopener">'
258+
'https://example.com/link</a> as\n'
259+
'well. Let us see if it will wrap properly.')
260+
261+
p = StringHTMLProperty(self.client, 'test', '1', None, 'test',
262+
test_string)
263+
self.assertEqual(p.wrapped(), test_result)
264+
246265
def test_string_plain_or_hyperlinked(self):
247266
''' test that email obscures the email '''
248267
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with [email protected] embedded &lt; html</b>')
@@ -312,10 +331,20 @@ def test_string_rst(self):
312331
s = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'<badtag>\njavascript:badcode data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=='))
313332
s_result = '<div class="document">\n<p>&lt;badtag&gt;\njavascript:badcode data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==</p>\n</div>\n'
314333

334+
# test url recognition
335+
t = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'link is https://example.com/link for testing.'))
336+
t_result = '<div class="document">\n<p>link is <a class="reference external" href="https://example.com/link">https://example.com/link</a> for testing.</p>\n</div>\n'
337+
338+
# test text that doesn't need to be processed
339+
u = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'Just a plain old string here. Nothig to process.'))
340+
u_result = '<div class="document">\n<p>Just a plain old string here. Nothig to process.</p>\n</div>\n'
341+
315342
self.assertEqual(p.rst(), u2s(u'<div class="document">\n<p>A string with <a class="reference external" href="mailto:cmeerw&#64;example.com">cmeerw&#64;example.com</a> <em>embedded</em> \u00df</p>\n</div>\n'))
316343
self.assertEqual(q.rst(), u2s(q_result))
317344
self.assertEqual(r.rst(), u2s(r_result))
318345
self.assertEqual(s.rst(), u2s(s_result))
346+
self.assertEqual(t.rst(), u2s(t_result))
347+
self.assertEqual(u.rst(), u2s(u_result))
319348

320349
@skip_stext
321350
def test_string_stext(self):

0 commit comments

Comments
 (0)