From 065460d78a1fffde87c0dabf430c4551b21149df Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Tue, 27 May 2014 13:33:29 +0200 Subject: [PATCH] add tests for website validation --- isso/tests/test_comments.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/isso/tests/test_comments.py b/isso/tests/test_comments.py index 17a8b79..43d7ecf 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -129,8 +129,25 @@ class TestComments(unittest.TestCase): for text in ("", "\n\n\n"): self.assertFalse(verify({"text": text})) - # email length + # email/website length + self.assertTrue(verify({"text": "...", "email": "*"*254})) + self.assertTrue(verify({"text": "...", "website": "google.de/" + "a"*128})) + self.assertFalse(verify({"text": "...", "email": "*"*1024})) + self.assertFalse(verify({"text": "...", "website": "google.de/" + "*"*1024})) + + # valid website url + self.assertTrue(comments.isurl("example.tld")) + self.assertTrue(comments.isurl("http://example.tld")) + self.assertTrue(comments.isurl("https://example.tld")) + self.assertTrue(comments.isurl("https://example.tld:1337/")) + self.assertTrue(comments.isurl("https://example.tld:1337/foobar")) + self.assertTrue(comments.isurl("https://example.tld:1337/foobar?p=1#isso-thread")) + + self.assertFalse(comments.isurl("ftp://example.tld/")) + self.assertFalse(comments.isurl("tel:+1234567890")) + self.assertFalse(comments.isurl("+1234567890")) + self.assertFalse(comments.isurl("spam")) def testGetInvalid(self):