Skip to content

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

Rename ProductAttribtue to Attribute in tests

Pacu2a10ac4d7b1ac
diff --git a/tests/api/test_product.py b/tests/api/test_product.py
index 6fa6714af7..300b100812 100644
--- a/tests/api/test_product.py
+++ b/tests/api/test_product.py
@@ -690,6 +690,7 @@ def test_product_type_create_mutation(admin_api_client, product_type):
new_instance = ProductType.objects.latest('pk')
assert new_instance.tax_rate == 'standard'
+
def test_product_type_update_mutation(admin_api_client, product_type):
query = """
mutation updateProductType(
diff --git a/tests/conftest.py b/tests/conftest.py
index 7f83973a65..6b24e4083d 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -709,7 +709,7 @@ def vatlayer(db, settings, tax_rates, taxes):
def translated_variant_fr(product):
attribute = product.product_type.variant_attributes.first()
return AttributeTranslation.objects.create(
- language_code='fr', product_attribute=attribute,
+ language_code='fr', attribute=attribute,
name='Name tranlsated to french')
@@ -717,7 +717,7 @@ def translated_variant_fr(product):
def translated_attribute(product):
attribute = product.product_type.product_attributes.first()
return AttributeTranslation.objects.create(
- language_code='fr', product_attribute=attribute,
+ language_code='fr', attribute=attribute,
name='Name tranlsated to french')
diff --git a/tests/dashboard/test_permissions.py b/tests/dashboard/test_permissions.py
index d03526340a..68e182a4f1 100644
--- a/tests/dashboard/test_permissions.py
+++ b/tests/dashboard/test_permissions.py
@@ -634,20 +634,20 @@ def test_staff_can_access_product_image_delete(
def test_staff_with_permissions_can_view_products_attributes_list(
staff_client, staff_user, permission_manage_products, color_attribute):
assert not staff_user.has_perm('product.manage_products')
- response = staff_client.get(reverse('dashboard:product-attributes'))
+ response = staff_client.get(reverse('dashboard:attributes'))
assert response.status_code == 302
response = staff_client.get(
reverse(
- 'dashboard:product-attribute-details', args=[color_attribute.pk]))
+ 'dashboard:attribute-details', args=[color_attribute.pk]))
assert response.status_code == 302
staff_user.user_permissions.add(permission_manage_products)
staff_user = User.objects.get(pk=staff_user.pk)
assert staff_user.has_perm('product.manage_products')
- response = staff_client.get(reverse('dashboard:product-attributes'))
+ response = staff_client.get(reverse('dashboard:attributes'))
assert response.status_code == 200
response = staff_client.get(
reverse(
- 'dashboard:product-attribute-details', args=[color_attribute.pk]))
+ 'dashboard:attribute-details', args=[color_attribute.pk]))
assert response.status_code == 200
@@ -656,26 +656,26 @@ def test_staff_with_permissions_can_update_add_and_delete_products_attributes(
assert not staff_user.has_perm('product.manage_products')
response = staff_client.get(
reverse(
- 'dashboard:product-attribute-update', args=[color_attribute.pk]))
+ 'dashboard:attribute-update', args=[color_attribute.pk]))
assert response.status_code == 302
response = staff_client.get(
reverse(
- 'dashboard:product-attribute-delete', args=[color_attribute.pk]))
+ 'dashboard:attribute-delete', args=[color_attribute.pk]))
assert response.status_code == 302
- response = staff_client.get(reverse('dashboard:product-attribute-add'))
+ response = staff_client.get(reverse('dashboard:attribute-add'))
assert response.status_code == 302
staff_user.user_permissions.add(permission_manage_products)
staff_user = User.objects.get(pk=staff_user.pk)
assert staff_user.has_perm('product.manage_products')
response = staff_client.get(
reverse(
- 'dashboard:product-attribute-update', args=[color_attribute.pk]))
+ 'dashboard:attribute-update', args=[color_attribute.pk]))
assert response.status_code == 200
response = staff_client.get(
reverse(
- 'dashboard:product-attribute-delete', args=[color_attribute.pk]))
+ 'dashboard:attribute-delete', args=[color_attribute.pk]))
assert response.status_code == 200
- response = staff_client.get(reverse('dashboard:product-attribute-add'))
+ response = staff_client.get(reverse('dashboard:attribute-add'))
assert response.status_code == 200
@@ -683,7 +683,7 @@ def test_staff_can_access_attribute_create(
staff_client, staff_user, permission_manage_products, color_attribute):
assert not staff_user.has_perm('product.manage_products')
url = reverse(
- 'dashboard:product-attribute-value-add',
+ 'dashboard:attribute-value-add',
kwargs={'attribute_pk': color_attribute.pk})
response = staff_client.get(url)
@@ -702,7 +702,7 @@ def test_staff_can_access_attribute_edit(
value = color_attribute.values.first()
assert not staff_user.has_perm('product.manage_products')
url = reverse(
- 'dashboard:product-attribute-value-update',
+ 'dashboard:attribute-value-update',
kwargs={
'attribute_pk': color_attribute.pk,
'value_pk': value.pk})
@@ -723,7 +723,7 @@ def test_staff_can_access_attribute_delete(
value = color_attribute.values.first()
assert not staff_user.has_perm('product.manage_products')
url = reverse(
- 'dashboard:product-attribute-value-delete',
+ 'dashboard:attribute-value-delete',
kwargs={
'attribute_pk': color_attribute.pk,
'value_pk': value.pk})
diff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.py
index 7e106fc793..1771050084 100644
--- a/tests/dashboard/test_product.py
+++ b/tests/dashboard/test_product.py
@@ -765,7 +765,7 @@ def test_view_ajax_upload_image(monkeypatch, admin_client, product_with_image):
def test_view_attribute_list(db, admin_client, color_attribute):
- url = reverse('dashboard:product-attributes')
+ url = reverse('dashboard:attributes')
response = admin_client.get(url)
@@ -780,7 +780,7 @@ def test_view_attribute_list(db, admin_client, color_attribute):
def test_view_attribute_details(admin_client, color_attribute):
url = reverse(
- 'dashboard:product-attribute-details',
+ 'dashboard:attribute-details',
kwargs={'pk': color_attribute.pk})
response = admin_client.get(url)
@@ -792,7 +792,7 @@ def test_view_attribute_details(admin_client, color_attribute):
def test_view_attribute_details_no_choices(admin_client):
attribute = Attribute.objects.create(slug='size', name='Size')
url = reverse(
- 'dashboard:product-attribute-details', kwargs={'pk': attribute.pk})
+ 'dashboard:attribute-details', kwargs={'pk': attribute.pk})
response = admin_client.get(url)
@@ -801,7 +801,7 @@ def test_view_attribute_details_no_choices(admin_client):
def test_view_attribute_create(admin_client, color_attribute):
- url = reverse('dashboard:product-attribute-add')
+ url = reverse('dashboard:attribute-add')
data = {'name': 'test', 'slug': 'test'}
response = admin_client.post(url, data, follow=True)
@@ -811,7 +811,7 @@ def test_view_attribute_create(admin_client, color_attribute):
def test_view_attribute_create_not_valid(admin_client, color_attribute):
- url = reverse('dashboard:product-attribute-add')
+ url = reverse('dashboard:attribute-add')
data = {}
response = admin_client.post(url, data, follow=True)
@@ -822,7 +822,7 @@ def test_view_attribute_create_not_valid(admin_client, color_attribute):
def test_view_attribute_edit(color_attribute, admin_client):
url = reverse(
- 'dashboard:product-attribute-update',
+ 'dashboard:attribute-update',
kwargs={'pk': color_attribute.pk})
data = {'name': 'new_name', 'slug': 'new_slug'}
@@ -837,7 +837,7 @@ def test_view_attribute_edit(color_attribute, admin_client):
def test_view_attribute_delete(admin_client, color_attribute):
url = reverse(
- 'dashboard:product-attribute-delete',
+ 'dashboard:attribute-delete',
kwargs={'pk': color_attribute.pk})
response = admin_client.post(url)
@@ -849,7 +849,7 @@ def test_view_attribute_delete(admin_client, color_attribute):
def test_view_attribute_not_deleted_before_confirmation(
admin_client, color_attribute):
url = reverse(
- 'dashboard:product-attribute-delete',
+ 'dashboard:attribute-delete',
kwargs={'pk': color_attribute.pk})
response = admin_client.get(url)
@@ -862,7 +862,7 @@ def test_view_attribute_value_create(color_attribute, admin_client):
values = AttributeValue.objects.filter(attribute=color_attribute.pk)
assert values.count() == 2
url = reverse(
- 'dashboard:product-attribute-value-add',
+ 'dashboard:attribute-value-add',
kwargs={'attribute_pk': color_attribute.pk})
data = {'name': 'Pink', 'attribute': color_attribute.pk}
@@ -878,7 +878,7 @@ def test_view_attribute_value_create_invalid(
values = AttributeValue.objects.filter(attribute=color_attribute.pk)
assert values.count() == 2
url = reverse(
- 'dashboard:product-attribute-value-add',
+ 'dashboard:attribute-value-add',
kwargs={'attribute_pk': color_attribute.pk})
data = {}
@@ -893,7 +893,7 @@ def test_view_attribute_value_edit(color_attribute, admin_client):
values = AttributeValue.objects.filter(attribute=color_attribute.pk)
assert values.count() == 2
url = reverse(
- 'dashboard:product-attribute-value-update',
+ 'dashboard:attribute-value-update',
kwargs={'attribute_pk': color_attribute.pk, 'value_pk': values[0].pk})
data = {'name': 'Pink', 'attribute': color_attribute.pk}
@@ -911,7 +911,7 @@ def test_view_attribute_value_delete(color_attribute, admin_client):
assert values.count() == 2
deleted_value = values[0]
url = reverse(
- 'dashboard:product-attribute-value-delete',
+ 'dashboard:attribute-value-delete',
kwargs={
'attribute_pk': color_attribute.pk, 'value_pk': deleted_value.pk})
@@ -928,7 +928,7 @@ def test_view_ajax_reorder_attribute_values(
order_before = [val.pk for val in color_attribute.values.all()]
ordered_values = list(reversed(order_before))
url = reverse(
- 'dashboard:product-attribute-values-reorder',
+ 'dashboard:attribute-values-reorder',
kwargs={'attribute_pk': color_attribute.pk})
data = {'ordered_values': ordered_values}
response = admin_client.post(
@@ -943,7 +943,7 @@ def test_view_ajax_reorder_attribute_values_invalid(
order_before = [val.pk for val in color_attribute.values.all()]
ordered_values = list(reversed(order_before)).append(3)
url = reverse(
- 'dashboard:product-attribute-values-reorder',
+ 'dashboard:attribute-values-reorder',
kwargs={'attribute_pk': color_attribute.pk})
data = {'ordered_values': ordered_values}
response = admin_client.post(
diff --git a/tests/test_product.py b/tests/test_product.py
index e1d313a625..c903b80d3e 100644
--- a/tests/test_product.py
+++ b/tests/test_product.py
@@ -640,11 +640,11 @@ def test_variant_picker_data_with_translations(
def test_get_product_attributes_data_translation(
- product, settings, translated_product_attribute):
+ product, settings, translated_attribute):
settings.LANGUAGE_CODE = 'fr'
attributes_data = get_product_attributes_data(product)
attributes_keys = [attr.name for attr in attributes_data.keys()]
- assert translated_product_attribute.name in attributes_keys
+ assert translated_attribute.name in attributes_keys
def test_homepage_collection_render(
diff --git a/tests/test_translation.py b/tests/test_translation.py
index 43079522e1..754f87047c 100644
--- a/tests/test_translation.py
+++ b/tests/test_translation.py
@@ -15,8 +15,8 @@ def product_translation_pl(product):
@pytest.fixture
-def attribute_value_translation_fr(translated_product_attribute):
- value = translated_product_attribute.product_attribute.values.first()
+def attribute_value_translation_fr(translated_attribute):
+ value = translated_attribute.product_attribute.values.first()
return AttributeValueTranslation.objects.create(
language_code='fr', attribute_value=value,
name='French name')
@@ -100,7 +100,7 @@ def test_product_variant_translation(settings, variant):
def test_attribute_translation(settings, color_attribute):
AttributeTranslation.objects.create(
- language_code='fr', product_attribute=color_attribute,
+ language_code='fr', attribute=color_attribute,
name='French name')
assert not color_attribute.translated.name == 'French name'
settings.LANGUAGE_CODE = 'fr'