Tests: Fix improper cleanup of SITE_URL

This commit is contained in:
Raphael Michel
2023-08-10 11:20:26 +02:00
parent 6250ab2165
commit 53e1d9c6c4
6 changed files with 8 additions and 22 deletions

View File

@@ -20,19 +20,19 @@
# <https://www.gnu.org/licenses/>.
#
from django import urls
from django.conf import settings
from django.test import override_settings
from pretix.helpers.urls import build_absolute_uri
def test_site_url_domain():
settings.SITE_URL = 'https://example.com'
assert build_absolute_uri('control:auth.login') == 'https://example.com/control/login'
with override_settings(SITE_URL='https://example.com'):
assert build_absolute_uri('control:auth.login') == 'https://example.com/control/login'
def test_site_url_subpath():
settings.SITE_URL = 'https://example.com/presale'
old_prefix = urls.get_script_prefix()
urls.set_script_prefix('/presale/')
assert build_absolute_uri('control:auth.login') == 'https://example.com/presale/control/login'
urls.set_script_prefix(old_prefix)
with override_settings(SITE_URL='https://example.com/presale'):
old_prefix = urls.get_script_prefix()
urls.set_script_prefix('/presale/')
assert build_absolute_uri('control:auth.login') == 'https://example.com/presale/control/login'
urls.set_script_prefix(old_prefix)