Skip to content

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

Add test

Krzysztof Świątek19319ef05e62
diff --git a/tests/api/test_variant.py b/tests/api/test_variant.py
index a377c6db51..71a579e010 100644
--- a/tests/api/test_variant.py
+++ b/tests/api/test_variant.py
@@ -887,33 +887,33 @@ def test_product_variant_bulk_create_by_attribute_id(
assert not product_variant.price_override
+ "price_field", ("priceOverride", "costPrice",),
+)
def test_product_variant_bulk_create_by_attribute_id_with_invalid_price(
- staff_api_client, product, size_attribute, permission_manage_products
+ staff_api_client, product, size_attribute, permission_manage_products, price_field
):
product_id = graphene.Node.to_global_id("Product", product.pk)
attribut_id = graphene.Node.to_global_id("Attribute", size_attribute.pk)
attribute_value = size_attribute.values.last()
sku = str(uuid4())[:12]
- variants = [
- {
- "sku": sku,
- "quantity": 1000,
- "costPrice": None,
- "priceOverride": "-1",
- "weight": 2.5,
- "trackInventory": True,
- "attributes": [{"id": attribut_id, "values": [attribute_value.name]}],
- }
- ]
+ variant = {
+ "sku": sku,
+ "quantity": 1000,
+ "weight": 2.5,
+ "trackInventory": True,
+ "attributes": [{"id": attribut_id, "values": [attribute_value.name]}],
+ }
+ variant[price_field] = "-1"
- variables = {"productId": product_id, "variants": variants}
+ variables = {"productId": product_id, "variants": [variant]}
staff_api_client.user.user_permissions.add(permission_manage_products)
response = staff_api_client.post_graphql(
PRODUCT_VARIANT_BULK_CREATE_MUTATION, variables
)
content = get_graphql_content(response)
data = content["data"]["productVariantBulkCreate"]
- assert data["bulkProductErrors"][0]["field"] == "priceOverride"
+ assert data["bulkProductErrors"][0]["field"] == price_field
assert data["bulkProductErrors"][0]["code"] == ProductErrorCode.INVALID.name