Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix url validation. fixes #97

  • Loading branch information...
commit 87304864685e7e9ec0880230d67afb5f02ab4ae7 1 parent 9790ebd
@mcbuddha mcbuddha authored
Showing with 10 additions and 9 deletions.
  1. +4 −0 server_test.py
  2. +6 −9 utils.py
View
4 server_test.py
@@ -73,6 +73,7 @@
}
url_fail = 'http://doesnotwork.example.com'
url_redir = 'http://example.com'
+uri_ = '/home/user/file'
#url_timeout = 'http://...'
@@ -88,6 +89,9 @@ def test_url_1(self):
def test_url_2(self):
self.assertFalse(server.url_fails(url_redir))
+ def test_url_3(self):
+ self.assertFalse(server.url_fails(uri_))
+
class DBHelperTest(unittest.TestCase):
def setUp(self):
View
15 utils.py
@@ -52,14 +52,11 @@ def json_dump(obj):
def url_fails(url):
- if validate_url(url):
- try:
+ try:
+ if validate_url(url):
obj = requests.head(url, allow_redirects=True)
- if obj.status_code == 200:
- return False
- else:
- return True
- except (requests.ConnectionError, AssertionError):
- return True
- else:
+ assert obj.status_code == 200
+ except (requests.ConnectionError, AssertionError):
return True
+ else:
+ return False
Please sign in to comment.
Something went wrong with that request. Please try again.