Skip to content

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

increase test coverage

Tomasz Szymański2af91ea49d70
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index d36dc9da30..ec042c5e70 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -2152,6 +2152,32 @@ def test_account_confirmation(user_api_client, customer_user):
assert customer_user.is_active == True
+def test_account_confirmation_invalid_user(user_api_client, customer_user):
+ variables = {
+ "email": "[email protected]",
+ "token": default_token_generator.make_token(customer_user)
+ }
+ response = user_api_client.post_graphql(CONFIRM_ACCOUNT_MUTATION, variables)
+ content = get_graphql_content(response)
+ assert content["data"]["confirmAccount"]["errors"] == [{
+ "field": "email",
+ "message": "User with this email doesn't exist"
+ }]
+
+
+def test_account_confirmation_invalid_token(user_api_client, customer_user):
+ variables = {
+ "email": customer_user.email,
+ "token": "invalid_token"
+ }
+ response = user_api_client.post_graphql(CONFIRM_ACCOUNT_MUTATION, variables)
+ content = get_graphql_content(response)
+ assert content["data"]["confirmAccount"]["errors"] == [{
+ "field": "token",
+ "message": "Invalid or expired token."
+ }]
+
+
@patch("saleor.account.emails._send_password_reset_email")
def test_request_password_reset_email_for_staff(
send_password_reset_email_mock, staff_api_client