Skip to content

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

Fix send email on request account delete mutation

fowczarekf88ce7dcfd7c
diff --git a/saleor/account/emails.py b/saleor/account/emails.py
index 69dd29f17c..ba4d378995 100644
--- a/saleor/account/emails.py
+++ b/saleor/account/emails.py
@@ -78,7 +78,7 @@ def _send_account_delete_confirmation_email_with_url(
"redirect_url": redirect_url,
"params": params,
}
- _send_account_delete_confirmation_email(recipient_email, delete_url)
+ _send_delete_confirmation_email(recipient_email, delete_url)
@app.task
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index 4435c84885..91b78b5bec 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -976,8 +976,24 @@ ACCOUNT_REQUEST_DELETION_MUTATION = """
"""
+@patch("saleor.account.emails._send_delete_confirmation_email")
+def test_account_request_deletion(send_delete_confirmation_email_mock, user_api_client):
+ user = user_api_client.user
+ variables = {"redirectUrl": "https://www.example.com"}
+ response = user_api_client.post_graphql(
+ ACCOUNT_REQUEST_DELETION_MUTATION, variables
+ )
+ content = get_graphql_content(response)
+ data = content["data"]["accountRequestDeletion"]
+ assert not data["errors"]
+ send_delete_confirmation_email_mock.assert_called_once_with(user.email, ANY)
+ url = send_delete_confirmation_email_mock.mock_calls[0][1][1]
+ url_validator = URLValidator()
+ url_validator(url)
+
+
@patch("saleor.account.emails._send_account_delete_confirmation_email_with_url.delay")
-def test_account_request_deletion(
+def test_account_request_deletion_token_validation(
send_account_delete_confirmation_email_with_url_mock, user_api_client
):
user = user_api_client.user