Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop unused AttributeValueType
IKarbowiakd9bdb71982fa
diff --git a/saleor/graphql/attribute/enums.py b/saleor/graphql/attribute/enums.pyindex 58b0a4244b..f55571f4fe 100644--- a/saleor/graphql/attribute/enums.py+++ b/saleor/graphql/attribute/enums.py@@ -1,15 +1,6 @@-import graphene-from ...attribute import AttributeEntityType, AttributeInputType, AttributeTypefrom ..core.enums import to_enumAttributeInputTypeEnum = to_enum(AttributeInputType)AttributeTypeEnum = to_enum(AttributeType)AttributeEntityTypeEnum = to_enum(AttributeEntityType)---class AttributeValueType(graphene.Enum):- COLOR = "COLOR"- GRADIENT = "GRADIENT"- URL = "URL"- STRING = "STRING"diff --git a/saleor/graphql/attribute/tests/mutations/test_attribute_value_create.py b/saleor/graphql/attribute/tests/mutations/test_attribute_value_create.pyindex 5fca083e9d..5b1a4e55ff 100644--- a/saleor/graphql/attribute/tests/mutations/test_attribute_value_create.py+++ b/saleor/graphql/attribute/tests/mutations/test_attribute_value_create.py@@ -42,7 +42,6 @@ CREATE_ATTRIBUTE_VALUE_MUTATION = """}attributeValue {name- typeslug}}@@ -73,7 +72,6 @@ def test_create_attribute_value(attr_data = data["attributeValue"]assert attr_data["name"] == nameassert attr_data["slug"] == slugify(name)- assert attr_data["type"] == "STRING"assert name in [value["name"] for value in data["attribute"]["values"]]diff --git a/saleor/graphql/attribute/tests/queries/test_attribute_query.py b/saleor/graphql/attribute/tests/queries/test_attribute_query.pyindex 622ed272f9..eb84a590b8 100644--- a/saleor/graphql/attribute/tests/queries/test_attribute_query.py+++ b/saleor/graphql/attribute/tests/queries/test_attribute_query.py@@ -6,8 +6,6 @@ from graphene.utils.str_converters import to_camel_casefrom .....attribute.models import Attributefrom .....product.models import Category, Collection, Product, ProductTypefrom ....tests.utils import assert_no_permission, get_graphql_content-from ...enums import AttributeValueType-from ...types import resolve_attribute_value_typedef test_get_single_attribute_by_id_as_customer(@@ -431,28 +429,6 @@ def test_retrieving_the_restricted_attributes_restricted(assert found_attributes[0]["node"][attribute] == expected_value- "raw_value, expected_type",- [- ("#0000", AttributeValueType.COLOR),- ("#FF69B4", AttributeValueType.COLOR),- ("rgb(255, 0, 0)", AttributeValueType.COLOR),- ("hsl(0, 100%, 50%)", AttributeValueType.COLOR),- ("hsla(120, 60%, 70%, 0.3)", AttributeValueType.COLOR),- ("rgba(100%, 255, 0, 0)", AttributeValueType.COLOR),- ("http://example.com", AttributeValueType.URL),- ("https://example.com", AttributeValueType.URL),- ("ftp://example.com", AttributeValueType.URL),- ("example.com", AttributeValueType.STRING),- ("Foo", AttributeValueType.STRING),- ("linear-gradient(red, yellow)", AttributeValueType.GRADIENT),- ("radial-gradient(#0000, yellow)", AttributeValueType.GRADIENT),- ],-)-def test_resolve_attribute_value_type(raw_value, expected_type):- assert resolve_attribute_value_type(raw_value) == expected_type--@pytest.mark.parametrize("tested_field", ["inCategory", "inCollection"])def test_attributes_in_collection_query(user_api_client,diff --git a/saleor/graphql/attribute/types.py b/saleor/graphql/attribute/types.pyindex 17fd1208c7..01d1ad0704 100644--- a/saleor/graphql/attribute/types.py+++ b/saleor/graphql/attribute/types.py@@ -14,37 +14,15 @@ from ..translations.fields import TranslationFieldfrom ..translations.types import AttributeTranslation, AttributeValueTranslationfrom .dataloaders import AttributesByAttributeId, AttributeValuesByAttributeIdLoaderfrom .descriptions import AttributeDescriptions, AttributeValueDescriptions-from .enums import (- AttributeEntityTypeEnum,- AttributeInputTypeEnum,- AttributeTypeEnum,- AttributeValueType,-)+from .enums import AttributeEntityTypeEnum, AttributeInputTypeEnum, AttributeTypeEnumCOLOR_PATTERN = r"^(#[0-9a-fA-F]{3}|#(?:[0-9a-fA-F]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))$" # noqacolor_pattern = re.compile(COLOR_PATTERN)-def resolve_attribute_value_type(attribute_value):- if color_pattern.match(attribute_value):- return AttributeValueType.COLOR- if "gradient(" in attribute_value:- return AttributeValueType.GRADIENT- if "://" in attribute_value:- return AttributeValueType.URL- return AttributeValueType.STRING--class AttributeValue(CountableDjangoObjectType):name = graphene.String(description=AttributeValueDescriptions.NAME)slug = graphene.String(description=AttributeValueDescriptions.SLUG)- type = AttributeValueType(- description=AttributeValueDescriptions.TYPE,- deprecation_reason=(- "Use the `inputType` field to determine the type of attribute's value. "- "This field will be removed after 2020-07-31."- ),- )translation = TranslationField(AttributeValueTranslation, type_name="attribute value")@@ -60,10 +38,6 @@ class AttributeValue(CountableDjangoObjectType):interfaces = [graphene.relay.Node]model = models.AttributeValue- @staticmethod- def resolve_type(root: models.AttributeValue, *_args):- return resolve_attribute_value_type(root.value)-@staticmethod@check_attribute_value_required_permissions()def resolve_input_type(root: models.AttributeValue, *_args):diff --git a/saleor/graphql/page/tests/benchmark/test_page_type.py b/saleor/graphql/page/tests/benchmark/test_page_type.pyindex 1a8719260e..801dd89f63 100644--- a/saleor/graphql/page/tests/benchmark/test_page_type.py+++ b/saleor/graphql/page/tests/benchmark/test_page_type.py@@ -29,7 +29,6 @@ def test_query_page_type(values {nameslug- type}valueRequiredvisibleInStorefront@@ -45,7 +44,6 @@ def test_query_page_type(values {nameslug- type}valueRequiredvisibleInStorefront@@ -94,7 +92,6 @@ def test_query_page_types(values {nameslug- type}valueRequiredvisibleInStorefront@@ -110,7 +107,6 @@ def test_query_page_types(values {nameslug- type}valueRequiredvisibleInStorefrontdiff --git a/saleor/graphql/product/tests/test_attributes.py b/saleor/graphql/product/tests/test_attributes.pyindex 3080009234..047f94ed46 100644--- a/saleor/graphql/product/tests/test_attributes.py+++ b/saleor/graphql/product/tests/test_attributes.py@@ -708,7 +708,6 @@ def test_retrieve_product_attributes_input_type(node {attributes {values {- typeinputType}}@@ -728,7 +727,6 @@ def test_retrieve_product_attributes_input_type(for gql_attr in found_products[0]["node"]["attributes"]:assert len(gql_attr["values"]) == 1- assert gql_attr["values"][0]["type"] == "STRING"assert gql_attr["values"][0]["inputType"] == "DROPDOWN"diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 647c7b5635..c18a3707c6 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -570,7 +570,6 @@ type AttributeValue implements Node {id: ID!name: Stringslug: String- type: AttributeValueType @deprecated(reason: "Use the `inputType` field to determine the type of attribute's value. This field will be removed after 2020-07-31.")translation(languageCode: LanguageCodeEnum!): AttributeValueTranslationinputType: AttributeInputTypeEnumreference: ID@@ -628,13 +627,6 @@ type AttributeValueTranslation implements Node {language: LanguageDisplay!}-enum AttributeValueType {- COLOR- GRADIENT- URL- STRING-}-type AttributeValueUpdate {errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")attribute: Attribute