[Zope3-checkins] CVS: Products3/z3checkins/tests - test_message.py:1.20

Gintautas Miliauskas gintas at pov.lt
Tue Feb 10 14:27:53 EST 2004


Update of /cvs-repository/Products3/z3checkins/tests
In directory cvs.zope.org:/tmp/cvs-serv8936/tests

Modified Files:
	test_message.py 
Log Message:
Now hyperlinks are created for URL's in the message body.


=== Products3/z3checkins/tests/test_message.py 1.19 => 1.20 ===
--- Products3/z3checkins/tests/test_message.py:1.19	Tue Feb 10 12:51:14 2004
+++ Products3/z3checkins/tests/test_message.py	Tue Feb 10 14:27:53 2004
@@ -1003,6 +1003,28 @@
         self.assertEquals(m(' x<tag\t>xxxxx|\t|'), ' x<tag\t>xxxxx|<span class="tab">></span>|')
         self.assertEquals(m(' x&ent;xxxx|\t|'), ' x&ent;xxxx|<span class="tab">></span>|')
 
+    def test_urls(self):
+        from zopeproducts.z3checkins.message import CheckinMessageView
+        view = CheckinMessageView()
+        prefixes = ['', 'A link: ', '(', '<']
+        suffixes = ['', ' etc.', ')', '>', '.', ',', '\n']
+        urls = ['http://www.example.com', 'https://www.example.com', 'http://localhost:8080/foo?q=a&w=b']
+
+        def quote(text):
+            return (text.replace('&', '&amp;')
+                        .replace('<', '&lt;')
+                        .replace('>', '&gt;')
+                        .replace('"', '&quot;'))
+
+        for prefix in prefixes:
+            for link in urls:
+                for suffix in suffixes:
+                    view.context = MessageStub(body="%s%s%s" % (prefix, link, suffix))
+                    prefix = quote(prefix)
+                    link = quote(link)
+                    suffix = quote(suffix)
+                    self.assertEquals(view.body(), '<pre>%s<a href="%s">%s</a>%s</pre>' % (prefix, link, link, suffix))
+
     def test_navigation_no_archive(self):
         from zopeproducts.z3checkins.message import CheckinMessageView
         view = CheckinMessageView()




More information about the Zope3-Checkins mailing list