Skip to content

Commit

Permalink
Cleanup test_urls;
Browse files Browse the repository at this point in the history
  • Loading branch information
naspeh committed Sep 21, 2013
1 parent 50055af commit 4a5031f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def check_urls(host=None, verbose=False):
with open('data/urls.json', 'br') as f:
urls = json.loads(f.read().decode())

def get(url, expected_code=200):
def get(url, expected_code=200, indent=''):
comment = ''
try:
conn = HTTPConnection(host)
Expand All @@ -74,8 +74,8 @@ def get(url, expected_code=200):
if code == 200:
res_url = url
else:
res_url = '/' + res.info().get('Location', '')
res_url = res_url.lstrip('http://' + host)
res_url = res.info().get('Location', '')
res_url = res_url.replace('http://' + host, '')
except HTTPError as e:
code = e.code
res_url = None
Expand All @@ -84,15 +84,15 @@ def get(url, expected_code=200):
if code != expected_code:
err = ['%s (%r != %r)' % (url, code, expected_code)]
else:
log('%s %s %s # %s' % (url, code, res_url, comment))
log('%s%s %s %s # %s' % (indent, url, code, res_url, comment))
return err

err = []
for url in sorted(urls.keys()):
aliases = urls.get(url)
err += get(url)
for alias in aliases or []:
err += get(alias, expected_code=301)
err += get(alias, expected_code=301, indent=' ')
if err:
print('Errors:')
print('\n'.join(err))
Expand Down

0 comments on commit 4a5031f

Please sign in to comment.