Skip to content

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

Adjust tests to include default orderings on models

Marcin Gębala55263fe542f0
diff --git a/tests/api/pagination/test_account.py b/tests/api/pagination/test_account.py
index 33dcfde247..9620cfaef0 100644
--- a/tests/api/pagination/test_account.py
+++ b/tests/api/pagination/test_account.py
@@ -214,7 +214,7 @@ def customers_for_pagination(db):
({"field": "EMAIL", "direction": "ASC"}, ["John", "Leslie", "Joe"]),
({"field": "EMAIL", "direction": "DESC"}, ["Joe", "Leslie", "John"]),
({"field": "ORDER_COUNT", "direction": "ASC"}, ["John", "Leslie", "Joe"]),
- ({"field": "ORDER_COUNT", "direction": "DESC"}, ["Joe", "John", "Leslie"]),
+ ({"field": "ORDER_COUNT", "direction": "DESC"}, ["Joe", "Leslie", "John"]),
],
)
def test_query_customers_pagination_with_sort(
diff --git a/tests/api/pagination/test_account_service_account.py b/tests/api/pagination/test_account_service_account.py
index c4f7518b93..6868e34015 100644
--- a/tests/api/pagination/test_account_service_account.py
+++ b/tests/api/pagination/test_account_service_account.py
@@ -78,7 +78,7 @@ def test_attributes_pagination_with_sorting(
@pytest.mark.parametrize(
"filter_by, service_account_order",
[
- ({"search": "Account"}, ["Account1", "AccountAccount1"]),
+ ({"search": "Account"}, ["Account1", "Account2"]),
({"search": "AccountAccount"}, ["AccountAccount1", "AccountAccount2"]),
({"search": "accountaccount"}, ["AccountAccount1", "AccountAccount2"]),
({"search": "Account1"}, ["Account1", "AccountAccount1"]),
diff --git a/tests/api/pagination/test_attribute.py b/tests/api/pagination/test_attribute.py
index e43ff62a97..4fe1bc7943 100644
--- a/tests/api/pagination/test_attribute.py
+++ b/tests/api/pagination/test_attribute.py
@@ -144,10 +144,10 @@ def test_attributes_pagination_with_sorting(
@pytest.mark.parametrize(
"filter_by, attributes_order",
[
- ({"search": "AttrAttr"}, ["AttrAttr1", "AttrAttr2"]),
- ({"search": "attr_attr"}, ["AttrAttr1", "AttrAttr2"]),
- ({"search": "Attr1"}, ["Attr1", "AttrAttr1"]),
- ({"valueRequired": False}, ["Attr2", "Attr3"]),
+ ({"search": "AttrAttr"}, ["AttrAttr2", "AttrAttr1"]),
+ ({"search": "attr_attr"}, ["AttrAttr2", "AttrAttr1"]),
+ ({"search": "Attr1"}, ["AttrAttr1", "Attr1"]),
+ ({"valueRequired": False}, ["Attr3", "Attr2"]),
],
)
def test_attributes_pagination_with_filtering(
@@ -168,7 +168,7 @@ def test_attributes_pagination_with_filtering_in_collection(
staff_api_client, attributes_for_pagination, collection
):
page_size = 2
- attributes_order = ["Attr1", "Attr2"]
+ attributes_order = ["Attr3", "AttrAttr2"]
collection_id = graphene.Node.to_global_id("Collection", collection.id)
filter_by = {"inCollection": collection_id}
@@ -185,7 +185,7 @@ def test_attributes_pagination_with_filtering_in_category(
staff_api_client, attributes_for_pagination, category
):
page_size = 2
- attributes_order = ["Attr1", "Attr2"]
+ attributes_order = ["Attr3", "AttrAttr2"]
category_id = graphene.Node.to_global_id("Category", category.id)
filter_by = {"inCategory": category_id}
diff --git a/tests/api/pagination/test_discount.py b/tests/api/pagination/test_discount.py
index 446f61174c..07fe1ce4f6 100644
--- a/tests/api/pagination/test_discount.py
+++ b/tests/api/pagination/test_discount.py
@@ -80,9 +80,9 @@ QUERY_SALES_PAGINATION = """
({"field": "NAME", "direction": "ASC"}, ["Sale1", "Sale15", "Sale2"]),
({"field": "NAME", "direction": "DESC"}, ["Sale4", "Sale3", "Sale2"]),
({"field": "START_DATE", "direction": "ASC"}, ["Sale2", "Sale3", "Sale4"]),
- ({"field": "END_DATE", "direction": "ASC"}, ["Sale2", "Sale4", "Sale3"]),
+ ({"field": "END_DATE", "direction": "ASC"}, ["Sale2", "Sale4", "Sale15"]),
({"field": "VALUE", "direction": "ASC"}, ["Sale1", "Sale3", "Sale4"]),
- ({"field": "TYPE", "direction": "ASC"}, ["Sale2", "Sale4", "Sale15"]),
+ ({"field": "TYPE", "direction": "ASC"}, ["Sale15", "Sale2", "Sale4"]),
],
)
def test_sales_pagination_with_sorting(
@@ -114,10 +114,10 @@ def test_sales_pagination_with_sorting(
[
({"status": "SCHEDULED"}, ["Sale1", "Sale15"]),
({"status": "ACTIVE"}, ["Sale2", "Sale3"]),
- ({"saleType": "FIXED"}, ["Sale2", "Sale4"]),
+ ({"saleType": "FIXED"}, ["Sale15", "Sale2"]),
({"saleType": "PERCENTAGE"}, ["Sale1", "Sale3"]),
({"started": {"gte": "2020-03-18T13:00:00+00:00"}}, ["Sale1", "Sale15"]),
- ({"started": {"lte": "2020-03-18T13:00:00+00:00"}}, ["Sale2", "Sale3"]),
+ ({"started": {"lte": "2020-03-18T13:00:00+00:00"}}, ["Sale15", "Sale2"]),
],
)
@freeze_time("2020-03-18 12:15:00")
@@ -244,7 +244,7 @@ QUERY_VOUCHERS_PAGINATION = """
["Voucher2", "Voucher4", "Voucher3"],
),
({"field": "VALUE", "direction": "ASC"}, ["Voucher1", "Voucher15", "Voucher3"]),
- ({"field": "TYPE", "direction": "ASC"}, ["Voucher2", "Voucher3", "Voucher15"]),
+ ({"field": "TYPE", "direction": "ASC"}, ["Voucher15", "Voucher2", "Voucher3"]),
(
{"field": "USAGE_LIMIT", "direction": "ASC"},
["Voucher1", "Voucher15", "Voucher3"],
@@ -285,11 +285,11 @@ def test_vouchers_pagination_with_sorting(
({"status": "SCHEDULED"}, ["Voucher1", "Voucher15"]),
({"status": "ACTIVE"}, ["Voucher2", "Voucher3"]),
({"timesUsed": {"gte": 1}}, ["Voucher2", "Voucher3"]),
- ({"timesUsed": {"lte": 1}}, ["Voucher1", "Voucher4"]),
+ ({"timesUsed": {"lte": 1}}, ["Voucher1", "Voucher15"]),
({"discountType": "FIXED"}, ["Voucher2", "Voucher4"]),
- ({"discountType": "PERCENTAGE"}, ["Voucher1", "Voucher3"]),
+ ({"discountType": "PERCENTAGE"}, ["Voucher1", "Voucher15"]),
({"started": {"gte": "2020-03-18T13:00:00+00:00"}}, ["Voucher1", "Voucher15"]),
- ({"started": {"lte": "2020-03-18T13:00:00+00:00"}}, ["Voucher2", "Voucher3"]),
+ ({"started": {"lte": "2020-03-18T13:00:00+00:00"}}, ["Voucher15", "Voucher2"]),
],
)
@freeze_time("2020-03-18 12:15:00")
diff --git a/tests/api/pagination/test_product.py b/tests/api/pagination/test_product.py
index f2fbf5d10f..29d2485d52 100644
--- a/tests/api/pagination/test_product.py
+++ b/tests/api/pagination/test_product.py
@@ -21,13 +21,14 @@ from ..utils import get_graphql_content
def categories_for_pagination(product_type):
categories = Category.tree.build_tree_nodes(
{
+ "id": 1,
"name": "Category2",
"slug": "cat1",
"children": [
- {"name": "CategoryCategory1", "slug": "cat_cat1"},
- {"name": "CategoryCategory2", "slug": "cat_cat2"},
- {"name": "Category1", "slug": "cat2"},
- {"name": "Category3", "slug": "cat3"},
+ {"parent_id": 1, "name": "CategoryCategory1", "slug": "cat_cat1"},
+ {"parent_id": 1, "name": "CategoryCategory2", "slug": "cat_cat2"},
+ {"parent_id": 1, "name": "Category1", "slug": "cat2"},
+ {"parent_id": 1, "name": "Category3", "slug": "cat3"},
],
}
)
@@ -100,11 +101,11 @@ QUERY_CATEGORIES_PAGINATION = """
),
(
{"field": "SUBCATEGORY_COUNT", "direction": "ASC"},
- ["Category2", "CategoryCategory1", "CategoryCategory2"],
+ ["Category1", "Category3", "CategoryCategory1"],
),
(
{"field": "PRODUCT_COUNT", "direction": "ASC"},
- ["CategoryCategory1", "Category1", "CategoryCategory2"],
+ ["Category1", "CategoryCategory1", "CategoryCategory2"],
),
],
)
@@ -177,9 +178,9 @@ QUERY_COLLECTIONS_PAGINATION = """
edges {
node {
name
- products{
- totalCount
- }
+ products{
+ totalCount
+ }
}
}
pageInfo{
@@ -206,11 +207,11 @@ QUERY_COLLECTIONS_PAGINATION = """
),
(
{"field": "AVAILABILITY", "direction": "ASC"},
- ["CollectionCollection2", "Collection2", "Collection1"],
+ ["Collection2", "CollectionCollection2", "Collection1"],
),
(
{"field": "PRODUCT_COUNT", "direction": "DESC"},
- ["Collection3", "CollectionCollection2", "Collection1"],
+ ["CollectionCollection2", "Collection3", "CollectionCollection1"],
),
],
)
@@ -401,11 +402,11 @@ QUERY_PRODUCTS_PAGINATION = """
),
(
{"field": "TYPE", "direction": "ASC"},
- ["Product1", "ProductProduct2", "Product3"],
+ ["Product1", "Product3", "ProductProduct2"],
),
(
{"field": "PUBLISHED", "direction": "ASC"},
- ["ProductProduct1", "Product2", "Product1"],
+ ["Product2", "ProductProduct1", "Product1"],
),
],
)
@@ -633,11 +634,11 @@ QUERY_PRODUCT_TYPES_PAGINATION = """
),
(
{"field": "DIGITAL", "direction": "ASC"},
- ["ProductTypeProductType1", "ProductTypeProductType2", "ProductType2"],
+ ["ProductType2", "ProductTypeProductType1", "ProductTypeProductType2"],
),
(
{"field": "SHIPPING_REQUIRED", "direction": "ASC"},
- ["ProductType1", "ProductTypeProductType1", "ProductType3"],
+ ["ProductType1", "ProductType3", "ProductTypeProductType1"],
),
],
)
diff --git a/tests/api/pagination/test_warehouse.py b/tests/api/pagination/test_warehouse.py
index 053408db88..c3e7033403 100644
--- a/tests/api/pagination/test_warehouse.py
+++ b/tests/api/pagination/test_warehouse.py
@@ -83,9 +83,9 @@ def test_warehouses_pagination_with_sorting(
[
(
{"search": "WarehouseWarehouse"},
- ["WarehouseWarehouse1", "WarehouseWarehouse2"],
+ ["WarehouseWarehouse2", "WarehouseWarehouse1"],
),
- ({"search": "Warehouse1"}, ["Warehouse1", "WarehouseWarehouse1"]),
+ ({"search": "Warehouse1"}, ["WarehouseWarehouse1", "Warehouse1"]),
],
)
def test_warehouses_pagination_with_filtering(
@@ -112,7 +112,7 @@ def test_warehouses_pagination_with_filtering_by_id(
staff_api_client, permission_manage_products, warehouses_for_pagination,
):
page_size = 2
- warehouses_order = ["Warehouse1", "Warehouse2"]
+ warehouses_order = ["WarehouseWarehouse2", "WarehouseWarehouse1"]
warehouses_ids = [
graphene.Node.to_global_id("Warehouse", warehouse.pk)
for warehouse in warehouses_for_pagination
diff --git a/tests/api/pagination/test_webhook.py b/tests/api/pagination/test_webhook.py
index 1b18f7e3ba..fa99989cd0 100644
--- a/tests/api/pagination/test_webhook.py
+++ b/tests/api/pagination/test_webhook.py
@@ -83,7 +83,7 @@ QUERY_WEBHOOKS_PAGINATION = """
),
(
{"field": "SERVICE_ACCOUNT", "direction": "ASC"},
- ["Webhook3", "WebhookWebhook1", "Webhook2"],
+ ["Webhook3", "WebhookWebhook1", "Webhook1"],
),
(
{"field": "TARGET_URL", "direction": "ASC"},
diff --git a/tests/api/test_plugins.py b/tests/api/test_plugins.py
index 77d1a7b2bd..80d64ffe6b 100644
--- a/tests/api/test_plugins.py
+++ b/tests/api/test_plugins.py
@@ -427,7 +427,7 @@ QUERY_PLUGIN_WITH_SORT = """
),
(
{"field": "IS_ACTIVE", "direction": "DESC"},
- ["PluginSample", "Active", "PluginInactive"],
+ ["Active", "PluginSample", "PluginInactive"],
),
],
)