Skip to content

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

Rename delete_from_storage to delete_from_storage_task

IKarbowiak0a6d4beb74f9
diff --git a/saleor/attribute/signals.py b/saleor/attribute/signals.py
index 55a5f8f56c..9039fb054c 100644
--- a/saleor/attribute/signals.py
+++ b/saleor/attribute/signals.py
@@ -1,6 +1,6 @@
-from ..core.tasks import delete_from_storage
+from ..core.tasks import delete_from_storage_task
def delete_attribute_value_file(sender, instance, **kwargs):
if file_url := instance.file_url:
- delete_from_storage.delay(file_url)
+ delete_from_storage_task.delay(file_url)
diff --git a/saleor/core/tasks.py b/saleor/core/tasks.py
index e552d03e47..0910a81ab3 100644
--- a/saleor/core/tasks.py
+++ b/saleor/core/tasks.py
@@ -4,5 +4,5 @@ from ..celeryconf import app
@app.task
-def delete_from_storage(path):
+def delete_from_storage_task(path):
default_storage.delete(path)
diff --git a/saleor/core/tests/test_tasks.py b/saleor/core/tests/test_tasks.py
index 8cc34350f6..ae3ff420ce 100644
--- a/saleor/core/tests/test_tasks.py
+++ b/saleor/core/tests/test_tasks.py
@@ -1,25 +1,25 @@
from django.core.files.storage import default_storage
-from ..tasks import delete_from_storage
+from ..tasks import delete_from_storage_task
-def test_delete_from_storage(product_with_image, media_root):
+def test_delete_from_storage_task(product_with_image, media_root):
# given
path = product_with_image.media.first().image.path
assert default_storage.exists(path)
# when
- delete_from_storage(path)
+ delete_from_storage_task(path)
# then
assert not default_storage.exists(path)
-def test_delete_from_storage_file_that_not_exists(media_root):
+def test_delete_from_storage_task_file_that_not_exists(media_root):
"""Ensure method not fail when trying to remove not existing file."""
# given
path = "random/test-path"
assert not default_storage.exists(path)
# when
- delete_from_storage(path)
+ delete_from_storage_task(path)
diff --git a/saleor/graphql/attribute/tests/mutations/test_attribute_delete.py b/saleor/graphql/attribute/tests/mutations/test_attribute_delete.py
index 080d588044..6810c4714d 100644
--- a/saleor/graphql/attribute/tests/mutations/test_attribute_delete.py
+++ b/saleor/graphql/attribute/tests/mutations/test_attribute_delete.py
@@ -20,9 +20,9 @@ ATTRIBUTE_DELETE_MUTATION = """
"""
-@patch("saleor.attribute.signals.delete_from_storage.delay")
+@patch("saleor.attribute.signals.delete_from_storage_task.delay")
def test_delete_attribute(
- delete_from_storage_mock,
+ delete_from_storage_task_mock,
staff_api_client,
color_attribute,
permission_manage_product_types_and_attributes,
@@ -45,12 +45,12 @@ def test_delete_attribute(
assert data["attribute"]["id"] == variables["id"]
with pytest.raises(attribute._meta.model.DoesNotExist):
attribute.refresh_from_db()
- delete_from_storage_mock.assert_not_called()
+ delete_from_storage_task_mock.assert_not_called()
-@patch("saleor.attribute.signals.delete_from_storage.delay")
+@patch("saleor.attribute.signals.delete_from_storage_task.delay")
def test_delete_file_attribute(
- delete_from_storage_mock,
+ delete_from_storage_task_mock,
staff_api_client,
file_attribute,
permission_manage_product_types_and_attributes,
@@ -74,5 +74,7 @@ def test_delete_file_attribute(
assert data["attribute"]["id"] == variables["id"]
with pytest.raises(attribute._meta.model.DoesNotExist):
attribute.refresh_from_db()
- assert delete_from_storage_mock.call_count == len(paths)
- assert {call.args[0] for call in delete_from_storage_mock.call_args_list} == paths
+ assert delete_from_storage_task_mock.call_count == len(paths)
+ assert {
+ call.args[0] for call in delete_from_storage_task_mock.call_args_list
+ } == paths
diff --git a/saleor/graphql/attribute/tests/mutations/test_attribute_value_delete.py b/saleor/graphql/attribute/tests/mutations/test_attribute_value_delete.py
index 233fc5eab4..0a92857d70 100644
--- a/saleor/graphql/attribute/tests/mutations/test_attribute_value_delete.py
+++ b/saleor/graphql/attribute/tests/mutations/test_attribute_value_delete.py
@@ -15,7 +15,7 @@ ATTRIBUTE_VALUE_DELETE_MUTATION = """
"""
-@patch("saleor.attribute.signals.delete_from_storage.delay")
+@patch("saleor.attribute.signals.delete_from_storage_task.delay")
def test_delete_attribute_value(
delete_from_storage_mock,
staff_api_client,
@@ -40,7 +40,7 @@ def test_delete_attribute_value(
delete_from_storage_mock.assert_not_called()
-@patch("saleor.attribute.signals.delete_from_storage.delay")
+@patch("saleor.attribute.signals.delete_from_storage_task.delay")
def test_delete_file_attribute_value(
delete_from_storage_mock,
staff_api_client,
diff --git a/saleor/graphql/product/tests/test_digital_content.py b/saleor/graphql/product/tests/test_digital_content.py
index 1a7ebe30cc..bc0d0d7a75 100644
--- a/saleor/graphql/product/tests/test_digital_content.py
+++ b/saleor/graphql/product/tests/test_digital_content.py
@@ -181,9 +181,9 @@ DIGITAL_CONTENT_DELETE_MUTATION = """
"""
-@patch("saleor.product.signals.delete_from_storage.delay")
+@patch("saleor.product.signals.delete_from_storage_task.delay")
def test_digital_content_delete_mutation(
- delete_from_storage_mock,
+ delete_from_storage_task_mock,
monkeypatch,
staff_api_client,
variant,
@@ -206,7 +206,7 @@ def test_digital_content_delete_mutation(
get_graphql_content(response)
variant = ProductVariant.objects.get(id=variant.id)
assert not hasattr(variant, "digital_content")
- delete_from_storage_mock.assert_called_once_with(path)
+ delete_from_storage_task_mock.assert_called_once_with(path)
def test_digital_content_update_mutation(
diff --git a/saleor/product/signals.py b/saleor/product/signals.py
index 70789b4e60..223c8716b2 100644
--- a/saleor/product/signals.py
+++ b/saleor/product/signals.py
@@ -1,4 +1,4 @@
-from ..core.tasks import delete_from_storage
+from ..core.tasks import delete_from_storage_task
from ..core.utils import delete_versatile_image
@@ -14,4 +14,4 @@ def delete_product_media_image(sender, instance, **kwargs):
def delete_digital_content_file(sender, instance, **kwargs):
if file := instance.content_file:
- delete_from_storage.delay(file.path)
+ delete_from_storage_task.delay(file.path)