Skip to content

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

Adjust tests

Marcin Gębalab4ddf10a485b
diff --git a/saleor/graphql/payment/types.py b/saleor/graphql/payment/types.py
index bb8a621bdd..7082ce59ec 100644
--- a/saleor/graphql/payment/types.py
+++ b/saleor/graphql/payment/types.py
@@ -4,8 +4,7 @@ from graphene import relay
from ...payment import GATEWAYS_ENUM, ChargeStatus, models
from ..account.types import Address
-from ..core.types.common import CountableDjangoObjectType, CountryDisplay
-from ..core.types.money import Money
+from ..core.types import CountableDjangoObjectType, Money
from ..core.utils import str_to_enum
PaymentGatewayEnum = graphene.Enum.from_enum(GATEWAYS_ENUM)
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.py
index 9cfe28b27e..a5fc1aaf18 100644
--- a/saleor/graphql/product/types.py
+++ b/saleor/graphql/product/types.py
@@ -285,7 +285,7 @@ class Product(CountableDjangoObjectType):
description='Get a single product image by ID')
variants = gql_optimizer.field(
graphene.List(
- ProductVariant, description='List of varinats for the product'),
+ ProductVariant, description='List of variants for the product'),
model_field='variants')
images = gql_optimizer.field(
graphene.List(
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index 06cc335dd4..b84aa84e28 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -170,7 +170,7 @@ def test_query_customers(
staff_api_client, user_api_client, permission_manage_users):
query = """
query Users {
- customers {
+ customers(first: 20) {
totalCount
edges {
node {
@@ -198,7 +198,7 @@ def test_query_staff(
admin_user, permission_manage_staff):
query = """
{
- staffUsers {
+ staffUsers(first: 20) {
edges {
node {
email
diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.py
index 469c48d531..085d49275f 100644
--- a/tests/api/test_attributes.py
+++ b/tests/api/test_attributes.py
@@ -39,7 +39,7 @@ def test_attributes_query(user_api_client, product):
attributes = Attribute.objects.prefetch_related('values')
query = """
query {
- attributes {
+ attributes(first: 20) {
edges {
node {
id
@@ -65,7 +65,7 @@ def test_attributes_in_category_query(user_api_client, product):
category = Category.objects.first()
query = """
query {
- attributes(inCategory: "%(category_id)s") {
+ attributes(inCategory: "%(category_id)s", first: 20) {
edges {
node {
id
diff --git a/tests/api/test_category.py b/tests/api/test_category.py
index c07cca050d..861c00f124 100644
--- a/tests/api/test_category.py
+++ b/tests/api/test_category.py
@@ -16,14 +16,7 @@ def test_category_query(user_api_client, product):
category(id: "%(category_pk)s") {
id
name
- ancestors {
- edges {
- node {
- name
- }
- }
- }
- children {
+ children(first: 20) {
edges {
node {
name
@@ -38,9 +31,6 @@ def test_category_query(user_api_client, product):
category_data = content['data']['category']
assert category_data is not None
assert category_data['name'] == category.name
- assert (
- len(category_data['ancestors']['edges']) ==
- category.get_ancestors().count())
assert (
len(category_data['children']['edges']) ==
category.get_children().count())
@@ -292,7 +282,7 @@ def test_category_delete_mutation(
LEVELED_CATEGORIES_QUERY = """
query leveled_categories($level: Int) {
- categories(level: $level) {
+ categories(level: $level, first: 20) {
edges {
node {
name
diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.py
index 1c29a02466..25ce84e670 100644
--- a/tests/api/test_checkout.py
+++ b/tests/api/test_checkout.py
@@ -550,7 +550,7 @@ def test_query_checkouts(
cart_with_item, staff_api_client, permission_manage_orders):
query = """
{
- checkouts {
+ checkouts(first: 20) {
edges {
node {
token
@@ -571,7 +571,7 @@ def test_query_checkout_lines(
cart_with_item, staff_api_client, permission_manage_orders):
query = """
{
- checkoutLines {
+ checkoutLines(first: 20) {
edges {
node {
id
diff --git a/tests/api/test_graphql.py b/tests/api/test_graphql.py
index 6b1cc03147..2662143e36 100644
--- a/tests/api/test_graphql.py
+++ b/tests/api/test_graphql.py
@@ -54,7 +54,7 @@ def test_real_query(user_api_client, product):
...ProductListFragmentQuery
__typename
}
- attributes(inCategory: $categoryId) {
+ attributes(inCategory: $categoryId, first: 20) {
edges {
node {
...ProductFiltersFragmentQuery
@@ -68,17 +68,7 @@ def test_real_query(user_api_client, product):
id
name
url
- ancestors {
- edges {
- node {
- name
- id
- url
- __typename
- }
- }
- }
- children {
+ children(first: 20) {
edges {
node {
name
diff --git a/tests/api/test_homepage.py b/tests/api/test_homepage.py
index 710cbc1f02..8a4d6ddc6e 100644
--- a/tests/api/test_homepage.py
+++ b/tests/api/test_homepage.py
@@ -5,7 +5,7 @@ from .utils import get_graphql_content
def test_homepage_events(order_events, staff_api_client, permission_manage_orders):
query = """
{
- homepageEvents {
+ homepageEvents(first: 20) {
edges {
node {
date
diff --git a/tests/api/test_payment.py b/tests/api/test_payment.py
index 695ddac952..6875021e8d 100644
--- a/tests/api/test_payment.py
+++ b/tests/api/test_payment.py
@@ -257,7 +257,7 @@ def test_payment_refund_error(
def test_payments_query(
payment_txn_captured, permission_manage_orders, staff_api_client):
query = """ {
- payments {
+ payments(first: 20) {
edges {
node {
id
@@ -365,7 +365,7 @@ def test_query_payments(
payment_dummy, permission_manage_orders, staff_api_client):
query = """
{
- payments {
+ payments(first: 20) {
edges {
node {
id
diff --git a/tests/api/test_product.py b/tests/api/test_product.py
index 4f87227eab..724489b3e6 100644
--- a/tests/api/test_product.py
+++ b/tests/api/test_product.py
@@ -38,7 +38,7 @@ def test_resolve_attribute_list(color_attribute):
def test_fetch_all_products(user_api_client, product):
query = """
query {
- products {
+ products(first: 1) {
totalCount
edges {
node {
@@ -60,7 +60,7 @@ def test_fetch_unavailable_products(user_api_client, product):
Product.objects.update(is_published=False)
query = """
query {
- products {
+ products(first: 1) {
totalCount
edges {
node {
@@ -82,7 +82,7 @@ def test_product_query(staff_api_client, product, permission_manage_products):
query = """
query {
category(id: "%(category_id)s") {
- products {
+ products(first: 20) {
edges {
node {
id
@@ -200,7 +200,7 @@ def test_filter_product_by_category(user_api_client, product):
category = product.category
query = """
query getProducts($categoryId: ID) {
- products(categories: [$categoryId]) {
+ products(categories: [$categoryId], first: 1) {
edges {
node {
name
@@ -241,7 +241,7 @@ def test_filter_products_by_attributes(user_api_client, product):
filter_by = '%s:%s' % (product_attr.slug, attr_value.slug)
query = """
query {
- products(attributes: ["%(filter_by)s"]) {
+ products(attributes: ["%(filter_by)s"], first: 1) {
edges {
node {
name
@@ -263,7 +263,7 @@ def test_filter_products_by_categories(
product.save()
query = """
query {
- products(categories: ["%(category_id)s"]) {
+ products(categories: ["%(category_id)s"], first: 1) {
edges {
node {
name
@@ -283,7 +283,7 @@ def test_filter_products_by_collections(
collection.products.add(product)
query = """
query {
- products(collections: ["%(collection_id)s"]) {
+ products(collections: ["%(collection_id)s"], first: 1) {
edges {
node {
name
@@ -311,7 +311,7 @@ def test_sort_products(user_api_client, product):
query = """
query {
- products(sortBy: %(sort_by_product_order)s) {
+ products(sortBy: %(sort_by_product_order)s, first: 2) {
edges {
node {
price {
@@ -572,7 +572,7 @@ def test_delete_product(staff_api_client, product, permission_manage_products):
def test_product_type(user_api_client, product_type):
query = """
query {
- productTypes {
+ productTypes(first: 20) {
totalCount
edges {
node {
@@ -604,7 +604,7 @@ def test_product_type_query(
query getProductType($id: ID!) {
productType(id: $id) {
name
- products {
+ products(first: 20) {
totalCount
edges {
node {
@@ -1126,7 +1126,7 @@ def test_product_update_variants_names(mock__update_variants_names,
def test_product_variants_by_ids(user_api_client, variant):
query = """
query getProduct($ids: [ID!]) {
- productVariants(ids: $ids) {
+ productVariants(ids: $ids, first: 1) {
edges {
node {
id
@@ -1206,7 +1206,7 @@ def test_product_variant_price(
def test_stock_availability_filter(user_api_client, product):
query = """
query Products($stockAvailability: StockAvailability) {
- products(stockAvailability: $stockAvailability) {
+ products(stockAvailability: $stockAvailability, first: 1) {
totalCount
edges {
node {
@@ -1244,7 +1244,7 @@ def test_product_sales(
permission_manage_orders):
query = """
query TopProducts($period: ReportingPeriod!) {
- reportProductSales(period: $period) {
+ reportProductSales(period: $period, first: 20) {
edges {
node {
revenue(period: $period) {