Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix reference attribute fixtures
IKarbowiak22115fcfce39
diff --git a/saleor/csv/tests/export/products_data/test_get_products_data.py b/saleor/csv/tests/export/products_data/test_get_products_data.pyindex 5dbc1bae1a..6617574a43 100644--- a/saleor/csv/tests/export/products_data/test_get_products_data.py+++ b/saleor/csv/tests/export/products_data/test_get_products_data.py@@ -227,16 +227,16 @@ def test_get_products_data_for_specified_warehouses_channels_and_attributes(product_with_image,product_with_variant_with_two_attributes,file_attribute,- page_reference_attribute,+ product_type_page_reference_attribute,page_list,):# givenproduct.variants.add(variant_with_many_stocks)product.product_type.variant_attributes.add(- file_attribute, page_reference_attribute+ file_attribute, product_type_page_reference_attribute)product.product_type.product_attributes.add(- file_attribute, page_reference_attribute+ file_attribute, product_type_page_reference_attribute)associate_attribute_values_to_instance(variant_with_many_stocks, file_attribute, file_attribute.values.first()@@ -245,20 +245,22 @@ def test_get_products_data_for_specified_warehouses_channels_and_attributes(product, file_attribute, file_attribute.values.first())product_ref_value = AttributeValue.objects.create(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_{page_list[0].pk}",name=page_list[0].title,)variant_ref_value = AttributeValue.objects.create(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant_with_many_stocks.pk}_{page_list[1].pk}",name=page_list[1].title,)associate_attribute_values_to_instance(- variant_with_many_stocks, page_reference_attribute, variant_ref_value+ variant_with_many_stocks,+ product_type_page_reference_attribute,+ variant_ref_value,)associate_attribute_values_to_instance(- product, page_reference_attribute, product_ref_value+ product, product_type_page_reference_attribute, product_ref_value)products = Product.objects.all()diff --git a/saleor/csv/tests/export/products_data/test_handle_relations_data.py b/saleor/csv/tests/export/products_data/test_handle_relations_data.pyindex dbf5401696..872a0d7a6a 100644--- a/saleor/csv/tests/export/products_data/test_handle_relations_data.py+++ b/saleor/csv/tests/export/products_data/test_handle_relations_data.py@@ -77,23 +77,25 @@ def test_get_products_relations_data_attribute_ids(prepare_products_data_mocked,product_list,file_attribute,- page_reference_attribute,+ product_type_page_reference_attribute,page,):# givenproduct = product_list[0]product.product_type.product_attributes.add(- file_attribute, page_reference_attribute+ file_attribute, product_type_page_reference_attribute)associate_attribute_values_to_instance(product, file_attribute, file_attribute.values.first())ref_value = AttributeValue.objects.create(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_{page.pk}",name=page.title,)- associate_attribute_values_to_instance(product, page_reference_attribute, ref_value)+ associate_attribute_values_to_instance(+ product, product_type_page_reference_attribute, ref_value+ )qs = Product.objects.all()export_fields = {"name", "description"}@@ -140,25 +142,25 @@ def test_prepare_products_relations_data(channel_USD,channel_PLN,file_attribute,- page_reference_attribute,+ product_type_page_reference_attribute,page,):# givenpk = product_with_image.pkproduct_with_image.product_type.product_attributes.add(- file_attribute, page_reference_attribute+ file_attribute, product_type_page_reference_attribute)associate_attribute_values_to_instance(product_with_image, file_attribute, file_attribute.values.first())ref_value = AttributeValue.objects.create(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product_with_image.pk}_{page.pk}",name=page.title,)associate_attribute_values_to_instance(- product_with_image, page_reference_attribute, ref_value+ product_with_image, product_type_page_reference_attribute, ref_value)collection_list[0].products.add(product_with_image)@@ -333,24 +335,26 @@ def test_get_variants_relations_data_attribute_ids(prepare_variants_data_mocked,product_list,file_attribute,- page_reference_attribute,+ product_type_page_reference_attribute,page,):# givenproduct = product_list[0]product.product_type.variant_attributes.add(- file_attribute, page_reference_attribute+ file_attribute, product_type_page_reference_attribute)variant = product.variants.first()associate_attribute_values_to_instance(variant, file_attribute, file_attribute.values.first())ref_value = AttributeValue.objects.create(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_{page.pk}",name=page.title,)- associate_attribute_values_to_instance(variant, page_reference_attribute, ref_value)+ associate_attribute_values_to_instance(+ variant, product_type_page_reference_attribute, ref_value+ )qs = Product.objects.all()export_fields = {"name", "variants__sku"}@@ -454,24 +458,26 @@ def test_prepare_variants_relations_data(channel_PLN,channel_USD,file_attribute,- page_reference_attribute,+ product_type_page_reference_attribute,page,):# givenproduct = product_with_variant_with_two_attributesproduct.product_type.variant_attributes.add(- file_attribute, page_reference_attribute+ file_attribute, product_type_page_reference_attribute)variant = product.variants.first()associate_attribute_values_to_instance(variant, file_attribute, file_attribute.values.first())ref_value = AttributeValue.objects.create(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_{page.pk}",name=page.title,)- associate_attribute_values_to_instance(variant, page_reference_attribute, ref_value)+ associate_attribute_values_to_instance(+ variant, product_type_page_reference_attribute, ref_value+ )qs = Product.objects.all()variant = product_with_variant_with_two_attributes.variants.first()diff --git a/saleor/graphql/attribute/tests/queries/test_attribute_query.py b/saleor/graphql/attribute/tests/queries/test_attribute_query.pyindex c17e867f9d..dabdf1e54f 100644--- a/saleor/graphql/attribute/tests/queries/test_attribute_query.py+++ b/saleor/graphql/attribute/tests/queries/test_attribute_query.py@@ -251,11 +251,11 @@ def test_get_single_product_attribute_with_file_value(def test_get_single_reference_attribute_by_staff(- staff_api_client, page_reference_attribute, permission_manage_products+ staff_api_client, product_type_page_reference_attribute, permission_manage_products):staff_api_client.user.user_permissions.add(permission_manage_products)attribute_gql_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.id+ "Attribute", product_type_page_reference_attribute.id)query = QUERY_ATTRIBUTEcontent = get_graphql_content(@@ -264,34 +264,37 @@ def test_get_single_reference_attribute_by_staff(assert content["data"]["attribute"], "Should have found an attribute"assert content["data"]["attribute"]["id"] == attribute_gql_id- assert content["data"]["attribute"]["slug"] == page_reference_attribute.slug+ assert (+ content["data"]["attribute"]["slug"]+ == product_type_page_reference_attribute.slug+ )assert (content["data"]["attribute"]["valueRequired"]- == page_reference_attribute.value_required+ == product_type_page_reference_attribute.value_required)assert (content["data"]["attribute"]["visibleInStorefront"]- == page_reference_attribute.visible_in_storefront+ == product_type_page_reference_attribute.visible_in_storefront)assert (content["data"]["attribute"]["filterableInStorefront"]- == page_reference_attribute.filterable_in_storefront+ == product_type_page_reference_attribute.filterable_in_storefront)assert (content["data"]["attribute"]["filterableInDashboard"]- == page_reference_attribute.filterable_in_dashboard+ == product_type_page_reference_attribute.filterable_in_dashboard)assert (content["data"]["attribute"]["availableInGrid"]- == page_reference_attribute.available_in_grid+ == product_type_page_reference_attribute.available_in_grid)assert (content["data"]["attribute"]["storefrontSearchPosition"]- == page_reference_attribute.storefront_search_position+ == product_type_page_reference_attribute.storefront_search_position)assert (content["data"]["attribute"]["entityType"]- == page_reference_attribute.entity_type.upper()+ == product_type_page_reference_attribute.entity_type.upper())diff --git a/saleor/graphql/page/tests/test_page.py b/saleor/graphql/page/tests/test_page.pyindex 486510df28..af1ef20fe6 100644--- a/saleor/graphql/page/tests/test_page.py+++ b/saleor/graphql/page/tests/test_page.py@@ -593,7 +593,11 @@ def test_create_page_with_file_attribute_required_no_file_url_given(def test_create_page_with_page_reference_attribute(- staff_api_client, permission_manage_pages, page_type, page_reference_attribute, page+ staff_api_client,+ permission_manage_pages,+ page_type,+ page_type_page_reference_attribute,+ page,):# givenpage_slug = "test-slug"@@ -607,12 +611,12 @@ def test_create_page_with_page_reference_attribute(page_type_id = graphene.Node.to_global_id("PageType", page_type.pk)ref_attribute_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.pk+ "Attribute", page_type_page_reference_attribute.pk)- page_type.page_attributes.add(page_reference_attribute)+ page_type.page_attributes.add(page_type_page_reference_attribute)reference = graphene.Node.to_global_id("Page", page.pk)- values_count = page_reference_attribute.values.count()+ values_count = page_type_page_reference_attribute.values.count()# test creating root pagevariables = {@@ -646,7 +650,7 @@ def test_create_page_with_page_reference_attribute(page_id = data["page"]["id"]_, new_page_pk = graphene.Node.from_global_id(page_id)expected_attr_data = {- "attribute": {"slug": page_reference_attribute.slug},+ "attribute": {"slug": page_type_page_reference_attribute.slug},"values": [{"slug": f"{new_page_pk}_{page.pk}",@@ -658,12 +662,15 @@ def test_create_page_with_page_reference_attribute(}assert data["page"]["attributes"][0] == expected_attr_data- page_reference_attribute.refresh_from_db()- assert page_reference_attribute.values.count() == values_count + 1+ page_type_page_reference_attribute.refresh_from_db()+ assert page_type_page_reference_attribute.values.count() == values_count + 1def test_create_page_with_page_reference_attribute_not_required_no_references_given(- staff_api_client, permission_manage_pages, page_type, page_reference_attribute+ staff_api_client,+ permission_manage_pages,+ page_type,+ page_type_page_reference_attribute,):# givenpage_slug = "test-slug"@@ -677,12 +684,12 @@ def test_create_page_with_page_reference_attribute_not_required_no_references_gipage_type_id = graphene.Node.to_global_id("PageType", page_type.pk)file_attribute_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.pk+ "Attribute", page_type_page_reference_attribute.pk)- page_type.page_attributes.add(page_reference_attribute)+ page_type.page_attributes.add(page_type_page_reference_attribute)- page_reference_attribute.value_required = False- page_reference_attribute.save(update_fields=["value_required"])+ page_type_page_reference_attribute.value_required = False+ page_type_page_reference_attribute.save(update_fields=["value_required"])# test creating root pagevariables = {@@ -714,7 +721,10 @@ def test_create_page_with_page_reference_attribute_not_required_no_references_gidef test_create_page_with_page_reference_attribute_required_no_references_given(- staff_api_client, permission_manage_pages, page_type, page_reference_attribute+ staff_api_client,+ permission_manage_pages,+ page_type,+ page_type_page_reference_attribute,):# givenpage_slug = "test-slug"@@ -728,12 +738,12 @@ def test_create_page_with_page_reference_attribute_required_no_references_given(page_type_id = graphene.Node.to_global_id("PageType", page_type.pk)file_attribute_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.pk+ "Attribute", page_type_page_reference_attribute.pk)- page_type.page_attributes.add(page_reference_attribute)+ page_type.page_attributes.add(page_type_page_reference_attribute)- page_reference_attribute.value_required = True- page_reference_attribute.save(update_fields=["value_required"])+ page_type_page_reference_attribute.value_required = True+ page_type_page_reference_attribute.save(update_fields=["value_required"])# test creating root pagevariables = {@@ -765,7 +775,7 @@ def test_create_page_with_product_reference_attribute(staff_api_client,permission_manage_pages,page_type,- product_reference_attribute,+ page_type_product_reference_attribute,product,):# given@@ -780,12 +790,12 @@ def test_create_page_with_product_reference_attribute(page_type_id = graphene.Node.to_global_id("PageType", page_type.pk)ref_attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", page_type_product_reference_attribute.pk)- page_type.page_attributes.add(product_reference_attribute)+ page_type.page_attributes.add(page_type_product_reference_attribute)reference = graphene.Node.to_global_id("Product", product.pk)- values_count = product_reference_attribute.values.count()+ values_count = page_type_product_reference_attribute.values.count()# test creating root pagevariables = {@@ -819,7 +829,7 @@ def test_create_page_with_product_reference_attribute(page_id = data["page"]["id"]_, new_page_pk = graphene.Node.from_global_id(page_id)expected_attr_data = {- "attribute": {"slug": product_reference_attribute.slug},+ "attribute": {"slug": page_type_product_reference_attribute.slug},"values": [{"slug": f"{new_page_pk}_{product.pk}",@@ -831,12 +841,15 @@ def test_create_page_with_product_reference_attribute(}assert data["page"]["attributes"][0] == expected_attr_data- product_reference_attribute.refresh_from_db()- assert product_reference_attribute.values.count() == values_count + 1+ page_type_product_reference_attribute.refresh_from_db()+ assert page_type_product_reference_attribute.values.count() == values_count + 1def test_create_page_with_product_reference_attribute_not_required_no_references_given(- staff_api_client, permission_manage_pages, page_type, product_reference_attribute+ staff_api_client,+ permission_manage_pages,+ page_type,+ page_type_product_reference_attribute,):# givenpage_slug = "test-slug"@@ -850,12 +863,12 @@ def test_create_page_with_product_reference_attribute_not_required_no_referencespage_type_id = graphene.Node.to_global_id("PageType", page_type.pk)file_attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", page_type_product_reference_attribute.pk)- page_type.page_attributes.add(product_reference_attribute)+ page_type.page_attributes.add(page_type_product_reference_attribute)- product_reference_attribute.value_required = False- product_reference_attribute.save(update_fields=["value_required"])+ page_type_product_reference_attribute.value_required = False+ page_type_product_reference_attribute.save(update_fields=["value_required"])# test creating root pagevariables = {@@ -887,7 +900,10 @@ def test_create_page_with_product_reference_attribute_not_required_no_referencesdef test_create_page_with_product_reference_attribute_required_no_references_given(- staff_api_client, permission_manage_pages, page_type, product_reference_attribute+ staff_api_client,+ permission_manage_pages,+ page_type,+ page_type_product_reference_attribute,):# givenpage_slug = "test-slug"@@ -901,12 +917,12 @@ def test_create_page_with_product_reference_attribute_required_no_references_givpage_type_id = graphene.Node.to_global_id("PageType", page_type.pk)file_attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", page_type_product_reference_attribute.pk)- page_type.page_attributes.add(product_reference_attribute)+ page_type.page_attributes.add(page_type_product_reference_attribute)- product_reference_attribute.value_required = True- product_reference_attribute.save(update_fields=["value_required"])+ page_type_product_reference_attribute.value_required = True+ page_type_product_reference_attribute.save(update_fields=["value_required"])# test creating root pagevariables = {@@ -1169,7 +1185,10 @@ def test_update_page_with_file_attribute_new_value_is_not_created(def test_update_page_with_page_reference_attribute_new_value(- staff_api_client, permission_manage_pages, page_list, page_reference_attribute+ staff_api_client,+ permission_manage_pages,+ page_list,+ page_type_page_reference_attribute,):# givenquery = UPDATE_PAGE_MUTATION@@ -1177,11 +1196,11 @@ def test_update_page_with_page_reference_attribute_new_value(page = page_list[0]ref_page = page_list[1]page_type = page.page_type- page_type.page_attributes.add(page_reference_attribute)+ page_type.page_attributes.add(page_type_page_reference_attribute)- values_count = page_reference_attribute.values.count()+ values_count = page_type_page_reference_attribute.values.count()ref_attribute_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.pk+ "Attribute", page_type_page_reference_attribute.pk)reference = graphene.Node.to_global_id("Page", ref_page.pk)@@ -1204,7 +1223,7 @@ def test_update_page_with_page_reference_attribute_new_value(assert not data["pageErrors"]assert data["page"]updated_attribute = {- "attribute": {"slug": page_reference_attribute.slug},+ "attribute": {"slug": page_type_page_reference_attribute.slug},"values": [{"slug": f"{page.pk}_{ref_page.pk}",@@ -1216,12 +1235,15 @@ def test_update_page_with_page_reference_attribute_new_value(}assert updated_attribute in data["page"]["attributes"]- page_reference_attribute.refresh_from_db()- assert page_reference_attribute.values.count() == values_count + 1+ page_type_page_reference_attribute.refresh_from_db()+ assert page_type_page_reference_attribute.values.count() == values_count + 1def test_update_page_with_page_reference_attribute_existing_value(- staff_api_client, permission_manage_pages, page_list, page_reference_attribute+ staff_api_client,+ permission_manage_pages,+ page_list,+ page_type_page_reference_attribute,):# givenquery = UPDATE_PAGE_MUTATION@@ -1229,18 +1251,20 @@ def test_update_page_with_page_reference_attribute_existing_value(page = page_list[0]ref_page = page_list[1]page_type = page.page_type- page_type.page_attributes.add(page_reference_attribute)+ page_type.page_attributes.add(page_type_page_reference_attribute)attr_value = AttributeValue.objects.create(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,name=page.title,slug=f"{page.pk}_{ref_page.pk}",)- associate_attribute_values_to_instance(page, page_reference_attribute, attr_value)+ associate_attribute_values_to_instance(+ page, page_type_page_reference_attribute, attr_value+ )- values_count = page_reference_attribute.values.count()+ values_count = page_type_page_reference_attribute.values.count()ref_attribute_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.pk+ "Attribute", page_type_page_reference_attribute.pk)reference = graphene.Node.to_global_id("Page", ref_page.pk)@@ -1263,7 +1287,7 @@ def test_update_page_with_page_reference_attribute_existing_value(assert not data["pageErrors"]assert data["page"]updated_attribute = {- "attribute": {"slug": page_reference_attribute.slug},+ "attribute": {"slug": page_type_page_reference_attribute.slug},"values": [{"slug": attr_value.slug,@@ -1275,26 +1299,26 @@ def test_update_page_with_page_reference_attribute_existing_value(}assert updated_attribute in data["page"]["attributes"]- page_reference_attribute.refresh_from_db()- assert page_reference_attribute.values.count() == values_count+ page_type_page_reference_attribute.refresh_from_db()+ assert page_type_page_reference_attribute.values.count() == values_countdef test_update_page_with_product_reference_attribute_new_value(staff_api_client,permission_manage_pages,page,- product_reference_attribute,+ page_type_product_reference_attribute,product,):# givenquery = UPDATE_PAGE_MUTATIONpage_type = page.page_type- page_type.page_attributes.add(product_reference_attribute)+ page_type.page_attributes.add(page_type_product_reference_attribute)- values_count = product_reference_attribute.values.count()+ values_count = page_type_product_reference_attribute.values.count()ref_attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", page_type_product_reference_attribute.pk)reference = graphene.Node.to_global_id("Product", product.pk)@@ -1317,7 +1341,7 @@ def test_update_page_with_product_reference_attribute_new_value(assert not data["pageErrors"]assert data["page"]updated_attribute = {- "attribute": {"slug": product_reference_attribute.slug},+ "attribute": {"slug": page_type_product_reference_attribute.slug},"values": [{"slug": f"{page.pk}_{product.pk}",@@ -1329,35 +1353,35 @@ def test_update_page_with_product_reference_attribute_new_value(}assert updated_attribute in data["page"]["attributes"]- product_reference_attribute.refresh_from_db()- assert product_reference_attribute.values.count() == values_count + 1+ page_type_product_reference_attribute.refresh_from_db()+ assert page_type_product_reference_attribute.values.count() == values_count + 1def test_update_page_with_product_reference_attribute_existing_value(staff_api_client,permission_manage_pages,page,- product_reference_attribute,+ page_type_product_reference_attribute,product,):# givenquery = UPDATE_PAGE_MUTATIONpage_type = page.page_type- page_type.page_attributes.add(product_reference_attribute)+ page_type.page_attributes.add(page_type_product_reference_attribute)attr_value = AttributeValue.objects.create(- attribute=product_reference_attribute,+ attribute=page_type_product_reference_attribute,name=page.title,slug=f"{page.pk}_{product.pk}",)associate_attribute_values_to_instance(- page, product_reference_attribute, attr_value+ page, page_type_product_reference_attribute, attr_value)- values_count = product_reference_attribute.values.count()+ values_count = page_type_product_reference_attribute.values.count()ref_attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", page_type_product_reference_attribute.pk)reference = graphene.Node.to_global_id("Product", product.pk)@@ -1380,7 +1404,7 @@ def test_update_page_with_product_reference_attribute_existing_value(assert not data["pageErrors"]assert data["page"]updated_attribute = {- "attribute": {"slug": product_reference_attribute.slug},+ "attribute": {"slug": page_type_product_reference_attribute.slug},"values": [{"slug": attr_value.slug,@@ -1392,8 +1416,8 @@ def test_update_page_with_product_reference_attribute_existing_value(}assert updated_attribute in data["page"]["attributes"]- product_reference_attribute.refresh_from_db()- assert product_reference_attribute.values.count() == values_count+ page_type_product_reference_attribute.refresh_from_db()+ assert page_type_product_reference_attribute.values.count() == values_count@freeze_time("2020-03-18 12:00:00")diff --git a/saleor/graphql/page/tests/test_page_reorder_attribute_values.py b/saleor/graphql/page/tests/test_page_reorder_attribute_values.pyindex 1ff69d595e..730e108013 100644--- a/saleor/graphql/page/tests/test_page_reorder_attribute_values.py+++ b/saleor/graphql/page/tests/test_page_reorder_attribute_values.py@@ -45,36 +45,40 @@ def test_sort_page_attribute_values(staff_api_client,permission_manage_pages,page,- page_reference_attribute,+ page_type_page_reference_attribute,):staff_api_client.user.user_permissions.add(permission_manage_pages)page_type = page.page_typepage_type.page_attributes.clear()- page_type.page_attributes.add(page_reference_attribute)+ page_type.page_attributes.add(page_type_page_reference_attribute)page_id = graphene.Node.to_global_id("Page", page.id)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.id)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", page_type_page_reference_attribute.id+ )attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,slug=f"{page.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,slug=f"{page.pk}_2",name="test name 2",),AttributeValue(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,slug=f"{page.pk}_3",name="test name 3",),])- associate_attribute_values_to_instance(page, page_reference_attribute, *attr_values)+ associate_attribute_values_to_instance(+ page, page_type_page_reference_attribute, *attr_values+ )variables = {"pageId": page_id,@@ -113,31 +117,33 @@ def test_sort_page_attribute_values_invalid_attribute_id(staff_api_client,permission_manage_pages,page,- page_reference_attribute,+ page_type_page_reference_attribute,color_attribute,):staff_api_client.user.user_permissions.add(permission_manage_pages)page_type = page.page_typepage_type.page_attributes.clear()- page_type.page_attributes.add(page_reference_attribute)+ page_type.page_attributes.add(page_type_page_reference_attribute)page_id = graphene.Node.to_global_id("Page", page.id)attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,slug=f"{page.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,slug=f"{page.pk}_2",name="test name 2",),])- associate_attribute_values_to_instance(page, page_reference_attribute, *attr_values)+ associate_attribute_values_to_instance(+ page, page_type_page_reference_attribute, *attr_values+ )variables = {"pageId": page_id,@@ -164,37 +170,41 @@ def test_sort_page_attribute_values_invalid_value_id(staff_api_client,permission_manage_pages,page,- page_reference_attribute,+ page_type_page_reference_attribute,size_page_attribute,):staff_api_client.user.user_permissions.add(permission_manage_pages)page_type = page.page_typepage_type.page_attributes.clear()- page_type.page_attributes.add(page_reference_attribute)+ page_type.page_attributes.add(page_type_page_reference_attribute)page_id = graphene.Node.to_global_id("Page", page.id)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.id)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", page_type_page_reference_attribute.id+ )attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,slug=f"{page.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,slug=f"{page.pk}_2",name="test name 2",),AttributeValue(- attribute=page_reference_attribute,+ attribute=page_type_page_reference_attribute,slug=f"{page.pk}_3",name="test name 3",),])- associate_attribute_values_to_instance(page, page_reference_attribute, *attr_values)+ associate_attribute_values_to_instance(+ page, page_type_page_reference_attribute, *attr_values+ )invalid_value_id = graphene.Node.to_global_id("AttributeValue", size_page_attribute.values.first().pkdiff --git a/saleor/graphql/product/tests/test_attributes.py b/saleor/graphql/product/tests/test_attributes.pyindex 3080009234..8357bcd470 100644--- a/saleor/graphql/product/tests/test_attributes.py+++ b/saleor/graphql/product/tests/test_attributes.py@@ -938,37 +938,39 @@ def test_sort_product_attribute_values(staff_api_client,permission_manage_products,product,- page_reference_attribute,+ product_type_page_reference_attribute,):staff_api_client.user.user_permissions.add(permission_manage_products)product_type = product.product_typeproduct_type.product_attributes.clear()- product_type.product_attributes.add(page_reference_attribute)+ product_type.product_attributes.add(product_type_page_reference_attribute)product_id = graphene.Node.to_global_id("Product", product.id)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.id)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.id+ )attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_2",name="test name 2",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_3",name="test name 3",),])associate_attribute_values_to_instance(- product, page_reference_attribute, *attr_values+ product, product_type_page_reference_attribute, *attr_values)variables = {@@ -1010,32 +1012,32 @@ def test_sort_product_attribute_values_invalid_attribute_id(staff_api_client,permission_manage_products,product,- page_reference_attribute,+ product_type_page_reference_attribute,color_attribute,):staff_api_client.user.user_permissions.add(permission_manage_products)product_type = product.product_typeproduct_type.product_attributes.clear()- product_type.product_attributes.add(page_reference_attribute)+ product_type.product_attributes.add(product_type_page_reference_attribute)product_id = graphene.Node.to_global_id("Product", product.id)attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_2",name="test name 2",),])associate_attribute_values_to_instance(- product, page_reference_attribute, *attr_values+ product, product_type_page_reference_attribute, *attr_values)variables = {@@ -1065,38 +1067,40 @@ def test_sort_product_attribute_values_invalid_value_id(staff_api_client,permission_manage_products,product,- page_reference_attribute,+ product_type_page_reference_attribute,size_page_attribute,):staff_api_client.user.user_permissions.add(permission_manage_products)product_type = product.product_typeproduct_type.product_attributes.clear()- product_type.product_attributes.add(page_reference_attribute)+ product_type.product_attributes.add(product_type_page_reference_attribute)product_id = graphene.Node.to_global_id("Product", product.id)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.id)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.id+ )attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_2",name="test name 2",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{product.pk}_3",name="test name 3",),])associate_attribute_values_to_instance(- product, page_reference_attribute, *attr_values+ product, product_type_page_reference_attribute, *attr_values)invalid_value_id = graphene.Node.to_global_id(@@ -1168,38 +1172,40 @@ def test_sort_product_variant_attribute_values(staff_api_client,permission_manage_products,product,- page_reference_attribute,+ product_type_page_reference_attribute,):staff_api_client.user.user_permissions.add(permission_manage_products)variant = product.variants.first()product_type = product.product_typeproduct_type.variant_attributes.clear()- product_type.variant_attributes.add(page_reference_attribute)+ product_type.variant_attributes.add(product_type_page_reference_attribute)variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.id)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.id+ )attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_2",name="test name 2",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_3",name="test name 3",),])associate_attribute_values_to_instance(- variant, page_reference_attribute, *attr_values+ variant, product_type_page_reference_attribute, *attr_values)variables = {@@ -1243,7 +1249,7 @@ def test_sort_product_variant_attribute_values_invalid_attribute_id(staff_api_client,permission_manage_products,product,- page_reference_attribute,+ product_type_page_reference_attribute,color_attribute,):staff_api_client.user.user_permissions.add(permission_manage_products)@@ -1251,25 +1257,25 @@ def test_sort_product_variant_attribute_values_invalid_attribute_id(variant = product.variants.first()product_type = product.product_typeproduct_type.variant_attributes.clear()- product_type.variant_attributes.add(page_reference_attribute)+ product_type.variant_attributes.add(product_type_page_reference_attribute)variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_2",name="test name 2",),])associate_attribute_values_to_instance(- variant, page_reference_attribute, *attr_values+ variant, product_type_page_reference_attribute, *attr_values)variables = {@@ -1299,7 +1305,7 @@ def test_sort_product_variant_attribute_values_invalid_value_id(staff_api_client,permission_manage_products,product,- page_reference_attribute,+ product_type_page_reference_attribute,size_page_attribute,):staff_api_client.user.user_permissions.add(permission_manage_products)@@ -1307,31 +1313,33 @@ def test_sort_product_variant_attribute_values_invalid_value_id(variant = product.variants.first()product_type = product.product_typeproduct_type.variant_attributes.clear()- product_type.variant_attributes.add(page_reference_attribute)+ product_type.variant_attributes.add(product_type_page_reference_attribute)variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.id)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.id+ )attr_values = AttributeValue.objects.bulk_create([AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_1",name="test name 1",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_2",name="test name 2",),AttributeValue(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,slug=f"{variant.pk}_3",name="test name 3",),])associate_attribute_values_to_instance(- variant, page_reference_attribute, *attr_values+ variant, product_type_page_reference_attribute, *attr_values)invalid_value_id = graphene.Node.to_global_id(diff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.pyindex c8e8f9a6e2..6f0fbd5087 100644--- a/saleor/graphql/product/tests/test_product.py+++ b/saleor/graphql/product/tests/test_product.py@@ -2353,13 +2353,13 @@ def test_create_product_with_page_reference_attribute(product_type,category,color_attribute,- page_reference_attribute,+ product_type_page_reference_attribute,permission_manage_products,page,):query = CREATE_PRODUCT_MUTATION- values_count = page_reference_attribute.values.count()+ values_count = product_type_page_reference_attribute.values.count()product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)category_id = graphene.Node.to_global_id("Category", category.pk)@@ -2367,9 +2367,9 @@ def test_create_product_with_page_reference_attribute(product_slug = "product-test-slug"# Add second attribute- product_type.product_attributes.add(page_reference_attribute)+ product_type.product_attributes.add(product_type_page_reference_attribute)reference_attr_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.id+ "Attribute", product_type_page_reference_attribute.id)reference = graphene.Node.to_global_id("Page", page.pk)@@ -2398,7 +2398,7 @@ def test_create_product_with_page_reference_attribute(expected_attributes_data = [{"attribute": {"slug": color_attribute.slug}, "values": []},{- "attribute": {"slug": page_reference_attribute.slug},+ "attribute": {"slug": product_type_page_reference_attribute.slug},"values": [{"slug": f"{product_id}_{page.id}",@@ -2412,8 +2412,8 @@ def test_create_product_with_page_reference_attribute(for attr_data in data["product"]["attributes"]:assert attr_data in expected_attributes_data- page_reference_attribute.refresh_from_db()- assert page_reference_attribute.values.count() == values_count + 1+ product_type_page_reference_attribute.refresh_from_db()+ assert product_type_page_reference_attribute.values.count() == values_count + 1def test_create_product_with_product_reference_attribute(@@ -2421,13 +2421,13 @@ def test_create_product_with_product_reference_attribute(product_type,category,color_attribute,- product_reference_attribute,+ product_type_product_reference_attribute,permission_manage_products,product,):query = CREATE_PRODUCT_MUTATION- values_count = product_reference_attribute.values.count()+ values_count = product_type_product_reference_attribute.values.count()product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)category_id = graphene.Node.to_global_id("Category", category.pk)@@ -2435,9 +2435,9 @@ def test_create_product_with_product_reference_attribute(product_slug = "product-test-slug"# Add second attribute- product_type.product_attributes.add(product_reference_attribute)+ product_type.product_attributes.add(product_type_product_reference_attribute)reference_attr_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.id+ "Attribute", product_type_product_reference_attribute.id)reference = graphene.Node.to_global_id("Product", product.pk)@@ -2466,7 +2466,7 @@ def test_create_product_with_product_reference_attribute(expected_attributes_data = [{"attribute": {"slug": color_attribute.slug}, "values": []},{- "attribute": {"slug": product_reference_attribute.slug},+ "attribute": {"slug": product_type_product_reference_attribute.slug},"values": [{"slug": f"{product_id}_{product.id}",@@ -2480,8 +2480,8 @@ def test_create_product_with_product_reference_attribute(for attr_data in data["product"]["attributes"]:assert attr_data in expected_attributes_data- product_reference_attribute.refresh_from_db()- assert product_reference_attribute.values.count() == values_count + 1+ product_type_product_reference_attribute.refresh_from_db()+ assert product_type_product_reference_attribute.values.count() == values_count + 1def test_create_product_with_file_attribute_new_attribute_value(@@ -2657,13 +2657,13 @@ def test_create_product_with_page_reference_attribute_required_no_references(staff_api_client,product_type,category,- page_reference_attribute,+ product_type_page_reference_attribute,permission_manage_products,):query = CREATE_PRODUCT_MUTATION- page_reference_attribute.value_required = True- page_reference_attribute.save(update_fields=["value_required"])+ product_type_page_reference_attribute.value_required = True+ product_type_page_reference_attribute.save(update_fields=["value_required"])product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)category_id = graphene.Node.to_global_id("Category", category.pk)@@ -2671,9 +2671,9 @@ def test_create_product_with_page_reference_attribute_required_no_references(product_slug = "product-test-slug"# Add second attribute- product_type.product_attributes.add(page_reference_attribute)+ product_type.product_attributes.add(product_type_page_reference_attribute)reference_attr_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.id+ "Attribute", product_type_page_reference_attribute.id)# test creating root product@@ -2698,7 +2698,9 @@ def test_create_product_with_page_reference_attribute_required_no_references(assert errors[0]["code"] == ProductErrorCode.REQUIRED.nameassert errors[0]["field"] == "attributes"assert errors[0]["attributes"] == [- graphene.Node.to_global_id("Attribute", page_reference_attribute.pk)+ graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.pk+ )]@@ -2706,13 +2708,13 @@ def test_create_product_with_product_reference_attribute_required_no_references(staff_api_client,product_type,category,- product_reference_attribute,+ product_type_product_reference_attribute,permission_manage_products,):query = CREATE_PRODUCT_MUTATION- product_reference_attribute.value_required = True- product_reference_attribute.save(update_fields=["value_required"])+ product_type_product_reference_attribute.value_required = True+ product_type_product_reference_attribute.save(update_fields=["value_required"])product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)category_id = graphene.Node.to_global_id("Category", category.pk)@@ -2720,9 +2722,9 @@ def test_create_product_with_product_reference_attribute_required_no_references(product_slug = "product-test-slug"# Add second attribute- product_type.product_attributes.add(product_reference_attribute)+ product_type.product_attributes.add(product_type_product_reference_attribute)reference_attr_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.id+ "Attribute", product_type_product_reference_attribute.id)# test creating root product@@ -2747,7 +2749,9 @@ def test_create_product_with_product_reference_attribute_required_no_references(assert errors[0]["code"] == ProductErrorCode.REQUIRED.nameassert errors[0]["field"] == "attributes"assert errors[0]["attributes"] == [- graphene.Node.to_global_id("Attribute", product_reference_attribute.pk)+ graphene.Node.to_global_id(+ "Attribute", product_type_product_reference_attribute.pk+ )]@@ -3644,7 +3648,7 @@ def test_update_product_rating(def test_update_product_with_page_reference_attribute_value(updated_webhook_mock,staff_api_client,- page_reference_attribute,+ product_type_page_reference_attribute,product,product_type,page,@@ -3655,10 +3659,12 @@ def test_update_product_with_page_reference_attribute_value(product_id = graphene.Node.to_global_id("Product", product.pk)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.pk)- product_type.product_attributes.add(page_reference_attribute)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.pk+ )+ product_type.product_attributes.add(product_type_page_reference_attribute)- values_count = page_reference_attribute.values.count()+ values_count = product_type_page_reference_attribute.values.count()reference = graphene.Node.to_global_id("Page", page.pk)@@ -3681,7 +3687,10 @@ def test_update_product_with_page_reference_attribute_value(assert len(attributes) == 2expected_file_att_data = {- "attribute": {"id": attribute_id, "name": page_reference_attribute.name},+ "attribute": {+ "id": attribute_id,+ "name": product_type_page_reference_attribute.name,+ },"values": [{"name": page.title,@@ -3695,15 +3704,15 @@ def test_update_product_with_page_reference_attribute_value(updated_webhook_mock.assert_called_once_with(product)- page_reference_attribute.refresh_from_db()- assert page_reference_attribute.values.count() == values_count + 1+ product_type_page_reference_attribute.refresh_from_db()+ assert product_type_page_reference_attribute.values.count() == values_count + 1@patch("saleor.plugins.manager.PluginsManager.product_updated")def test_update_product_with_page_reference_attribute_existing_value(updated_webhook_mock,staff_api_client,- page_reference_attribute,+ product_type_page_reference_attribute,product,product_type,page,@@ -3714,18 +3723,20 @@ def test_update_product_with_page_reference_attribute_existing_value(product_id = graphene.Node.to_global_id("Product", product.pk)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.pk)- product_type.product_attributes.add(page_reference_attribute)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.pk+ )+ product_type.product_attributes.add(product_type_page_reference_attribute)attr_value = AttributeValue.objects.create(- attribute=page_reference_attribute,+ attribute=product_type_page_reference_attribute,name=page.title,slug=f"{product.pk}_{page.pk}",)associate_attribute_values_to_instance(- product, page_reference_attribute, attr_value+ product, product_type_page_reference_attribute, attr_value)- values_count = page_reference_attribute.values.count()+ values_count = product_type_page_reference_attribute.values.count()reference = graphene.Node.to_global_id("Page", page.pk)@@ -3748,7 +3759,10 @@ def test_update_product_with_page_reference_attribute_existing_value(assert len(attributes) == 2expected_file_att_data = {- "attribute": {"id": attribute_id, "name": page_reference_attribute.name},+ "attribute": {+ "id": attribute_id,+ "name": product_type_page_reference_attribute.name,+ },"values": [{"name": page.title,@@ -3762,15 +3776,15 @@ def test_update_product_with_page_reference_attribute_existing_value(updated_webhook_mock.assert_called_once_with(product)- page_reference_attribute.refresh_from_db()- assert page_reference_attribute.values.count() == values_count+ product_type_page_reference_attribute.refresh_from_db()+ assert product_type_page_reference_attribute.values.count() == values_count@patch("saleor.plugins.manager.PluginsManager.product_updated")def test_update_product_with_page_reference_attribute_value_not_given(updated_webhook_mock,staff_api_client,- page_reference_attribute,+ product_type_page_reference_attribute,product,product_type,permission_manage_products,@@ -3778,13 +3792,15 @@ def test_update_product_with_page_reference_attribute_value_not_given(# givenquery = MUTATION_UPDATE_PRODUCT- page_reference_attribute.value_required = True- page_reference_attribute.save(update_fields=["value_required"])+ product_type_page_reference_attribute.value_required = True+ product_type_page_reference_attribute.save(update_fields=["value_required"])product_id = graphene.Node.to_global_id("Product", product.pk)- attribute_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.pk)- product_type.product_attributes.add(page_reference_attribute)+ attribute_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.pk+ )+ product_type.product_attributes.add(product_type_page_reference_attribute)variables = {"productId": product_id,@@ -3813,7 +3829,7 @@ def test_update_product_with_page_reference_attribute_value_not_given(def test_update_product_with_product_reference_attribute_value(updated_webhook_mock,staff_api_client,- product_reference_attribute,+ product_type_product_reference_attribute,product_list,product_type,permission_manage_products,@@ -3826,11 +3842,11 @@ def test_update_product_with_product_reference_attribute_value(product_ref = product_list[1]attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", product_type_product_reference_attribute.pk)- product_type.product_attributes.add(product_reference_attribute)+ product_type.product_attributes.add(product_type_product_reference_attribute)- values_count = product_reference_attribute.values.count()+ values_count = product_type_product_reference_attribute.values.count()reference = graphene.Node.to_global_id("Product", product_ref.pk)@@ -3853,7 +3869,10 @@ def test_update_product_with_product_reference_attribute_value(assert len(attributes) == 2expected_file_att_data = {- "attribute": {"id": attribute_id, "name": product_reference_attribute.name},+ "attribute": {+ "id": attribute_id,+ "name": product_type_product_reference_attribute.name,+ },"values": [{"name": product_ref.name,@@ -3867,15 +3886,15 @@ def test_update_product_with_product_reference_attribute_value(updated_webhook_mock.assert_called_once_with(product)- product_reference_attribute.refresh_from_db()- assert product_reference_attribute.values.count() == values_count + 1+ product_type_product_reference_attribute.refresh_from_db()+ assert product_type_product_reference_attribute.values.count() == values_count + 1@patch("saleor.plugins.manager.PluginsManager.product_updated")def test_update_product_with_product_reference_attribute_existing_value(updated_webhook_mock,staff_api_client,- product_reference_attribute,+ product_type_product_reference_attribute,product_list,product_type,permission_manage_products,@@ -3888,19 +3907,19 @@ def test_update_product_with_product_reference_attribute_existing_value(product_ref = product_list[1]attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", product_type_product_reference_attribute.pk)- product_type.product_attributes.add(product_reference_attribute)+ product_type.product_attributes.add(product_type_product_reference_attribute)attr_value = AttributeValue.objects.create(- attribute=product_reference_attribute,+ attribute=product_type_product_reference_attribute,name=product_ref.name,slug=f"{product.pk}_{product_ref.pk}",)associate_attribute_values_to_instance(- product, product_reference_attribute, attr_value+ product, product_type_product_reference_attribute, attr_value)- values_count = product_reference_attribute.values.count()+ values_count = product_type_product_reference_attribute.values.count()reference = graphene.Node.to_global_id("Product", product_ref.pk)@@ -3923,7 +3942,10 @@ def test_update_product_with_product_reference_attribute_existing_value(assert len(attributes) == 2expected_file_att_data = {- "attribute": {"id": attribute_id, "name": product_reference_attribute.name},+ "attribute": {+ "id": attribute_id,+ "name": product_type_product_reference_attribute.name,+ },"values": [{"name": product_ref.name,@@ -3937,15 +3959,15 @@ def test_update_product_with_product_reference_attribute_existing_value(updated_webhook_mock.assert_called_once_with(product)- product_reference_attribute.refresh_from_db()- assert product_reference_attribute.values.count() == values_count+ product_type_product_reference_attribute.refresh_from_db()+ assert product_type_product_reference_attribute.values.count() == values_count@patch("saleor.plugins.manager.PluginsManager.product_updated")def test_update_product_with_product_reference_attribute_value_not_given(updated_webhook_mock,staff_api_client,- product_reference_attribute,+ product_type_product_reference_attribute,product,product_type,permission_manage_products,@@ -3953,15 +3975,15 @@ def test_update_product_with_product_reference_attribute_value_not_given(# givenquery = MUTATION_UPDATE_PRODUCT- product_reference_attribute.value_required = True- product_reference_attribute.save(update_fields=["value_required"])+ product_type_product_reference_attribute.value_required = True+ product_type_product_reference_attribute.save(update_fields=["value_required"])product_id = graphene.Node.to_global_id("Product", product.pk)attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", product_type_product_reference_attribute.pk)- product_type.product_attributes.add(product_reference_attribute)+ product_type.product_attributes.add(product_type_product_reference_attribute)variables = {"productId": product_id,@@ -4644,7 +4666,7 @@ def test_product_type_query_only_variant_selections_value_set(product_type,file_attribute_with_file_input_type_without_values,author_page_attribute,- page_reference_attribute,+ product_type_page_reference_attribute,product,permission_manage_products,monkeypatch,@@ -4665,7 +4687,7 @@ def test_product_type_query_only_variant_selections_value_set(product_type.variant_attributes.add(file_attribute_with_file_input_type_without_values,author_page_attribute,- page_reference_attribute,+ product_type_page_reference_attribute,)variables = {diff --git a/saleor/graphql/product/tests/test_variant.py b/saleor/graphql/product/tests/test_variant.pyindex 2dfdf76fc2..d74d593aa9 100644--- a/saleor/graphql/product/tests/test_variant.py+++ b/saleor/graphql/product/tests/test_variant.py@@ -557,7 +557,7 @@ def test_create_variant_with_page_reference_attribute(staff_api_client,product,product_type,- page_reference_attribute,+ product_type_page_reference_attribute,page_list,permission_manage_products,warehouse,@@ -567,13 +567,15 @@ def test_create_variant_with_page_reference_attribute(sku = "1"product_type.variant_attributes.clear()- product_type.variant_attributes.add(page_reference_attribute)- ref_attr_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.id)+ product_type.variant_attributes.add(product_type_page_reference_attribute)+ ref_attr_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.id+ )page_ref_1 = graphene.Node.to_global_id("Page", page_list[0].pk)page_ref_2 = graphene.Node.to_global_id("Page", page_list[1].pk)- values_count = page_reference_attribute.values.count()+ values_count = product_type_page_reference_attribute.values.count()stocks = [{@@ -598,7 +600,10 @@ def test_create_variant_with_page_reference_attribute(assert data["sku"] == skuvariant_id = data["id"]_, variant_pk = graphene.Node.from_global_id(variant_id)- assert data["attributes"][0]["attribute"]["slug"] == page_reference_attribute.slug+ assert (+ data["attributes"][0]["attribute"]["slug"]+ == product_type_page_reference_attribute.slug+ )expected_values = [{"slug": f"{variant_pk}_{page_list[0].pk}",@@ -619,8 +624,8 @@ def test_create_variant_with_page_reference_attribute(assert data["stocks"][0]["quantity"] == stocks[0]["quantity"]assert data["stocks"][0]["warehouse"]["slug"] == warehouse.slug- page_reference_attribute.refresh_from_db()- assert page_reference_attribute.values.count() == values_count + 2+ product_type_page_reference_attribute.refresh_from_db()+ assert product_type_page_reference_attribute.values.count() == values_count + 2updated_webhook_mock.assert_called_once_with(product)@@ -631,7 +636,7 @@ def test_create_variant_with_page_reference_attribute_no_references_given(staff_api_client,product,product_type,- page_reference_attribute,+ product_type_page_reference_attribute,permission_manage_products,warehouse,):@@ -640,10 +645,12 @@ def test_create_variant_with_page_reference_attribute_no_references_given(sku = "1"product_type.variant_attributes.clear()- product_type.variant_attributes.add(page_reference_attribute)- ref_attr_id = graphene.Node.to_global_id("Attribute", page_reference_attribute.id)+ product_type.variant_attributes.add(product_type_page_reference_attribute)+ ref_attr_id = graphene.Node.to_global_id(+ "Attribute", product_type_page_reference_attribute.id+ )- values_count = page_reference_attribute.values.count()+ values_count = product_type_page_reference_attribute.values.count()stocks = [{@@ -671,8 +678,8 @@ def test_create_variant_with_page_reference_attribute_no_references_given(assert errors[0]["field"] == "attributes"assert errors[0]["attributes"] == [ref_attr_id]- page_reference_attribute.refresh_from_db()- assert page_reference_attribute.values.count() == values_count+ product_type_page_reference_attribute.refresh_from_db()+ assert product_type_page_reference_attribute.values.count() == values_countupdated_webhook_mock.assert_not_called()@@ -683,7 +690,7 @@ def test_create_variant_with_product_reference_attribute(staff_api_client,product,product_type,- product_reference_attribute,+ product_type_product_reference_attribute,product_list,permission_manage_products,warehouse,@@ -693,15 +700,15 @@ def test_create_variant_with_product_reference_attribute(sku = "1"product_type.variant_attributes.clear()- product_type.variant_attributes.add(product_reference_attribute)+ product_type.variant_attributes.add(product_type_product_reference_attribute)ref_attr_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.id+ "Attribute", product_type_product_reference_attribute.id)product_ref_1 = graphene.Node.to_global_id("Product", product_list[0].pk)product_ref_2 = graphene.Node.to_global_id("Product", product_list[1].pk)- values_count = product_reference_attribute.values.count()+ values_count = product_type_product_reference_attribute.values.count()stocks = [{@@ -729,7 +736,8 @@ def test_create_variant_with_product_reference_attribute(variant_id = data["id"]_, variant_pk = graphene.Node.from_global_id(variant_id)assert (- data["attributes"][0]["attribute"]["slug"] == product_reference_attribute.slug+ data["attributes"][0]["attribute"]["slug"]+ == product_type_product_reference_attribute.slug)expected_values = [{@@ -751,8 +759,8 @@ def test_create_variant_with_product_reference_attribute(assert data["stocks"][0]["quantity"] == stocks[0]["quantity"]assert data["stocks"][0]["warehouse"]["slug"] == warehouse.slug- product_reference_attribute.refresh_from_db()- assert product_reference_attribute.values.count() == values_count + 2+ product_type_product_reference_attribute.refresh_from_db()+ assert product_type_product_reference_attribute.values.count() == values_count + 2updated_webhook_mock.assert_called_once_with(product)@@ -763,7 +771,7 @@ def test_create_variant_with_product_reference_attribute_no_references_given(staff_api_client,product,product_type,- product_reference_attribute,+ product_type_product_reference_attribute,permission_manage_products,warehouse,):@@ -772,12 +780,12 @@ def test_create_variant_with_product_reference_attribute_no_references_given(sku = "1"product_type.variant_attributes.clear()- product_type.variant_attributes.add(product_reference_attribute)+ product_type.variant_attributes.add(product_type_product_reference_attribute)ref_attr_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.id+ "Attribute", product_type_product_reference_attribute.id)- values_count = product_reference_attribute.values.count()+ values_count = product_type_product_reference_attribute.values.count()stocks = [{@@ -805,8 +813,8 @@ def test_create_variant_with_product_reference_attribute_no_references_given(assert errors[0]["field"] == "attributes"assert errors[0]["attributes"] == [ref_attr_id]- product_reference_attribute.refresh_from_db()- assert product_reference_attribute.values.count() == values_count+ product_type_product_reference_attribute.refresh_from_db()+ assert product_type_product_reference_attribute.values.count() == values_countupdated_webhook_mock.assert_not_called()@@ -1541,7 +1549,7 @@ def test_update_product_variant_with_page_reference_attribute(staff_api_client,product,page,- page_reference_attribute,+ product_type_page_reference_attribute,permission_manage_products,):variant = product.variants.first()@@ -1550,11 +1558,11 @@ def test_update_product_variant_with_page_reference_attribute(product_type = product.product_typeproduct_type.variant_attributes.clear()- product_type.variant_attributes.add(page_reference_attribute)+ product_type.variant_attributes.add(product_type_page_reference_attribute)variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)ref_attribute_id = graphene.Node.to_global_id(- "Attribute", page_reference_attribute.pk+ "Attribute", product_type_page_reference_attribute.pk)reference = graphene.Node.to_global_id("Page", page.pk)@@ -1579,7 +1587,7 @@ def test_update_product_variant_with_page_reference_attribute(assert len(variant_data["attributes"]) == 1assert (variant_data["attributes"][0]["attribute"]["slug"]- == page_reference_attribute.slug+ == product_type_page_reference_attribute.slug)assert len(variant_data["attributes"][0]["values"]) == 1assert (@@ -1591,7 +1599,7 @@ def test_update_product_variant_with_page_reference_attribute(def test_update_product_variant_with_product_reference_attribute(staff_api_client,product_list,- product_reference_attribute,+ product_type_product_reference_attribute,permission_manage_products,):product = product_list[0]@@ -1603,11 +1611,11 @@ def test_update_product_variant_with_product_reference_attribute(product_type = product.product_typeproduct_type.variant_attributes.clear()- product_type.variant_attributes.add(product_reference_attribute)+ product_type.variant_attributes.add(product_type_product_reference_attribute)variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)ref_attribute_id = graphene.Node.to_global_id(- "Attribute", product_reference_attribute.pk+ "Attribute", product_type_product_reference_attribute.pk)reference = graphene.Node.to_global_id("Product", product_ref.pk)@@ -1632,7 +1640,7 @@ def test_update_product_variant_with_product_reference_attribute(assert len(variant_data["attributes"]) == 1assert (variant_data["attributes"][0]["attribute"]["slug"]- == product_reference_attribute.slug+ == product_type_product_reference_attribute.slug)assert len(variant_data["attributes"][0]["values"]) == 1assert (diff --git a/saleor/product/tests/test_get_variant_selection_attributes.py b/saleor/product/tests/test_get_variant_selection_attributes.pyindex 7563c24e90..5d40728eff 100644--- a/saleor/product/tests/test_get_variant_selection_attributes.py+++ b/saleor/product/tests/test_get_variant_selection_attributes.py@@ -5,8 +5,8 @@ from ..utils.variants import get_variant_selection_attributesdef test_get_variant_selection_attributes(product_type_attribute_list,file_attribute_with_file_input_type_without_values,- page_reference_attribute,- product_reference_attribute,+ product_type_page_reference_attribute,+ product_type_product_reference_attribute,):# givenmultiselect_attr = product_type_attribute_list[0]@@ -15,8 +15,8 @@ def test_get_variant_selection_attributes(attrs = product_type_attribute_list + [file_attribute_with_file_input_type_without_values,- page_reference_attribute,- product_reference_attribute,+ product_type_page_reference_attribute,+ product_type_product_reference_attribute,]# whendiff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.pyindex b87186f75f..c64c79db8f 100644--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@ -835,7 +835,7 @@ def file_attribute_with_file_input_type_without_values(db):@pytest.fixture-def page_reference_attribute(db):+def product_type_page_reference_attribute(db):return Attribute.objects.create(slug="page-reference",name="Page reference",@@ -846,7 +846,18 @@ def page_reference_attribute(db):@pytest.fixture-def product_reference_attribute(db):+def page_type_page_reference_attribute(db):+ return Attribute.objects.create(+ slug="page-reference",+ name="Page reference",+ type=AttributeType.PAGE_TYPE,+ input_type=AttributeInputType.REFERENCE,+ entity_type=AttributeEntityType.PAGE,+ )+++def product_type_product_reference_attribute(db):return Attribute.objects.create(slug="product-reference",name="Product reference",@@ -856,6 +867,17 @@ def product_reference_attribute(db):)+def page_type_product_reference_attribute(db):+ return Attribute.objects.create(+ slug="product-reference",+ name="Product reference",+ type=AttributeType.PAGE_TYPE,+ input_type=AttributeInputType.REFERENCE,+ entity_type=AttributeEntityType.PRODUCT,+ )++@pytest.fixturedef size_page_attribute(db):attribute = Attribute.objects.create(