allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/5] git commit: [#7160] ticket:557 add unit test for URL validator
Date Thu, 27 Mar 2014 16:12:28 GMT
Repository: allura
Updated Branches:
  refs/heads/master cb78d4554 -> ac7bf9822


[#7160] ticket:557 add unit test for URL validator


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/ac7bf982
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/ac7bf982
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/ac7bf982

Branch: refs/heads/master
Commit: ac7bf98224e9ae16ed418964cba00bfb95b723a4
Parents: ee90c93
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Tue Mar 11 19:19:25 2014 +0400
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Mar 27 16:12:14 2014 +0000

----------------------------------------------------------------------
 Allura/allura/tests/test_validators.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ac7bf982/Allura/allura/tests/test_validators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_validators.py b/Allura/allura/tests/test_validators.py
index 2e6bb02..eacd286 100644
--- a/Allura/allura/tests/test_validators.py
+++ b/Allura/allura/tests/test_validators.py
@@ -233,3 +233,20 @@ class TestPathValidator(unittest.TestCase):
 
     def test_no_input(self):
         self.assertEqual({}, self.val.to_python(''))
+
+
+class TestUrlValidator(unittest.TestCase):
+    val = v.URL
+    def test_valid(self):
+        self.assertEqual('http://192.168.0.1', self.val.to_python('192.168.0.1'))
+        self.assertEqual('http://url', self.val.to_python('url'))
+
+    def test_invalid_ip(self):
+        with self.assertRaises(fe.Invalid) as cm:
+            self.val.to_python('192.168.0')
+        self.assertEqual(str(cm.exception), 'That is not a valid URL')
+
+    def test_invalid_url(self):
+        with self.assertRaises(fe.Invalid) as cm:
+            self.val.to_python('u"rl')
+        self.assertEqual(str(cm.exception), 'That is not a valid URL')


Mime
View raw message