Skip to content

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

Move and split api benchmarks

fowczreke6d87c153466
diff --git a/saleor/graphql/account/tests/benchmark/__init__.py b/saleor/graphql/account/tests/benchmark/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/api/benchmark/test_account.py b/saleor/graphql/account/tests/benchmark/test_account.py
similarity index 100%
rename from tests/api/benchmark/test_account.py
rename to saleor/graphql/account/tests/benchmark/test_account.py
diff --git a/tests/api/benchmark/test_permission_group.py b/saleor/graphql/account/tests/benchmark/test_permission_group.py
similarity index 100%
rename from tests/api/benchmark/test_permission_group.py
rename to saleor/graphql/account/tests/benchmark/test_permission_group.py
diff --git a/saleor/graphql/checkout/tests/benchmark/__init__.py b/saleor/graphql/checkout/tests/benchmark/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/saleor/graphql/checkout/tests/benchmark/conftest.py b/saleor/graphql/checkout/tests/benchmark/conftest.py
new file mode 100644
index 0000000000..fc29e0b8ba
--- /dev/null
+++ b/saleor/graphql/checkout/tests/benchmark/conftest.py
@@ -0,0 +1,79 @@
+import pytest
+
+from saleor.checkout import calculations
+from saleor.checkout.utils import add_variant_to_checkout
+from saleor.payment import ChargeStatus, TransactionKind
+from saleor.payment.models import Payment
+
+
+def customer_checkout(customer_user, checkout_with_voucher_percentage_and_shipping):
+ checkout_with_voucher_percentage_and_shipping.user = customer_user
+ checkout_with_voucher_percentage_and_shipping.save()
+ return checkout_with_voucher_percentage_and_shipping
+
+
+def checkout_with_variant(checkout, stock):
+ variant = stock.product_variant
+ add_variant_to_checkout(checkout, variant, 1)
+
+ checkout.save()
+ return checkout
+
+
+def checkout_with_shipping_address(checkout_with_variant, address):
+ checkout = checkout_with_variant
+
+ checkout.shipping_address = address.get_copy()
+ checkout.save()
+
+ return checkout
+
+
+def checkout_with_shipping_method(checkout_with_shipping_address, shipping_method):
+ checkout = checkout_with_shipping_address
+
+ checkout.shipping_method = shipping_method
+ checkout.save()
+
+ return checkout
+
+
+def checkout_with_billing_address(checkout_with_shipping_method, address):
+ checkout = checkout_with_shipping_method
+
+ checkout.billing_address = address
+ checkout.save()
+
+ return checkout
+
+
+def checkout_with_charged_payment(checkout_with_billing_address):
+ checkout = checkout_with_billing_address
+
+ taxed_total = calculations.checkout_total(checkout=checkout, lines=list(checkout))
+ payment = Payment.objects.create(
+ gateway="mirumee.payments.dummy",
+ is_active=True,
+ total=taxed_total.gross.amount,
+ currency="USD",
+ )
+
+ payment.charge_status = ChargeStatus.FULLY_CHARGED
+ payment.captured_amount = payment.total
+ payment.checkout = checkout_with_billing_address
+ payment.save()
+
+ payment.transactions.create(
+ amount=payment.total,
+ kind=TransactionKind.CAPTURE,
+ gateway_response={},
+ is_success=True,
+ )
+
+ return checkout
diff --git a/tests/api/benchmark/test_checkout_mutations.py b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
similarity index 99%
rename from tests/api/benchmark/test_checkout_mutations.py
rename to saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
index 2f06ba736c..02f441ee8b 100644
--- a/tests/api/benchmark/test_checkout_mutations.py
+++ b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py
@@ -3,8 +3,7 @@ from graphene import Node
from saleor.checkout import calculations
from saleor.checkout.models import Checkout
-
-from ..utils import get_graphql_content
+from tests.api.utils import get_graphql_content
FRAGMENT_PRICE = """
fragment Price on TaxedMoney {
diff --git a/saleor/graphql/checkout/tests/benchmark/test_homepage.py b/saleor/graphql/checkout/tests/benchmark/test_homepage.py
new file mode 100644
index 0000000000..aa97cf84f8
--- /dev/null
+++ b/saleor/graphql/checkout/tests/benchmark/test_homepage.py
@@ -0,0 +1,142 @@
+import pytest
+
+from tests.api.utils import get_graphql_content
+
+
[email protected]_queries(autouse=False)
+def test_user_checkout_details(user_api_client, customer_checkout, count_queries):
+ query = """
+ fragment Price on TaxedMoney {
+ gross {
+ amount
+ currency
+ }
+ net {
+ amount
+ currency
+ }
+ }
+
+ fragment ProductVariant on ProductVariant {
+ id
+ name
+ pricing {
+ onSale
+ priceUndiscounted {
+ ...Price
+ }
+ price {
+ ...Price
+ }
+ }
+ product {
+ id
+ name
+ thumbnail {
+ url
+ alt
+ }
+ thumbnail2x: thumbnail(size: 510) {
+ url
+ }
+ }
+ }
+
+ fragment CheckoutLine on CheckoutLine {
+ id
+ quantity
+ totalPrice {
+ ...Price
+ }
+ variant {
+ stockQuantity
+ ...ProductVariant
+ }
+ quantity
+ }
+
+ fragment Address on Address {
+ id
+ firstName
+ lastName
+ companyName
+ streetAddress1
+ streetAddress2
+ city
+ postalCode
+ country {
+ code
+ country
+ }
+ countryArea
+ phone
+ isDefaultBillingAddress
+ isDefaultShippingAddress
+ }
+
+ fragment ShippingMethod on ShippingMethod {
+ id
+ name
+ price {
+ currency
+ amount
+ }
+ }
+
+ fragment Checkout on Checkout {
+ availablePaymentGateways {
+ id
+ name
+ config {
+ field
+ value
+ }
+ }
+ token
+ id
+ totalPrice {
+ ...Price
+ }
+ subtotalPrice {
+ ...Price
+ }
+ billingAddress {
+ ...Address
+ }
+ shippingAddress {
+ ...Address
+ }
+ email
+ availableShippingMethods {
+ ...ShippingMethod
+ }
+ shippingMethod {
+ ...ShippingMethod
+ }
+ shippingPrice {
+ ...Price
+ }
+ lines {
+ ...CheckoutLine
+ }
+ isShippingRequired
+ discount {
+ currency
+ amount
+ }
+ discountName
+ translatedDiscountName
+ voucherCode
+ }
+
+ query UserCheckoutDetails {
+ me {
+ id
+ checkout {
+ ...Checkout
+ }
+ }
+ }
+ """
+ get_graphql_content(user_api_client.post_graphql(query))
diff --git a/saleor/graphql/menu/tests/benchmark.py/__init__.py b/saleor/graphql/menu/tests/benchmark.py/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/saleor/graphql/menu/tests/benchmark.py/conftest.py b/saleor/graphql/menu/tests/benchmark.py/conftest.py
new file mode 100644
index 0000000000..89eb814f91
--- /dev/null
+++ b/saleor/graphql/menu/tests/benchmark.py/conftest.py
@@ -0,0 +1,23 @@
+import pytest
+
+from saleor.menu.utils import update_menu
+
+
+def site_with_top_menu(site_settings):
+ menu = site_settings.top_menu
+ menu.items.create(name="Link 1", url="http://example.com/")
+ menu.items.create(name="Link 2", url="http://example.com/")
+ menu.items.create(name="Link 3", url="http://example.com/")
+ update_menu(menu)
+ return site_settings
+
+
+def site_with_bottom_menu(site_settings):
+ menu = site_settings.bottom_menu
+ menu.items.create(name="Link 1", url="http://example.com/")
+ menu.items.create(name="Link 2", url="http://example.com/")
+ menu.items.create(name="Link 3", url="http://example.com/")
+ update_menu(menu)
+ return site_settings
diff --git a/saleor/graphql/menu/tests/benchmark.py/test_homepage.py b/saleor/graphql/menu/tests/benchmark.py/test_homepage.py
new file mode 100644
index 0000000000..936b0491fd
--- /dev/null
+++ b/saleor/graphql/menu/tests/benchmark.py/test_homepage.py
@@ -0,0 +1,89 @@
+import pytest
+
+from tests.api.utils import get_graphql_content
+
+
[email protected]_queries(autouse=False)
+def test_retrieve_main_menu(api_client, site_with_top_menu, count_queries):
+ query = """
+ fragment MainMenuSubItem on MenuItem {
+ id
+ name
+ category {
+ id
+ name
+ }
+ url
+ collection {
+ id
+ name
+ }
+ page {
+ slug
+ }
+ parent {
+ id
+ }
+ }
+
+ query MainMenu {
+ shop {
+ navigation {
+ main {
+ id
+ items {
+ ...MainMenuSubItem
+ children {
+ ...MainMenuSubItem
+ children {
+ ...MainMenuSubItem
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ """
+
+ get_graphql_content(api_client.post_graphql(query))
+
+
[email protected]_queries(autouse=False)
+def test_retrieve_secondary_menu(api_client, site_with_bottom_menu, count_queries):
+ query = """
+ fragment SecondaryMenuSubItem on MenuItem {
+ id
+ name
+ category {
+ id
+ name
+ }
+ url
+ collection {
+ id
+ name
+ }
+ page {
+ slug
+ }
+ }
+
+ query SecondaryMenu {
+ shop {
+ navigation {
+ secondary {
+ items {
+ ...SecondaryMenuSubItem
+ children {
+ ...SecondaryMenuSubItem
+ }
+ }
+ }
+ }
+ }
+ }
+ """
+ get_graphql_content(api_client.post_graphql(query))
diff --git a/saleor/graphql/order/tests/benchmark/__init__.py b/saleor/graphql/order/tests/benchmark/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/api/benchmark/test_order.py b/saleor/graphql/order/tests/benchmark/test_order.py
similarity index 87%
rename from tests/api/benchmark/test_order.py
rename to saleor/graphql/order/tests/benchmark/test_order.py
index a226fc823c..b19eb36b8f 100644
--- a/tests/api/benchmark/test_order.py
+++ b/saleor/graphql/order/tests/benchmark/test_order.py
@@ -1,7 +1,10 @@
import pytest
-from ..utils import get_graphql_content
-from .test_checkout_mutations import FRAGMENT_ADDRESS, FRAGMENT_PRODUCT_VARIANT
+from saleor.graphql.checkout.tests.benchmark.test_checkout_mutations import (
+ FRAGMENT_ADDRESS,
+ FRAGMENT_PRODUCT_VARIANT,
+)
+from tests.api.utils import get_graphql_content
FRAGMENT_ORDER_DETAILS = (
FRAGMENT_ADDRESS
diff --git a/saleor/graphql/product/tests/benchmark/__init__.py b/saleor/graphql/product/tests/benchmark/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/saleor/graphql/product/tests/benchmark/conftest.py b/saleor/graphql/product/tests/benchmark/conftest.py
new file mode 100644
index 0000000000..380f5b2fc9
--- /dev/null
+++ b/saleor/graphql/product/tests/benchmark/conftest.py
@@ -0,0 +1,65 @@
+import pytest
+
+from saleor.discount.models import Sale
+from saleor.product.models import Category
+
+
+def sales_list():
+ return list(
+ Sale.objects.bulk_create(
+ [Sale(name="Sale1", value=15), Sale(name="Sale2", value=5)]
+ )
+ )
+
+
+def homepage_collection(
+ site_settings,
+ collection,
+ product_list_published,
+ product_with_image,
+ product_with_variant_with_two_attributes,
+ product_with_multiple_values_attributes,
+ product_without_shipping,
+ non_default_category,
+ sales_list,
+):
+ product_with_image.category = non_default_category
+ product_with_image.save()
+
+ collection.products.set(product_list_published)
+
+ collection.products.add(product_with_image)
+ collection.products.add(product_with_variant_with_two_attributes)
+ collection.products.add(product_with_multiple_values_attributes)
+ collection.products.add(product_without_shipping)
+
+ site_settings.homepage_collection = collection
+ site_settings.save(update_fields=["homepage_collection"])
+ return collection
+
+
+def category_with_products(
+ product_with_image,
+ product_list_published,
+ product_with_variant_with_two_attributes,
+ product_with_multiple_values_attributes,
+ product_without_shipping,
+ sales_list,
+):
+ category = Category.objects.create(name="Category", slug="cat")
+
+ product_list_published.update(category=category)
+
+ product_with_image.category = category
+ product_with_image.save()
+ product_with_variant_with_two_attributes.category = category
+ product_with_variant_with_two_attributes.save()
+ product_with_multiple_values_attributes.category = category
+ product_with_multiple_values_attributes.save()
+ product_without_shipping.category = category
+ product_without_shipping.save()
+
+ return category
diff --git a/tests/api/benchmark/test_category.py b/saleor/graphql/product/tests/benchmark/test_category.py
similarity index 100%
rename from tests/api/benchmark/test_category.py
rename to saleor/graphql/product/tests/benchmark/test_category.py
diff --git a/tests/api/benchmark/test_collection.py b/saleor/graphql/product/tests/benchmark/test_collection.py
similarity index 100%
rename from tests/api/benchmark/test_collection.py
rename to saleor/graphql/product/tests/benchmark/test_collection.py
diff --git a/saleor/graphql/product/tests/benchmark/test_homepage.py b/saleor/graphql/product/tests/benchmark/test_homepage.py
new file mode 100644
index 0000000000..23fdf9c0bc
--- /dev/null
+++ b/saleor/graphql/product/tests/benchmark/test_homepage.py
@@ -0,0 +1,109 @@
+import pytest
+
+from tests.api.utils import get_graphql_content
+
+
[email protected]_queries(autouse=False)
+def test_retrieve_product_list(
+ api_client, homepage_collection, category, categories_tree, count_queries,
+):
+ query = """
+ query ProductsList {
+ shop {
+ description
+ name
+ homepageCollection {
+ id
+ backgroundImage {
+ url
+ }
+ name
+ }
+ }
+ categories(level: 0, first: 4) {
+ edges {
+ node {
+ id
+ name
+ backgroundImage {
+ url
+ }
+ }
+ }
+ }
+ }
+ """
+ get_graphql_content(api_client.post_graphql(query))
+
+
[email protected]_queries(autouse=False)
+def test_featured_products_list(api_client, homepage_collection, count_queries):
+ query = """
+ fragment BasicProductFields on Product {
+ id
+ name
+ thumbnail {
+ url
+ alt
+ }
+ thumbnail2x: thumbnail(size: 510) {
+ url
+ }
+ }
+
+ fragment Price on TaxedMoney {
+ gross {
+ amount
+ currency
+ }
+ net {
+ amount
+ currency
+ }
+ }
+
+ fragment ProductPricingField on Product {
+ pricing {
+ onSale
+ priceRangeUndiscounted {
+ start {
+ ...Price
+ }
+ stop {
+ ...Price
+ }
+ }
+ priceRange {
+ start {
+ ...Price
+ }
+ stop {
+ ...Price
+ }
+ }
+ }
+ }
+
+ query FeaturedProducts {
+ shop {
+ homepageCollection {
+ id
+ products(first: 20) {
+ edges {
+ node {
+ ...BasicProductFields
+ ...ProductPricingField
+ category {
+ id
+ name
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ """
+ get_graphql_content(api_client.post_graphql(query))
diff --git a/tests/api/benchmark/test_product.py b/saleor/graphql/product/tests/benchmark/test_product.py
similarity index 100%
rename from tests/api/benchmark/test_product.py
rename to saleor/graphql/product/tests/benchmark/test_product.py
diff --git a/tests/api/benchmark/test_variant.py b/saleor/graphql/product/tests/benchmark/test_variant.py
similarity index 100%
rename from tests/api/benchmark/test_variant.py
rename to saleor/graphql/product/tests/benchmark/test_variant.py
diff --git a/tests/api/benchmark/test_variant_stocks.py b/saleor/graphql/product/tests/benchmark/test_variant_stocks.py
similarity index 100%
rename from tests/api/benchmark/test_variant_stocks.py
rename to saleor/graphql/product/tests/benchmark/test_variant_stocks.py
diff --git a/saleor/graphql/shop/tests/benchmark/__init__.py b/saleor/graphql/shop/tests/benchmark/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/saleor/graphql/shop/tests/benchmark/test_homepage.py b/saleor/graphql/shop/tests/benchmark/test_homepage.py
new file mode 100644
index 0000000000..b21a5eeaee
--- /dev/null
+++ b/saleor/graphql/shop/tests/benchmark/test_homepage.py
@@ -0,0 +1,30 @@
+import pytest
+
+from tests.api.utils import get_graphql_content
+
+
[email protected]_queries(autouse=False)
+def test_retrieve_shop(api_client, count_queries):
+ query = """
+ query getShop {
+ shop {
+ defaultCountry {
+ code
+ country
+ }
+ countries {
+ country
+ code
+ }
+ geolocalization {
+ country {
+ code
+ country
+ }
+ }
+ }
+ }
+ """
+
+ get_graphql_content(api_client.post_graphql(query))
diff --git a/tests/api/benchmark/conftest.py b/tests/api/benchmark/conftest.py
deleted file mode 100644
index dde3149eeb..0000000000
--- a/tests/api/benchmark/conftest.py
+++ /dev/null
@@ -1,163 +0,0 @@
-import pytest
-
-from saleor.checkout import calculations
-from saleor.checkout.utils import add_variant_to_checkout
-from saleor.discount.models import Sale
-from saleor.menu.utils import update_menu
-from saleor.payment import ChargeStatus, TransactionKind
-from saleor.payment.models import Payment
-from saleor.product.models import Category
-
-
-def site_with_top_menu(site_settings):
- menu = site_settings.top_menu
- menu.items.create(name="Link 1", url="http://example.com/")
- menu.items.create(name="Link 2", url="http://example.com/")
- menu.items.create(name="Link 3", url="http://example.com/")
- update_menu(menu)
- return site_settings
-
-
-def site_with_bottom_menu(site_settings):
- menu = site_settings.bottom_menu
- menu.items.create(name="Link 1", url="http://example.com/")
- menu.items.create(name="Link 2", url="http://example.com/")
- menu.items.create(name="Link 3", url="http://example.com/")
- update_menu(menu)
- return site_settings
-
-
-def sales_list():
- return list(
- Sale.objects.bulk_create(
- [Sale(name="Sale1", value=15), Sale(name="Sale2", value=5)]
- )
- )
-
-
-def homepage_collection(
- site_settings,
- collection,
- product_list_published,
- product_with_image,
- product_with_variant_with_two_attributes,
- product_with_multiple_values_attributes,
- product_without_shipping,
- non_default_category,
- sales_list,
-):
- product_with_image.category = non_default_category
- product_with_image.save()
-
- collection.products.set(product_list_published)
-
- collection.products.add(product_with_image)
- collection.products.add(product_with_variant_with_two_attributes)
- collection.products.add(product_with_multiple_values_attributes)
- collection.products.add(product_without_shipping)
-
- site_settings.homepage_collection = collection
- site_settings.save(update_fields=["homepage_collection"])
- return collection
-
-
-def category_with_products(
- product_with_image,
- product_list_published,
- product_with_variant_with_two_attributes,
- product_with_multiple_values_attributes,
- product_without_shipping,
- sales_list,
-):
- category = Category.objects.create(name="Category", slug="cat")
-
- product_list_published.update(category=category)
-
- product_with_image.category = category
- product_with_image.save()
- product_with_variant_with_two_attributes.category = category
- product_with_variant_with_two_attributes.save()
- product_with_multiple_values_attributes.category = category
- product_with_multiple_values_attributes.save()
- product_without_shipping.category = category
- product_without_shipping.save()
-
- return category
-
-
-def customer_checkout(customer_user, checkout_with_voucher_percentage_and_shipping):
- checkout_with_voucher_percentage_and_shipping.user = customer_user
- checkout_with_voucher_percentage_and_shipping.save()
- return checkout_with_voucher_percentage_and_shipping
-
-
-def checkout_with_variant(checkout, stock):
- variant = stock.product_variant
- add_variant_to_checkout(checkout, variant, 1)
-
- checkout.save()
- return checkout
-
-
-def checkout_with_shipping_address(checkout_with_variant, address):
- checkout = checkout_with_variant
-
- checkout.shipping_address = address.get_copy()
- checkout.save()
-
- return checkout
-
-
-def checkout_with_shipping_method(checkout_with_shipping_address, shipping_method):
- checkout = checkout_with_shipping_address
-
- checkout.shipping_method = shipping_method
- checkout.save()
-
- return checkout
-
-
-def checkout_with_billing_address(checkout_with_shipping_method, address):
- checkout = checkout_with_shipping_method
-
- checkout.billing_address = address
- checkout.save()
-
- return checkout
-
-
-def checkout_with_charged_payment(checkout_with_billing_address):
- checkout = checkout_with_billing_address
-
- taxed_total = calculations.checkout_total(checkout=checkout, lines=list(checkout))
- payment = Payment.objects.create(
- gateway="mirumee.payments.dummy",
- is_active=True,
- total=taxed_total.gross.amount,
- currency="USD",
- )
-
- payment.charge_status = ChargeStatus.FULLY_CHARGED
- payment.captured_amount = payment.total
- payment.checkout = checkout_with_billing_address
- payment.save()
-
- payment.transactions.create(
- amount=payment.total,
- kind=TransactionKind.CAPTURE,
- gateway_response={},
- is_success=True,
- )
-
- return checkout
diff --git a/tests/api/benchmark/test_homepage.py b/tests/api/benchmark/test_homepage.py
deleted file mode 100644
index 2ebb32e445..0000000000
--- a/tests/api/benchmark/test_homepage.py
+++ /dev/null
@@ -1,361 +0,0 @@
-import pytest
-
-from tests.api.utils import get_graphql_content
-
-
[email protected]_queries(autouse=False)
-def test_retrieve_main_menu(api_client, site_with_top_menu, count_queries):
- query = """
- fragment MainMenuSubItem on MenuItem {
- id
- name
- category {
- id
- name
- }
- url
- collection {
- id
- name
- }
- page {
- slug
- }
- parent {
- id
- }
- }
-
- query MainMenu {
- shop {
- navigation {
- main {
- id
- items {
- ...MainMenuSubItem
- children {
- ...MainMenuSubItem
- children {
- ...MainMenuSubItem
- }
- }
- }
- }
- }
- }
- }
- """
-
- get_graphql_content(api_client.post_graphql(query))
-
-
[email protected]_queries(autouse=False)
-def test_retrieve_secondary_menu(api_client, site_with_bottom_menu, count_queries):
- query = """
- fragment SecondaryMenuSubItem on MenuItem {
- id
- name
- category {
- id
- name
- }
- url
- collection {
- id
- name
- }
- page {
- slug
- }
- }
-
- query SecondaryMenu {
- shop {
- navigation {
- secondary {
- items {
- ...SecondaryMenuSubItem
- children {
- ...SecondaryMenuSubItem
- }
- }
- }
- }
- }
- }
- """
- get_graphql_content(api_client.post_graphql(query))
-
-
[email protected]_queries(autouse=False)
-def test_retrieve_shop(api_client, count_queries):
- query = """
- query getShop {
- shop {
- defaultCountry {
- code
- country
- }
- countries {
- country
- code
- }
- geolocalization {
- country {
- code
- country
- }
- }
- }
- }
- """
-
- get_graphql_content(api_client.post_graphql(query))
-
-
[email protected]_queries(autouse=False)
-def test_retrieve_product_list(
- api_client, homepage_collection, category, categories_tree, count_queries,
-):
- query = """
- query ProductsList {
- shop {
- description
- name
- homepageCollection {
- id
- backgroundImage {
- url
- }
- name
- }
- }
- categories(level: 0, first: 4) {
- edges {
- node {
- id
- name
- backgroundImage {
- url
- }
- }
- }
- }
- }
- """
- get_graphql_content(api_client.post_graphql(query))
-
-
[email protected]_queries(autouse=False)
-def test_featured_products_list(api_client, homepage_collection, count_queries):
- query = """
- fragment BasicProductFields on Product {
- id
- name
- thumbnail {
- url
- alt
- }
- thumbnail2x: thumbnail(size: 510) {
- url
- }
- }
-
- fragment Price on TaxedMoney {
- gross {
- amount
- currency
- }
- net {
- amount
- currency
- }
- }
-
- fragment ProductPricingField on Product {
- pricing {
- onSale
- priceRangeUndiscounted {
- start {
- ...Price
- }
- stop {
- ...Price
- }
- }
- priceRange {
- start {
- ...Price
- }
- stop {
- ...Price
- }
- }
- }
- }
-
- query FeaturedProducts {
- shop {
- homepageCollection {
- id
- products(first: 20) {
- edges {
- node {
- ...BasicProductFields
- ...ProductPricingField
- category {
- id
- name
- }
- }
- }
- }
- }
- }
- }
- """
- get_graphql_content(api_client.post_graphql(query))
-
-
[email protected]_queries(autouse=False)
-def test_user_checkout_details(user_api_client, customer_checkout, count_queries):
- query = """
- fragment Price on TaxedMoney {
- gross {
- amount
- currency
- }
- net {
- amount
- currency
- }
- }
-
- fragment ProductVariant on ProductVariant {
- id
- name
- pricing {
- onSale
- priceUndiscounted {
- ...Price
- }
- price {
- ...Price
- }
- }
- product {
- id
- name
- thumbnail {
- url
- alt
- }
- thumbnail2x: thumbnail(size: 510) {
- url
- }
- }
- }
-
- fragment CheckoutLine on CheckoutLine {
- id
- quantity
- totalPrice {
- ...Price
- }
- variant {
- stockQuantity
- ...ProductVariant
- }
- quantity
- }
-
- fragment Address on Address {
- id
- firstName
- lastName
- companyName
- streetAddress1
- streetAddress2
- city
- postalCode
- country {
- code
- country
- }
- countryArea
- phone
- isDefaultBillingAddress
- isDefaultShippingAddress
- }
-
- fragment ShippingMethod on ShippingMethod {
- id
- name
- price {
- currency
- amount
- }
- }
-
- fragment Checkout on Checkout {
- availablePaymentGateways {
- id
- name
- config {
- field
- value
- }
- }
- token
- id
- totalPrice {
- ...Price
- }
- subtotalPrice {
- ...Price
- }
- billingAddress {
- ...Address
- }
- shippingAddress {
- ...Address
- }
- email
- availableShippingMethods {
- ...ShippingMethod
- }
- shippingMethod {
- ...ShippingMethod
- }
- shippingPrice {
- ...Price
- }
- lines {
- ...CheckoutLine
- }
- isShippingRequired
- discount {
- currency
- amount
- }
- discountName
- translatedDiscountName
- voucherCode
- }
-
- query UserCheckoutDetails {
- me {
- id
- checkout {
- ...Checkout
- }
- }
- }
- """
- get_graphql_content(user_api_client.post_graphql(query))