PLAT-1863 Fixes for LMS shards 2 and 3 tests under Django 1.9

This commit is contained in:
Jeremy Bowman
2017-12-22 14:32:13 -05:00
parent e98420dd8d
commit bd9c7a082e
7 changed files with 39 additions and 14 deletions

View File

@@ -11,10 +11,19 @@ import django
def expected_redirect_url(relative_url, hostname='testserver'):
"""
Get the expected redirect URL for the current Django version and the
given relative URL. Django 1.8 and earlier redirect to absolute URLs,
later versions redirect to relative ones.
given relative URL:
* Django 1.8 and earlier redirect URLs beginning with a slash to absolute
URLs, later versions redirect to relative ones.
* Django 1.8 and earlier leave URLs without a leading slash alone, later
versions prepend the missing slash.
"""
if django.VERSION < (1, 9):
return 'http://{}{}'.format(hostname, relative_url)
if relative_url.startswith('/'):
return 'http://{}{}'.format(hostname, relative_url)
else:
return relative_url
else:
return relative_url
if relative_url.startswith('/'):
return relative_url
else:
return '/{}'.format(relative_url)