Skip to content

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

Use checkout object with many lines in benchmark tests

Maciej Korycinski8c70f2eb8b80
diff --git a/saleor/graphql/checkout/tests/benchmark/conftest.py b/saleor/graphql/checkout/tests/benchmark/conftest.py
index 4548b64ea2..f34ab7f22d 100644
--- a/saleor/graphql/checkout/tests/benchmark/conftest.py
+++ b/saleor/graphql/checkout/tests/benchmark/conftest.py
@@ -14,17 +14,26 @@ def customer_checkout(customer_user, checkout_with_voucher_percentage_and_shippi
@pytest.fixture()
-def checkout_with_variant(checkout, stock):
- variant = stock.product_variant
- add_variant_to_checkout(checkout, variant, 1)
+def checkout_with_variants(
+ checkout,
+ stock,
+ product_with_default_variant,
+ product_with_single_variant,
+ product_with_two_variants,
+):
+
+ add_variant_to_checkout(checkout, product_with_default_variant.variants.get(), 1)
+ add_variant_to_checkout(checkout, product_with_single_variant.variants.get(), 10)
+ add_variant_to_checkout(checkout, product_with_two_variants.variants.first(), 3)
+ add_variant_to_checkout(checkout, product_with_two_variants.variants.last(), 5)
checkout.save()
return checkout
@pytest.fixture()
-def checkout_with_shipping_address(checkout_with_variant, address):
- checkout = checkout_with_variant
+def checkout_with_shipping_address(checkout_with_variants, address):
+ checkout = checkout_with_variants
checkout.shipping_address = address.get_copy()
checkout.save()
diff --git a/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
index 6789cac0a2..383f775a00 100644
--- a/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
+++ b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
@@ -297,7 +297,7 @@ def test_add_billing_address_to_checkout(
@pytest.mark.count_queries(autouse=False)
def test_update_checkout_lines(
api_client,
- checkout_with_variant,
+ checkout_with_items,
stock,
product_with_default_variant,
product_with_single_variant,
@@ -331,7 +331,7 @@ def test_update_checkout_lines(
"""
)
variables = {
- "checkoutId": Node.to_global_id("Checkout", checkout_with_variant.pk),
+ "checkoutId": Node.to_global_id("Checkout", checkout_with_items.pk),
"lines": [
{
"quantity": 1,
@@ -372,7 +372,7 @@ def test_update_checkout_lines(
@pytest.mark.django_db
@pytest.mark.count_queries(autouse=False)
def test_checkout_shipping_address_update(
- api_client, graphql_address_data, checkout_with_variant, count_queries
+ api_client, graphql_address_data, checkout_with_variants, count_queries
):
query = (
FRAGMENT_CHECKOUT
@@ -395,7 +395,7 @@ def test_checkout_shipping_address_update(
"""
)
variables = {
- "checkoutId": Node.to_global_id("Checkout", checkout_with_variant.pk),
+ "checkoutId": Node.to_global_id("Checkout", checkout_with_variants.pk),
"shippingAddress": graphql_address_data,
}
response = get_graphql_content(api_client.post_graphql(query, variables))
@@ -404,7 +404,7 @@ def test_checkout_shipping_address_update(
@pytest.mark.django_db
@pytest.mark.count_queries(autouse=False)
-def test_checkout_email_update(api_client, checkout_with_variant, count_queries):
+def test_checkout_email_update(api_client, checkout_with_variants, count_queries):
query = (
FRAGMENT_CHECKOUT
+ """
@@ -424,7 +424,7 @@ def test_checkout_email_update(api_client, checkout_with_variant, count_queries)
"""
)
variables = {
- "checkoutId": Node.to_global_id("Checkout", checkout_with_variant.pk),
+ "checkoutId": Node.to_global_id("Checkout", checkout_with_variants.pk),
"email": "[email protected]",
}
response = get_graphql_content(api_client.post_graphql(query, variables))