Skip to content

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

Benchmark tests for order address resolvers (#7079)

Tomasz Szymański26bd271ac323
diff --git a/conftest.py b/conftest.py
index e23e4a8b9f..62f7fb73b3 100644
--- a/conftest.py
+++ b/conftest.py
@@ -3,4 +3,5 @@ pytest_plugins = [
"saleor.plugins.tests.fixtures",
"saleor.graphql.tests.fixtures",
"saleor.graphql.channel.tests.fixtures",
+ "saleor.graphql.order.tests.benchmark.fixtures",
]
diff --git a/saleor/graphql/order/tests/benchmark/fixtures.py b/saleor/graphql/order/tests/benchmark/fixtures.py
new file mode 100644
index 0000000000..f7f921a6b4
--- /dev/null
+++ b/saleor/graphql/order/tests/benchmark/fixtures.py
@@ -0,0 +1,22 @@
+import uuid
+
+import pytest
+from prices import Money, TaxedMoney
+
+from .....order.models import Order
+
+
+def orders_for_benchmarks(channel_USD, address, customer_user):
+ orders = [
+ Order(
+ token=str(uuid.uuid4()),
+ channel=channel_USD,
+ billing_address=address.get_copy(),
+ shipping_address=address.get_copy(),
+ user=customer_user,
+ total=TaxedMoney(net=Money(i, "USD"), gross=Money(i, "USD")),
+ )
+ for i in range(10)
+ ]
+ return Order.objects.bulk_create(orders)
diff --git a/saleor/graphql/order/tests/benchmark/test_order.py b/saleor/graphql/order/tests/benchmark/test_order.py
index 051b21d62a..f1ad4019a0 100644
--- a/saleor/graphql/order/tests/benchmark/test_order.py
+++ b/saleor/graphql/order/tests/benchmark/test_order.py
@@ -152,3 +152,37 @@ def test_staff_order_details(
}
staff_api_client.user.user_permissions.add(permission_manage_orders)
get_graphql_content(staff_api_client.post_graphql(query, variables))
+
+
+MULTIPLE_ORDER_ADDRESS_DETAILS_QUERY = """
+ query orders {
+ orders(first: 10) {
+ edges {
+ node {
+ id
+ shippingAddress {
+ id
+ }
+ billingAddress {
+ id
+ }
+ }
+ }
+ }
+ }
+"""
+
+
[email protected]_queries(autouse=False)
+def test_staff_multiple_orders_address_resolving(
+ staff_api_client,
+ permission_manage_orders,
+ orders_for_benchmarks,
+ count_queries,
+):
+ staff_api_client.user.user_permissions.add(permission_manage_orders)
+ content = get_graphql_content(
+ staff_api_client.post_graphql(MULTIPLE_ORDER_ADDRESS_DETAILS_QUERY)
+ )
+ assert content["data"]["orders"] is not None