PLAT-1847 Fix cms tests under Django 1.9

This commit is contained in:
Jeremy Bowman
2017-12-13 15:29:02 -05:00
parent a0df76e19e
commit d44e6297ae
8 changed files with 36 additions and 12 deletions

View File

@@ -0,0 +1,20 @@
"""
Utilities for Open edX unit tests.
"""
from __future__ import absolute_import, unicode_literals
import django
# TODO: Remove Django 1.11 upgrade shim
# SHIM: We should be able to get rid of this utility post-upgrade
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.
"""
if django.VERSION < (1, 9):
return 'http://{}{}'.format(hostname, relative_url)
else:
return relative_url