Skip to content

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

Fix tests

Krzysztof Świątek7311a72a1ad7
diff --git a/saleor/account/utils.py b/saleor/account/utils.py
index 67e6a059f6..681c0200e4 100644
--- a/saleor/account/utils.py
+++ b/saleor/account/utils.py
@@ -1,10 +1,6 @@
-import os
-import random
-
import jwt
from django.conf import settings
from django.core.exceptions import ValidationError
-from django.core.files import File
from django.utils import timezone
from ..account.error_codes import AccountErrorCode
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index 1245c78431..3947727243 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -16,7 +16,7 @@ from prices import Money
from saleor.account import events as account_events
from saleor.account.error_codes import AccountErrorCode
from saleor.account.models import Address, User
-from saleor.account.utils import create_jwt_token, get_random_avatar
+from saleor.account.utils import create_jwt_token
from saleor.checkout import AddressType
from saleor.graphql.account.mutations.base import INVALID_TOKEN
from saleor.graphql.account.mutations.staff import (
@@ -1537,11 +1537,6 @@ def test_staff_update_doesnt_change_existing_avatar(
staff_user = User.objects.create(email="[email protected]", is_staff=True)
- # Create random avatar
- staff_user.avatar = get_random_avatar()
- staff_user.save()
- original_path = staff_user.avatar.path
-
id = graphene.Node.to_global_id("User", staff_user.id)
variables = {"id": id, "permissions": [], "is_active": False}
response = staff_api_client.post_graphql(
@@ -1552,7 +1547,7 @@ def test_staff_update_doesnt_change_existing_avatar(
assert data["errors"] == []
staff_user.refresh_from_db()
- assert staff_user.avatar.path == original_path
+ assert not staff_user.avatar
def test_staff_delete(staff_api_client, permission_manage_staff):
diff --git a/tests/test_account.py b/tests/test_account.py
index 53ed5486b4..a316611995 100644
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -1,10 +1,8 @@
-import re
from urllib.parse import urlencode
import i18naddress
import pytest
from django.core.exceptions import ValidationError
-from django.core.files import File
from django.http import QueryDict
from django.template import Context, Template
from django_countries.fields import Country
@@ -13,7 +11,7 @@ from saleor.account import forms, i18n
from saleor.account.i18n import AddressForm
from saleor.account.models import User
from saleor.account.templatetags.i18n_address_tags import format_address
-from saleor.account.utils import get_random_avatar, remove_staff_member
+from saleor.account.utils import remove_staff_member
from saleor.account.validators import validate_possible_number
@@ -293,12 +291,6 @@ def test_get_full_name(email, first_name, last_name, full_name, address):
assert user.get_full_name() == full_name
-def test_get_random_avatar():
- avatar = get_random_avatar()
- assert isinstance(avatar, File)
- assert re.match(r"avatar\d+.png", avatar.name)
-
-
def test_remove_staff_member_with_orders(staff_user, permission_manage_products, order):
order.user = staff_user
order.save()
diff --git a/tests/test_core.py b/tests/test_core.py
index 13b4f2fbe3..2b23c174f8 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -99,7 +99,7 @@ def test_create_superuser(db, client, media_root):
assert User.objects.all().count() == 1
admin = User.objects.all().first()
assert admin.is_superuser
- assert admin.avatar
+ assert not admin.avatar
# Test duplicating
create_superuser(credentials)
assert User.objects.all().count() == 1