Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix flaky test and get rid of warnings (#8458)
Iga Karbowiakcf02ee5e6de6
diff --git a/saleor/graphql/account/tests/test_account.py b/saleor/graphql/account/tests/test_account.pyindex 209ecd0bcf..3adf796c5b 100644--- a/saleor/graphql/account/tests/test_account.py+++ b/saleor/graphql/account/tests/test_account.py@@ -4628,8 +4628,8 @@ def test_query_staff_members_app_no_permission(({"search": "Kowalski"}, 1),({"search": "John"}, 1), # first_name({"search": "Doe"}, 1), # last_name- ({"search": "wroc"}, 1), # city- ({"search": "pl"}, 2), # country+ ({"search": "irv"}, 1), # city+ ({"search": "us"}, 1), # country],)def test_query_staff_members_with_filter_search(@@ -4638,7 +4638,7 @@ def test_query_staff_members_with_filter_search(query_staff_users_with_filter,staff_api_client,permission_manage_staff,- address,+ address_usa,staff_user,):users = User.objects.bulk_create(@@ -4664,7 +4664,7 @@ def test_query_staff_members_with_filter_search(),])- users[1].addresses.set([address])+ users[1].addresses.set([address_usa])variables = {"filter": staff_member_filter}response = staff_api_client.post_graphql(diff --git a/saleor/graphql/attribute/utils.py b/saleor/graphql/attribute/utils.pyindex 1b051d1029..bfe9cd3b6f 100644--- a/saleor/graphql/attribute/utils.py+++ b/saleor/graphql/attribute/utils.py@@ -1,6 +1,7 @@import refrom collections import defaultdictfrom dataclasses import dataclass+from datetime import datetimefrom typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Tuple, Unionfrom urllib.parse import urlparse@@ -9,6 +10,7 @@ from django.conf import settingsfrom django.core.exceptions import ValidationErrorfrom django.db.models import Qfrom django.template.defaultfilters import truncatechars+from django.utils import timezonefrom django.utils.text import slugifyfrom graphql.error import GraphQLError@@ -208,16 +210,18 @@ class AttributeAssignmentMixin:attribute: attribute_models.Attribute,attr_values: AttrValuesInput,):- value = (- attr_values.date- if attribute.input_type == AttributeInputType.DATE- else attr_values.date_time- )+ is_date_attr = attribute.input_type == AttributeInputType.DATE+ value = attr_values.date if is_date_attr else attr_values.date_time- defaults = {- "date_time": value,- "name": value,- }+ tz = timezone.get_current_timezone()+ date_time = (+ datetime(+ value.year, value.month, value.day, 0, 0, tzinfo=tz # type: ignore+ )+ if is_date_attr+ else value+ )+ defaults = {"name": value, "date_time": date_time}return (cls._update_or_create_value(instance, attribute, defaults) if value else ())