Return-Path: X-Original-To: apmail-allura-commits-archive@www.apache.org Delivered-To: apmail-allura-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AF99F105AC for ; Thu, 27 Mar 2014 16:12:41 +0000 (UTC) Received: (qmail 99309 invoked by uid 500); 27 Mar 2014 16:12:41 -0000 Delivered-To: apmail-allura-commits-archive@allura.apache.org Received: (qmail 99267 invoked by uid 500); 27 Mar 2014 16:12:39 -0000 Mailing-List: contact commits-help@allura.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@allura.apache.org Delivered-To: mailing list commits@allura.apache.org Received: (qmail 99109 invoked by uid 99); 27 Mar 2014 16:12:29 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Mar 2014 16:12:29 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1B5FC8943FB; Thu, 27 Mar 2014 16:12:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brondsem@apache.org To: commits@allura.apache.org Date: Thu, 27 Mar 2014 16:12:28 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/5] git commit: [#7160] ticket:557 add unit test for URL validator 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 Authored: Tue Mar 11 19:19:25 2014 +0400 Committer: Dave Brondsema 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')