Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Rename AtributeChoiceValue to AttributeValue
Pacu27074ca87e52e
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex a25fb7f60f..ca898d3945 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -29,7 +29,7 @@ from ...order.models import Fulfillment, Order, Paymentfrom ...order.utils import update_order_statusfrom ...page.models import Pagefrom ...product.models import (- AttributeChoiceValue, Category, Collection, Product, ProductAttribute,+ AttributeValue, Category, Collection, Product, ProductAttribute,ProductImage, ProductType, ProductVariant)from ...product.thumbnails import create_product_thumbnailsfrom ...product.utils.attributes import get_name_from_attributes@@ -343,7 +343,7 @@ def create_attribute_value(attribute, **kwargs):'name': name}defaults.update(kwargs)defaults['slug'] = slugify(defaults['name'])- attribute_value = AttributeChoiceValue.objects.get_or_create(**defaults)[0]+ attribute_value = AttributeValue.objects.get_or_create(**defaults)[0]return attribute_valuediff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 9db40de1f4..a416c2feff 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -15,7 +15,7 @@ from ...core import TaxRateTypefrom ...core.utils.taxes import DEFAULT_TAX_RATE_NAME, include_taxes_in_pricesfrom ...core.weight import WeightField, get_default_weight_unitfrom ...product.models import (- AttributeChoiceValue, Category, Collection, Product, ProductAttribute,+ AttributeValue, Category, Collection, Product, ProductAttribute,ProductImage, ProductType, ProductVariant, VariantImage)from ...product.thumbnails import create_product_thumbnailsfrom ...product.utils.attributes import get_name_from_attributes@@ -195,8 +195,8 @@ class AttributesMixin(object):if value:# if the passed attribute value is a string,# create the attribute value.- if not isinstance(value, AttributeChoiceValue):- value = AttributeChoiceValue(+ if not isinstance(value, AttributeValue):+ value = AttributeValue(attribute_id=attr.pk, name=value, slug=slugify(value))value.save()attributes[smart_text(attr.pk)] = smart_text(value.pk)@@ -430,9 +430,9 @@ class ProductAttributeForm(forms.ModelForm):'Product internal name', 'Internal name')}-class AttributeChoiceValueForm(forms.ModelForm):+class AttributeValueForm(forms.ModelForm):class Meta:- model = AttributeChoiceValue+ model = AttributeValuefields = ['attribute', 'name']widgets = {'attribute': forms.widgets.HiddenInput()}labels = {@@ -444,9 +444,9 @@ class AttributeChoiceValueForm(forms.ModelForm):return super().save(commit=commit)-class ReorderAttributeChoiceValuesForm(forms.ModelForm):+class ReorderAttributeValuesForm(forms.ModelForm):ordered_values = OrderedModelMultipleChoiceField(- queryset=AttributeChoiceValue.objects.none())+ queryset=AttributeValue.objects.none())class Meta:model = ProductAttributediff --git a/saleor/dashboard/product/urls.py b/saleor/dashboard/product/urls.pyindex cb54bf45da..f63a07c3e3 100644--- a/saleor/dashboard/product/urls.py+++ b/saleor/dashboard/product/urls.py@@ -68,14 +68,14 @@ urlpatterns = [url(r'attributes/(?P<pk>[0-9]+)/delete/$',views.attribute_delete, name='product-attribute-delete'),url(r'attributes/(?P<attribute_pk>[0-9]+)/value/add/$',- views.attribute_choice_value_create,+ views.attribute_value_create,name='product-attribute-value-add'),url(r'attributes/(?P<attribute_pk>[0-9]+)/value/(?P<value_pk>[0-9]+)/update/$', # noqa- views.attribute_choice_value_edit,+ views.attribute_value_edit,name='product-attribute-value-update'),url(r'attributes/(?P<attribute_pk>[0-9]+)/value/(?P<value_pk>[0-9]+)/delete/$', # noqa- views.attribute_choice_value_delete,+ views.attribute_value_delete,name='product-attribute-value-delete'),url(r'attributes/(?P<attribute_pk>[0-9]+)/values/reorder/$',- views.ajax_reorder_attribute_choice_values,+ views.ajax_reorder_attribute_values,name='product-attribute-values-reorder')]diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex 4f8f073934..4705edc649 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -14,7 +14,7 @@ from . import formsfrom ...core.utils import get_paginator_itemsfrom ...discount.models import Salefrom ...product.models import (- AttributeChoiceValue, Product, ProductAttribute, ProductImage, ProductType,+ AttributeValue, Product, ProductAttribute, ProductImage, ProductType,ProductVariant)from ...product.utils.availability import get_availabilityfrom ...product.utils.costs import (@@ -611,10 +611,10 @@ def attribute_delete(request, pk):@staff_member_required@permission_required('product.manage_products')-def attribute_choice_value_create(request, attribute_pk):+def attribute_value_create(request, attribute_pk):attribute = get_object_or_404(ProductAttribute, pk=attribute_pk)- value = AttributeChoiceValue(attribute_id=attribute_pk)- form = forms.AttributeChoiceValueForm(request.POST or None, instance=value)+ value = AttributeValue(attribute_id=attribute_pk)+ form = forms.AttributeValueForm(request.POST or None, instance=value)if form.is_valid():form.save()msg = pgettext_lazy(@@ -630,10 +630,10 @@ def attribute_choice_value_create(request, attribute_pk):@staff_member_required@permission_required('product.manage_products')-def attribute_choice_value_edit(request, attribute_pk, value_pk):+def attribute_value_edit(request, attribute_pk, value_pk):attribute = get_object_or_404(ProductAttribute, pk=attribute_pk)- value = get_object_or_404(AttributeChoiceValue, pk=value_pk)- form = forms.AttributeChoiceValueForm(request.POST or None, instance=value)+ value = get_object_or_404(AttributeValue, pk=value_pk)+ form = forms.AttributeValueForm(request.POST or None, instance=value)if form.is_valid():form.save()msg = pgettext_lazy(@@ -649,8 +649,8 @@ def attribute_choice_value_edit(request, attribute_pk, value_pk):@staff_member_required@permission_required('product.manage_products')-def attribute_choice_value_delete(request, attribute_pk, value_pk):- value = get_object_or_404(AttributeChoiceValue, pk=value_pk)+def attribute_value_delete(request, attribute_pk, value_pk):+ value = get_object_or_404(AttributeValue, pk=value_pk)if request.method == 'POST':value.delete()msg = pgettext_lazy(@@ -666,9 +666,9 @@ def attribute_choice_value_delete(request, attribute_pk, value_pk):@staff_member_required@permission_required('product.manage_products')-def ajax_reorder_attribute_choice_values(request, attribute_pk):+def ajax_reorder_attribute_values(request, attribute_pk):attribute = get_object_or_404(ProductAttribute, pk=attribute_pk)- form = forms.ReorderAttributeChoiceValuesForm(+ form = forms.ReorderAttributeValuesForm(request.POST, instance=attribute)status = 200ctx = {}diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.pyindex 9b809a1e85..fa01acace5 100644--- a/saleor/data_feeds/google_merchant.py+++ b/saleor/data_feeds/google_merchant.py@@ -10,7 +10,7 @@ from django.utils.encoding import smart_textfrom ..discount.models import Salefrom ..product.models import (- AttributeChoiceValue, Category, ProductAttribute, ProductVariant)+ AttributeValue, Category, ProductAttribute, ProductVariant)CATEGORY_SEPARATOR = ' > '@@ -200,7 +200,7 @@ def write_feed(file_obj):'products', 'categories')attributes_dict = {a.slug: a.pk for a in ProductAttribute.objects.all()}attribute_values_dict = {smart_text(a.pk): smart_text(a) for a- in AttributeChoiceValue.objects.all()}+ in AttributeValue.objects.all()}category_paths = {}current_site = Site.objects.get_current()for item in get_feed_items():diff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex 16a864dbfe..9b26c26ac7 100644--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@ -40,8 +40,8 @@ from .page.types import Pagefrom .page.mutations import PageCreate, PageDelete, PageUpdatefrom .product.filters import ProductFilterSetfrom .product.mutations.attributes import (- AttributeChoiceValueCreate, AttributeChoiceValueDelete,- AttributeChoiceValueUpdate, ProductAttributeCreate, ProductAttributeDelete,+ AttributeValueCreate, AttributeValueDelete,+ AttributeValueUpdate, ProductAttributeCreate, ProductAttributeDelete,ProductAttributeUpdate)from .product.mutations.products import (CategoryCreate, CategoryDelete, CategoryUpdate,@@ -278,9 +278,9 @@ class Mutations(graphene.ObjectType):set_password = SetPassword.Field()password_reset = PasswordReset.Field()- attribute_choice_value_create = AttributeChoiceValueCreate.Field()- attribute_choice_value_delete = AttributeChoiceValueDelete.Field()- attribute_choice_value_update = AttributeChoiceValueUpdate.Field()+ attribute_value_create = AttributeValueCreate.Field()+ attribute_value_delete = AttributeValueDelete.Field()+ attribute_value_update = AttributeValueUpdate.Field()category_create = CategoryCreate.Field()category_delete = CategoryDelete.Field()diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.pyindex 09217718e4..8525645686 100644--- a/saleor/graphql/product/mutations/attributes.py+++ b/saleor/graphql/product/mutations/attributes.py@@ -11,7 +11,7 @@ class ProductAttributesInput(graphene.InputObjectType):required=True, description='Name displayed in the interface.')-class AttributeChoiceValueInput(graphene.InputObjectType):+class AttributeValueInput(graphene.InputObjectType):attribute = graphene.ID(required=False,description='Attribute to which value will be assigned.',@@ -24,7 +24,7 @@ class AttributeChoiceValueInput(graphene.InputObjectType):required=True, description='Real value eg. HEX color.')-class AttributeChoiceValueUpdateInput(graphene.InputObjectType):+class AttributeValueUpdateInput(graphene.InputObjectType):slug = graphene.String(required=True, description='Internal name.')name = graphene.String(@@ -73,36 +73,36 @@ class ProductAttributeDelete(ModelDeleteMutation):return user.has_perm('product.manage_products')-class AttributeChoiceValueCreate(ModelMutation):+class AttributeValueCreate(ModelMutation):class Arguments:- input = AttributeChoiceValueInput(+ input = AttributeValueInput(required=True,description='Fields required to create an attribute choice value.')class Meta:description = 'Creates an attribute choice value.'- model = models.AttributeChoiceValue+ model = models.AttributeValue@classmethoddef user_is_allowed(cls, user, input):return user.has_perm('product.manage_products')-class AttributeChoiceValueUpdate(AttributeChoiceValueCreate):+class AttributeValueUpdate(AttributeValueCreate):class Arguments:id = graphene.ID(required=True,description='ID of an attribute choice value to update.')- input = AttributeChoiceValueUpdateInput(+ input = AttributeValueUpdateInput(required=True,description='Fields required to update an attribute choice value.')class Meta:description = 'Updates an attribute choice value.'- model = models.AttributeChoiceValue+ model = models.AttributeValue-class AttributeChoiceValueDelete(ModelDeleteMutation):+class AttributeValueDelete(ModelDeleteMutation):class Arguments:id = graphene.ID(required=True,@@ -110,7 +110,7 @@ class AttributeChoiceValueDelete(ModelDeleteMutation):class Meta:description = 'Deletes an attribute choice value.'- model = models.AttributeChoiceValue+ model = models.AttributeValue@classmethoddef user_is_allowed(cls, user, input):diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.pyindex 878105af7e..33f844aefc 100644--- a/saleor/graphql/product/types.py+++ b/saleor/graphql/product/types.py@@ -37,7 +37,7 @@ def resolve_attribute_list(attributes):att.pk: att for att in models.ProductAttribute.objects.filter(pk__in=keys)}values_map = {- val.pk: val for val in models.AttributeChoiceValue.objects.filter(+ val.pk: val for val in models.AttributeValue.objects.filter(pk__in=values)}attributes_list = [SelectedAttribute(@@ -67,7 +67,7 @@ class ProductAttributeValue(CountableDjangoObjectType):description = 'Represents a value of an attribute.'exclude_fields = ['attribute']interfaces = [relay.Node]- model = models.AttributeChoiceValue+ model = models.AttributeValuedef resolve_type(self, info):return resolve_attribute_value_type(self.value)diff --git a/saleor/graphql/product/utils.py b/saleor/graphql/product/utils.pyindex 6434486239..af3819d4b6 100644--- a/saleor/graphql/product/utils.py+++ b/saleor/graphql/product/utils.py@@ -1,7 +1,7 @@from django.utils.text import slugifyfrom ...product.models import (- AttributeChoiceValue, ProductAttribute, ProductVariant)+ AttributeValue, ProductAttribute, ProductVariant)from ...product.utils.attributes import get_name_from_attributes@@ -16,7 +16,7 @@ def attributes_to_hstore(attribute_value_input, attributes_queryset):attributes_hstore = {}values_map = dict(- AttributeChoiceValue.objects.values_list('slug', 'id'))+ AttributeValue.objects.values_list('slug', 'id'))for attribute in attribute_value_input:attr_slug = attribute.get('slug')@@ -33,7 +33,7 @@ def attributes_to_hstore(attribute_value_input, attributes_queryset):value_id = values_map.get(value)if value_id is None:- # `value_id` was not found; create a new AttributeChoiceValue+ # `value_id` was not found; create a new AttributeValue# instance from the provided `value`.attr_instance = ProductAttribute.objects.get(slug=attr_slug)obj = attr_instance.values.get_or_create(diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 9ffa771f1b..c66eea2b63 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -355,29 +355,29 @@ type AssignNavigation {menu: Menu}-type AttributeChoiceValueCreate {+type AttributeValueCreate {errors: [Error]- attributeChoiceValue: ProductAttributeValue+ attributeValue: ProductAttributeValue}-type AttributeChoiceValueDelete {+type AttributeValueDelete {errors: [Error]- attributeChoiceValue: ProductAttributeValue+ attributeValue: ProductAttributeValue}-input AttributeChoiceValueInput {+input AttributeValueInput {attribute: IDslug: String!name: String!value: String!}-type AttributeChoiceValueUpdate {+type AttributeValueUpdate {errors: [Error]- attributeChoiceValue: ProductAttributeValue+ attributeValue: ProductAttributeValue}-input AttributeChoiceValueUpdateInput {+input AttributeValueUpdateInput {slug: String!name: String!}@@ -821,9 +821,9 @@ type Mutations {tokenVerify(token: String): VerifyTokensetPassword(id: ID!, input: SetPasswordInput!): SetPasswordpasswordReset(email: String!): PasswordReset- attributeChoiceValueCreate(input: AttributeChoiceValueInput!): AttributeChoiceValueCreate- attributeChoiceValueDelete(id: ID!): AttributeChoiceValueDelete- attributeChoiceValueUpdate(id: ID!, input: AttributeChoiceValueUpdateInput!): AttributeChoiceValueUpdate+ attributeValueCreate(input: AttributeValueInput!): AttributeValueCreate+ attributeValueDelete(id: ID!): AttributeValueDelete+ attributeValueUpdate(id: ID!, input: AttributeValueUpdateInput!): AttributeValueUpdatecategoryCreate(input: CategoryInput!): CategoryCreatecategoryDelete(id: ID!): CategoryDeletecategoryUpdate(id: ID!, input: CategoryInput!): CategoryUpdatediff --git a/saleor/product/models.py b/saleor/product/models.pyindex e8031c833b..8a3011ac2b 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -355,7 +355,7 @@ class ProductAttributeTranslation(models.Model):return self.name-class AttributeChoiceValue(SortableModel):+class AttributeValue(SortableModel):name = models.CharField(max_length=100)value = models.CharField(max_length=100, default='')slug = models.SlugField(max_length=100)@@ -375,21 +375,21 @@ class AttributeChoiceValue(SortableModel):return self.attribute.values.all()-class AttributeChoiceValueTranslation(models.Model):+class AttributeValueTranslation(models.Model):language_code = models.CharField(max_length=10)- attribute_choice_value = models.ForeignKey(- AttributeChoiceValue, related_name='translations',+ attribute_value = models.ForeignKey(+ AttributeValue, related_name='translations',on_delete=models.CASCADE)name = models.CharField(max_length=100)class Meta:- unique_together = (('language_code', 'attribute_choice_value'),)+ unique_together = (('language_code', 'attribute_value'),)def __repr__(self):class_ = type(self)- return '%s(pk=%r, name=%r, attribute_choice_value_pk=%r)' % (+ return '%s(pk=%r, name=%r, attribute_value_pk=%r)' % (class_.__name__, self.pk, self.name,- self.attribute_choice_value_id)+ self.attribute_value_id)def __str__(self):return self.namediff --git a/saleor/product/utils/attributes.py b/saleor/product/utils/attributes.pyindex 287d382b52..a939e7355e 100644--- a/saleor/product/utils/attributes.py+++ b/saleor/product/utils/attributes.py@@ -1,6 +1,6 @@def get_product_attributes_data(product):"""Returns attributes associated with the product,- as dict of ProductAttribute: AttributeChoiceValue values.+ as dict of ProductAttribute: AttributeValue values."""attributes = product.product_type.product_attributes.all()attributes_map = {@@ -19,7 +19,7 @@ def get_name_from_attributes(variant, attributes):def get_attributes_display_map(obj, attributes):"""Returns attributes associated with an object,- as dict of ProductAttribute: AttributeChoiceValue values.+ as dict of ProductAttribute: AttributeValue values.Args:attributes: ProductAttribute Iterable@@ -34,14 +34,14 @@ def get_attributes_display_map(obj, attributes):def generate_name_from_values(attributes_dict):- """Generates name from AttributeChoiceValues. Attributes dict is sorted,+ """Generates name from AttributeValues. Attributes dict is sorted,as attributes order should be kept within each save.Args:- attributes_dict: dict of attribute_pk: AttributeChoiceValue values+ attributes_dict: dict of attribute_pk: AttributeValue values"""return ' / '.join(- str(attributechoice_value)- for attribute_pk, attributechoice_value in sorted(+ str(attribute_value)+ for attribute_pk, attribute_value in sorted(attributes_dict.items(),key=lambda x: x[0]))diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.pyindex 5ed96742b4..72345adb8a 100644--- a/tests/api/test_attributes.py+++ b/tests/api/test_attributes.py@@ -6,7 +6,7 @@ import pytestfrom django.shortcuts import reversefrom tests.utils import get_graphql_contentfrom saleor.product.models import (- Category, ProductAttribute, AttributeChoiceValue)+ Category, ProductAttribute, AttributeValue)from saleor.graphql.product.utils import attributes_to_hstorefrom saleor.graphql.product.types import resolve_attribute_value_type, ProductAttributeValueType@@ -26,7 +26,7 @@ def test_attributes_to_hstore(product, color_attribute):input_data = [{'slug': color_attribute.slug, 'value': 'Space Grey'}]ids = attributes_to_hstore(input_data, attrs_qs)- new_value = AttributeChoiceValue.objects.get(slug='space-grey')+ new_value = AttributeValue.objects.get(slug='space-grey')assert str(color_attribute.pk) in idsassert ids[str(color_attribute.pk)] == str(new_value.pk)@@ -164,13 +164,13 @@ def test_delete_product_attribute(admin_api_client, color_attribute):attribute.refresh_from_db()-def test_create_attribute_choice_value(admin_api_client, color_attribute):+def test_create_attribute_value(admin_api_client, color_attribute):attribute = color_attributequery = """mutation createChoice($attribute: ID!, $name: String!, $slug: String!, $value: String!) {- attributeChoiceValueCreate(+ attributeValueCreate(input: {attribute: $attribute, name: $name, slug: $slug, value: $value}) {- attributeChoiceValue {+ attributeValue {nameslugtype@@ -190,20 +190,20 @@ def test_create_attribute_choice_value(admin_api_client, color_attribute):content = get_graphql_content(response)assert 'errors' not in contentdata = content[- 'data']['attributeChoiceValueCreate']['attributeChoiceValue']+ 'data']['attributeValueCreate']['attributeValue']assert data['name'] == nameassert data['slug'] == slugassert data['value'] == valueassert data['type'] == 'STRING'-def test_update_attribute_choice_value(admin_api_client, pink_choice_value):- value = pink_choice_value+def test_update_attribute_value(admin_api_client, pink_attribute_value):+ value = pink_attribute_valuequery = """mutation updateChoice($id: ID!, $name: String!, $slug: String!) {- attributeChoiceValueUpdate(+ attributeValueUpdate(id: $id, input: {name: $name, slug: $slug}) {- attributeChoiceValue {+ attributeValue {nameslug}@@ -221,17 +221,18 @@ def test_update_attribute_choice_value(admin_api_client, pink_choice_value):assert 'errors' not in contentvalue.refresh_from_db()data = content[- 'data']['attributeChoiceValueUpdate']['attributeChoiceValue']+ 'data']['attributeValueUpdate']['attributeValue']assert data['name'] == name == value.name-def test_delete_attribute_choice_value(admin_api_client, color_attribute, pink_choice_value):- value = pink_choice_value+def test_delete_attribute_value(+ admin_api_client, color_attribute, pink_attribute_value):+ value = pink_attribute_valuevalue = color_attribute.values.get(name='Red')query = """mutation updateChoice($id: ID!) {- attributeChoiceValueDelete(id: $id) {- attributeChoiceValue {+ attributeValueDelete(id: $id) {+ attributeValue {nameslug}@@ -247,6 +248,7 @@ def test_delete_attribute_choice_value(admin_api_client, color_attribute, pink_cwith pytest.raises(value._meta.model.DoesNotExist):value.refresh_from_db()+@pytest.mark.parametrize('raw_value, expected_type', [('#0000', ProductAttributeValueType.COLOR),('#FF69B4', ProductAttributeValueType.COLOR),@@ -267,7 +269,7 @@ def test_resolve_attribute_value_type(raw_value, expected_type):def test_query_attribute_values(- color_attribute, pink_choice_value, user_api_client):+ color_attribute, pink_attribute_value, user_api_client):attribute_id = graphene.Node.to_global_id('ProductAttribute', color_attribute.id)query = """@@ -294,7 +296,7 @@ def test_query_attribute_values(assert 'errors' not in contentdata = content['data']['attributes']['edges'][0]['node']values = data['values']- pink = [v for v in values if v['name'] == pink_choice_value.name]+ pink = [v for v in values if v['name'] == pink_attribute_value.name]assert len(pink) == 1pink = pink[0]assert pink['value'] == '#FF69B4'diff --git a/tests/conftest.py b/tests/conftest.pyindex 7878125471..1df031f2e2 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -31,7 +31,7 @@ from saleor.order.models import Orderfrom saleor.order.utils import recalculate_orderfrom saleor.page.models import Pagefrom saleor.product.models import (- AttributeChoiceValue, Category, Collection, Product, ProductAttribute,+ AttributeValue, Category, Collection, Product, ProductAttribute,ProductAttributeTranslation, ProductImage, ProductTranslation, ProductType,ProductVariant)from saleor.shipping.models import (@@ -245,16 +245,16 @@ def shipping_method(shipping_zone):def color_attribute(db): # pylint: disable=W0613attribute = ProductAttribute.objects.create(slug='color', name='Color')- AttributeChoiceValue.objects.create(+ AttributeValue.objects.create(attribute=attribute, name='Red', slug='red')- AttributeChoiceValue.objects.create(+ AttributeValue.objects.create(attribute=attribute, name='Blue', slug='blue')return attribute@pytest.fixture-def pink_choice_value(color_attribute): # pylint: disable=W0613- value = AttributeChoiceValue.objects.create(+def pink_attribute_value(color_attribute): # pylint: disable=W0613+ value = AttributeValue.objects.create(slug='pink', name='Pink', attribute=color_attribute, value='#FF69B4')return value@@ -262,9 +262,9 @@ def pink_choice_value(color_attribute): # pylint: disable=W0613@pytest.fixturedef size_attribute(db): # pylint: disable=W0613attribute = ProductAttribute.objects.create(slug='size', name='Size')- AttributeChoiceValue.objects.create(+ AttributeValue.objects.create(attribute=attribute, name='Small', slug='small')- AttributeChoiceValue.objects.create(+ AttributeValue.objects.create(attribute=attribute, name='Big', slug='big')return attributediff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex 9bbb314455..e0bce8f65d 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -12,7 +12,7 @@ from saleor.dashboard.product import ProductBulkActionfrom saleor.dashboard.product.forms import ProductForm, ProductVariantFormfrom saleor.product.forms import VariantChoiceFieldfrom saleor.product.models import (- AttributeChoiceValue, Collection, Product, ProductAttribute, ProductImage,+ AttributeValue, Collection, Product, ProductAttribute, ProductImage,ProductType, ProductVariant)from ..utils import create_image@@ -858,8 +858,8 @@ def test_view_attribute_not_deleted_before_confirmation(assert ProductAttribute.objects.filter(pk=color_attribute.pk)-def test_view_attribute_choice_value_create(color_attribute, admin_client):- values = AttributeChoiceValue.objects.filter(attribute=color_attribute.pk)+def test_view_attribute_value_create(color_attribute, admin_client):+ values = AttributeValue.objects.filter(attribute=color_attribute.pk)assert values.count() == 2url = reverse('dashboard:product-attribute-value-add',@@ -869,13 +869,13 @@ def test_view_attribute_choice_value_create(color_attribute, admin_client):response = admin_client.post(url, data, follow=True)assert response.status_code == 200- values = AttributeChoiceValue.objects.filter(attribute=color_attribute.pk)+ values = AttributeValue.objects.filter(attribute=color_attribute.pk)assert values.count() == 3-def test_view_attribute_choice_value_create_invalid(+def test_view_attribute_value_create_invalid(color_attribute, admin_client):- values = AttributeChoiceValue.objects.filter(attribute=color_attribute.pk)+ values = AttributeValue.objects.filter(attribute=color_attribute.pk)assert values.count() == 2url = reverse('dashboard:product-attribute-value-add',@@ -885,12 +885,12 @@ def test_view_attribute_choice_value_create_invalid(response = admin_client.post(url, data, follow=True)assert response.status_code == 200- values = AttributeChoiceValue.objects.filter(attribute=color_attribute.pk)+ values = AttributeValue.objects.filter(attribute=color_attribute.pk)assert values.count() == 2-def test_view_attribute_choice_value_edit(color_attribute, admin_client):- values = AttributeChoiceValue.objects.filter(attribute=color_attribute.pk)+def test_view_attribute_value_edit(color_attribute, admin_client):+ values = AttributeValue.objects.filter(attribute=color_attribute.pk)assert values.count() == 2url = reverse('dashboard:product-attribute-value-update',@@ -900,14 +900,14 @@ def test_view_attribute_choice_value_edit(color_attribute, admin_client):response = admin_client.post(url, data, follow=True)assert response.status_code == 200- values = AttributeChoiceValue.objects.filter(+ values = AttributeValue.objects.filter(attribute=color_attribute.pk, name='Pink')assert len(values) == 1assert values[0].name == 'Pink'-def test_view_attribute_choice_value_delete(color_attribute, admin_client):- values = AttributeChoiceValue.objects.filter(attribute=color_attribute.pk)+def test_view_attribute_value_delete(color_attribute, admin_client):+ values = AttributeValue.objects.filter(attribute=color_attribute.pk)assert values.count() == 2deleted_value = values[0]url = reverse(@@ -918,12 +918,12 @@ def test_view_attribute_choice_value_delete(color_attribute, admin_client):response = admin_client.post(url, follow=True)assert response.status_code == 200- values = AttributeChoiceValue.objects.filter(attribute=color_attribute.pk)+ values = AttributeValue.objects.filter(attribute=color_attribute.pk)assert len(values) == 1assert deleted_value not in values-def test_view_ajax_reorder_attribute_choice_values(+def test_view_ajax_reorder_attribute_values(admin_client, color_attribute):order_before = [val.pk for val in color_attribute.values.all()]ordered_values = list(reversed(order_before))@@ -938,7 +938,7 @@ def test_view_ajax_reorder_attribute_choice_values(assert order_after == ordered_values-def test_view_ajax_reorder_attribute_choice_values_invalid(+def test_view_ajax_reorder_attribute_values_invalid(admin_client, color_attribute):order_before = [val.pk for val in color_attribute.values.all()]ordered_values = list(reversed(order_before)).append(3)@@ -1009,7 +1009,7 @@ def test_product_form_change_attributes(db, product, color_attribute):assert product.attributes[str(color_attribute.pk)] == str(color_value.pk)# Check that new attribute was created for author- author_value = AttributeChoiceValue.objects.get(name=new_author)+ author_value = AttributeValue.objects.get(name=new_author)assert product.attributes[str(text_attribute.pk)] == str(author_value.pk)diff --git a/tests/test_data_feeds.py b/tests/test_data_feeds.pyindex d1a99d965f..64eb9b346d 100644--- a/tests/test_data_feeds.py+++ b/tests/test_data_feeds.py@@ -6,7 +6,7 @@ from django.utils.encoding import smart_textfrom saleor.data_feeds.google_merchant import (get_feed_items, item_attributes, item_google_product_category, write_feed)-from saleor.product.models import AttributeChoiceValue, Category+from saleor.product.models import AttributeValue, Categorydef test_saleor_feed_items(product, site_settings):@@ -19,7 +19,7 @@ def test_saleor_feed_items(product, site_settings):attributes_dict = {}current_site = site_settings.siteattribute_values_dict = {smart_text(a.pk): smart_text(a) for a- in AttributeChoiceValue.objects.all()}+ in AttributeValue.objects.all()}attributes = item_attributes(items[0], categories, category_paths,current_site, discounts, attributes_dict,attribute_values_dict)diff --git a/tests/test_product_attributes.py b/tests/test_product_attributes.pyindex 216bab1722..6be76e340b 100644--- a/tests/test_product_attributes.py+++ b/tests/test_product_attributes.py@@ -1,7 +1,7 @@import pytestfrom saleor.product.models import (- AttributeChoiceValue, Product, ProductAttribute)+ AttributeValue, Product, ProductAttribute)from saleor.product.utils.attributes import (generate_name_from_values, get_attributes_display_map,get_name_from_attributes)@@ -53,11 +53,11 @@ def test_get_name_from_attributes_no_attributes(product_with_no_attributes):def test_generate_name_from_values():attribute = ProductAttribute.objects.create(slug='color', name='Color')- red = AttributeChoiceValue.objects.create(+ red = AttributeValue.objects.create(attribute=attribute, name='Red', slug='red')- blue = AttributeChoiceValue.objects.create(+ blue = AttributeValue.objects.create(attribute=attribute, name='Blue', slug='blue')- yellow = AttributeChoiceValue.objects.create(+ yellow = AttributeValue.objects.create(attribute=attribute, name='Yellow', slug='yellow')values = {'3': red, '2': blue, '1': yellow}name = generate_name_from_values(values)diff --git a/tests/test_translation.py b/tests/test_translation.pyindex 9b9b0d0e7e..8bb95a1221 100644--- a/tests/test_translation.py+++ b/tests/test_translation.py@@ -1,7 +1,7 @@import pytestfrom saleor.product.models import (- AttributeChoiceValueTranslation, CategoryTranslation,+ AttributeValueTranslation, CategoryTranslation,CollectionTranslation, ProductAttributeTranslation, ProductTranslation,ProductVariantTranslation)from saleor.shipping.models import ShippingMethodTranslation@@ -15,10 +15,10 @@ def product_translation_pl(product):@pytest.fixture-def attribute_choice_translation_fr(translated_product_attribute):+def attribute_value_translation_fr(translated_product_attribute):value = translated_product_attribute.product_attribute.values.first()- return AttributeChoiceValueTranslation.objects.create(- language_code='fr', attribute_choice_value=value,+ return AttributeValueTranslation.objects.create(+ language_code='fr', attribute_value=value,name='French name')@@ -107,8 +107,8 @@ def test_product_attribute_translation(settings, color_attribute):assert color_attribute.translated.name == 'French name'-def test_attribute_choice_value_translation(- settings, product, attribute_choice_translation_fr):+def test_attribute_value_translation(+ settings, product, attribute_value_translation_fr):attribute = product.product_type.product_attributes.first().values.first()assert not attribute.translated.name == 'French name'settings.LANGUAGE_CODE = 'fr'