Permalink
Browse files

Add another test.

Also allow = and &
Fix typos.
  • Loading branch information...
markotibold committed Sep 20, 2012
1 parent 86bb516 commit 9d61ffb2295b859b377f749d965794d694d8413b
Showing with 8 additions and 5 deletions.
  1. +6 −3 fiber/tests.py
  2. +2 −2 fiber/utils/validators.py
View
@@ -546,10 +546,13 @@ class TestUtilsURLValidator(TestCase):
validator = FiberURLValidator()
def test_passes_normal(self):
- self.assertEqual(self.validator('http://google.com'), None)
+ self.assertEqual(self.validator('http://www.google.com/'), None)
- def test_passes_url_containts_anchor(self):
- self.assertEqual(self.validator('/some_page#SomeAnchor'), None)
+ def test_passes_url_contains_anchor(self):
+ self.assertEqual(self.validator('/some/page/#SomeAnchor'), None)
+
+ def test_passes_url_contains_querystring_and_anchor(self):
+ self.assertEqual(self.validator('/some/page/?id=12&user_id=1#SomeAnchor'), None)
def test_named_url(self):
# Must raise if named url does not exist
@@ -14,7 +14,7 @@ class FiberURLValidator(RegexValidator):
Django's `URLValidator` only matches urls that are prefixed with a protocol.
"""
protocol_regex = re.compile(r'^(((http|ftp)s?)://).+$', re.IGNORECASE)
- regex = re.compile(r'^[-\w/\.\:#?""]+$')
+ regex = re.compile(r'^[-\w/\.\:#\?&"=]+$')
def __call__(self, value):
"""
@@ -27,7 +27,7 @@ def __call__(self, value):
django_url_validator = URLValidator(verify_exists=False)
django_url_validator(url)
else:
- # check if it's a named url, and if so, if it's reversable
+ # check if it's a named url, and if so, if it's reversible
if is_quoted_url(url) and not get_named_url_from_quoted_url(url):
raise ValidationError(_('No reverse match found for the named url'), 'no_reverse_match')
# check if it's a fiber_url (more strict than absolute url)

0 comments on commit 9d61ffb

Please sign in to comment.