Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add build absolute uri test
TOMEKd0f7233bcb77
diff --git a/tests/dashboard/test_staff.py b/tests/dashboard/test_staff.pyindex 56a9e932ed..9fa7d14943 100644--- a/tests/dashboard/test_staff.py+++ b/tests/dashboard/test_staff.py@@ -100,8 +100,7 @@ def test_send_set_password_email(staff_user, site_settings):site = site_settings.siteuid = urlsafe_base64_encode(force_bytes(staff_user.pk)).decode()token = default_token_generator.make_token(staff_user)- logo_url = build_absolute_uri(- location=None) + static('images/logo-document.svg')+ logo_url = build_absolute_uri(static('images/logo-document.svg'))password_set_url = build_absolute_uri(reverse('account:reset-password-confirm',diff --git a/tests/test_core.py b/tests/test_core.pyindex 405edea56b..c697899fa9 100644--- a/tests/test_core.py+++ b/tests/test_core.py@@ -1,20 +1,22 @@import iofrom contextlib import redirect_stdoutfrom unittest.mock import Mock, patch+from urllib.parse import urljoinimport pytestfrom django.conf import settingsfrom django.db.models import Case, F, Whenfrom django.shortcuts import reverse+from django.templatetags.static import staticfrom django.urls import translate_urlfrom measurement.measures import Weightfrom prices import Moneyfrom saleor.account.models import Address, Userfrom saleor.core.storages import S3MediaStoragefrom saleor.core.utils import (- Country, create_superuser, create_thumbnails, format_money,- get_country_by_ip, get_currency_for_country, random_data)+ Country, build_absolute_uri, create_superuser, create_thumbnails,+ format_money, get_country_by_ip, get_currency_for_country, random_data)from saleor.core.utils.text import get_cleaner, strip_htmlfrom saleor.core.weight import WeightUnits, convert_weightfrom saleor.discount.models import Sale, Voucher@@ -299,3 +301,12 @@ def test_convert_weight():weight = Weight(kg=1)expected_result = Weight(g=1000)assert convert_weight(weight, WeightUnits.GRAM) == expected_result++def test_build_absolute_uri(site_settings):+ url = 'https://example.com/static/images/image.jpg'+ logo_url = build_absolute_uri(static('images/logo-document.svg'))+ protocol = 'https' if settings.ENABLE_SSL else 'http'+ current_url = '%s://%s' % (protocol, site_settings.site.domain)+ logo_location = urljoin(current_url, static('images/logo-document.svg'))+ assert build_absolute_uri(location=url) == url+ assert logo_url == logo_location