Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Drop unused site clear cache (#18954)

Iga Karbowiak758df7555b55
diff --git a/saleor/graphql/account/tests/benchmark/test_account.py b/saleor/graphql/account/tests/benchmark/test_account.py
index 6c26ad6d56..b7439dbd81 100644
--- a/saleor/graphql/account/tests/benchmark/test_account.py
+++ b/saleor/graphql/account/tests/benchmark/test_account.py
@@ -5,7 +5,6 @@ import pytest
from django.core.files import File
from .....account.models import Group, User
-from .....site.models import Site
from ....tests.utils import get_graphql_content
@@ -413,10 +412,6 @@ def test_users_for_federation_query_count(
content = get_graphql_content(response)
assert len(content["data"]["_entities"]) == 2
- # Clear cache for proper query count comparison.
- # Site and site settings are cached in `auth_backend` when querying the current site.
- Site.objects.clear_cache()
-
variables = {
"representations": [
{
@@ -496,10 +491,6 @@ def test_addresses_for_federation_query_count(
content = get_graphql_content(response)
assert len(content["data"]["_entities"]) == 1
- # Clear cache for proper query count comparison.
- # Site and site settings are cached in `auth_backend` when querying the current site.
- Site.objects.clear_cache()
-
variables = {
"representations": [
{
diff --git a/saleor/graphql/app/tests/benchmarks/test_apps.py b/saleor/graphql/app/tests/benchmarks/test_apps.py
index 38211b2727..64a3c9dd2c 100644
--- a/saleor/graphql/app/tests/benchmarks/test_apps.py
+++ b/saleor/graphql/app/tests/benchmarks/test_apps.py
@@ -2,7 +2,6 @@ import graphene
import pytest
from .....app.models import App, AppToken
-from .....site.models import Site
from .....webhook.models import Webhook
from ....tests.utils import get_graphql_content
@@ -55,10 +54,6 @@ def test_apps_for_federation_query_count(
content = get_graphql_content(response)
assert len(content["data"]["_entities"]) == 1
- # Clear cache for proper query count comparison.
- # Site and site settings are cached in `auth_backend` when querying the current site.
- Site.objects.clear_cache()
-
variables = {
"representations": [
{
diff --git a/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
index c56fdce2c7..7e6646485f 100644
--- a/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
+++ b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
@@ -17,7 +17,6 @@ from .....plugins.manager import get_plugins_manager
from .....product.models import Product, ProductVariant, ProductVariantChannelListing
from .....product.utils.variant_prices import update_discounted_prices_for_promotion
from .....product.utils.variants import fetch_variants_for_promotion_rules
-from .....site.models import Site
from .....warehouse.models import Stock
from ....core.utils import to_global_id_or_none
from ....tests.utils import get_graphql_content
@@ -839,10 +838,6 @@ def test_update_checkout_lines_with_reservations(
data = content["data"]["checkoutLinesUpdate"]
assert not data["errors"]
- # Clear cache for proper query count comparison.
- # Site and site settings are cached in `auth_backend` when querying the current site.
- Site.objects.clear_cache()
-
# Updating multiple lines in checkout has same query count as updating one
with django_assert_num_queries(107):
variables = {
@@ -1115,10 +1110,6 @@ def test_add_checkout_lines_with_reservations(
data = content["data"]["checkoutLinesAdd"]
assert not data["errors"]
- # Clear cache for proper query count comparison.
- # Site and site settings are cached in `auth_backend` when querying the current site.
- Site.objects.clear_cache()
-
checkout.lines.exclude(id=line.id).delete()
with django_assert_num_queries(104):
diff --git a/saleor/graphql/discount/tests/benchmark/test_voucher_code_bulk_delete.py b/saleor/graphql/discount/tests/benchmark/test_voucher_code_bulk_delete.py
index 883750e686..29c49150ec 100644
--- a/saleor/graphql/discount/tests/benchmark/test_voucher_code_bulk_delete.py
+++ b/saleor/graphql/discount/tests/benchmark/test_voucher_code_bulk_delete.py
@@ -1,7 +1,6 @@
import graphene
import pytest
-from .....site.models import Site
from ....tests.utils import get_graphql_content
VOUCHER_CODE_BULK_DELETE_MUTATION = """
@@ -38,10 +37,6 @@ def test_voucher_code_bulk_delete_queries(
content = get_graphql_content(response)
assert content["data"]["voucherCodeBulkDelete"]["count"] == 1
- # Clear cache for proper query count comparison.
- # Site and site settings are cached in `auth_backend` when querying the current site.
- Site.objects.clear_cache()
-
variables = {"ids": ids[1:]}
with django_assert_num_queries(11):
diff --git a/saleor/graphql/product/tests/benchmark/test_product.py b/saleor/graphql/product/tests/benchmark/test_product.py
index 8f15301b76..34a2dbf4d4 100644
--- a/saleor/graphql/product/tests/benchmark/test_product.py
+++ b/saleor/graphql/product/tests/benchmark/test_product.py
@@ -13,7 +13,6 @@ from .....channel.models import Channel
from .....core.taxes import TaxType
from .....plugins.manager import PluginsManager
from .....product.models import ProductChannelListing, ProductMedia, ProductTranslation
-from .....site.models import Site
from ....tests.utils import get_graphql_content
@@ -334,10 +333,6 @@ def test_retrieve_channel_listings(
)
)
- # Clear cache for proper query count comparison.
- # Site and site settings are cached in `auth_backend` when querying the current site.
- Site.objects.clear_cache()
-
ProductChannelListing.objects.bulk_create(
[
ProductChannelListing(
diff --git a/saleor/graphql/warehouse/tests/benchmark/test_stock_bulk_update.py b/saleor/graphql/warehouse/tests/benchmark/test_stock_bulk_update.py
index 2c7253d3cb..3d32b5cee3 100644
--- a/saleor/graphql/warehouse/tests/benchmark/test_stock_bulk_update.py
+++ b/saleor/graphql/warehouse/tests/benchmark/test_stock_bulk_update.py
@@ -1,7 +1,6 @@
import pytest
from django.db import connection
-from .....site.models import Site
from .....warehouse.models import Stock
from ....tests.utils import get_graphql_content
@@ -90,10 +89,6 @@ def test_stocks_bulk_update_queries_count(
)
assert webhook_queries_count == 1
- # Clear cache for proper query count comparison.
- # Site and site settings are cached in `auth_backend` when querying the current site.
- Site.objects.clear_cache()
-
stocks_input += [
{
"variantExternalReference": variant_1.external_reference,
diff --git a/saleor/tests/e2e/account/account/test_staff_login_customers_only_mode.py b/saleor/tests/e2e/account/account/test_staff_login_customers_only_mode.py
index f67c976893..1363d60559 100644
--- a/saleor/tests/e2e/account/account/test_staff_login_customers_only_mode.py
+++ b/saleor/tests/e2e/account/account/test_staff_login_customers_only_mode.py
@@ -1,7 +1,6 @@
from unittest.mock import patch
import pytest
-from django.contrib.sites.models import Site
from .....site import PasswordLoginMode
from ...account.utils.token_create import raw_token_create
@@ -80,7 +79,6 @@ def test_staff_token_has_no_permissions_in_customers_only_mode(
# Step 3: Switch to CUSTOMERS_ONLY mode
site_settings.password_login_mode = PasswordLoginMode.CUSTOMERS_ONLY
site_settings.save(update_fields=["password_login_mode"])
- Site.objects.clear_cache()
# Step 4: Try to create a product and fetch orders — should fail
response = enabled_client.post_graphql(PRODUCT_CREATE_MUTATION, product_input)
@@ -96,7 +94,6 @@ def test_staff_token_has_no_permissions_in_customers_only_mode(
# Step 5: Switch back to ENABLED mode — should succeed again
site_settings.password_login_mode = PasswordLoginMode.ENABLED
site_settings.save(update_fields=["password_login_mode"])
- Site.objects.clear_cache()
response = enabled_client.post_graphql(PRODUCT_CREATE_MUTATION, product_input)
content = get_graphql_content(response)
diff --git a/saleor/tests/e2e/account/account/test_staff_login_disabled_mode.py b/saleor/tests/e2e/account/account/test_staff_login_disabled_mode.py
index 4b9eae415b..32708b2c83 100644
--- a/saleor/tests/e2e/account/account/test_staff_login_disabled_mode.py
+++ b/saleor/tests/e2e/account/account/test_staff_login_disabled_mode.py
@@ -1,7 +1,6 @@
from unittest.mock import patch
import pytest
-from django.contrib.sites.models import Site
from .....site import PasswordLoginMode
from ...account.utils.token_create import raw_token_create
@@ -80,7 +79,6 @@ def test_staff_token_is_rejected_in_disabled_mode(
# Step 3: Switch to DISABLED mode
site_settings.password_login_mode = PasswordLoginMode.DISABLED
site_settings.save(update_fields=["password_login_mode"])
- Site.objects.clear_cache()
# Step 4: Try to create a product and fetch orders — should fail (user is not authenticated)
response = enabled_client.post_graphql(PRODUCT_CREATE_MUTATION, product_input)
@@ -100,7 +98,6 @@ def test_staff_token_is_rejected_in_disabled_mode(
# Step 5: Switch back to ENABLED mode — should succeed again
site_settings.password_login_mode = PasswordLoginMode.ENABLED
site_settings.save(update_fields=["password_login_mode"])
- Site.objects.clear_cache()
response = enabled_client.post_graphql(PRODUCT_CREATE_MUTATION, product_input)
content = get_graphql_content(response)