Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Skip turned off tests instead of commenting them
Michał Sipa699882ac8946
diff --git a/tests/api/pagination/test_core.py b/tests/api/pagination/test_core.pyindex d260d30227..92442b32ad 100644--- a/tests/api/pagination/test_core.py+++ b/tests/api/pagination/test_core.py@@ -139,43 +139,48 @@ def test_pagination_forward_first_page_info(books):assert page_info["hasPreviousPage"] is False-# Currently, page info has the bug, new pagination fixing it.-# We should uncomment this test in PR #5149.-# def test_pagination_forward_middle_page_info(books):-# page_size = 5--# variables = {"first": page_size, "after": None}-# result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)-# assert not result.errors-# content = result.data-# end_cursor = content["books"]["pageInfo"]["endCursor"]--# variables = {"first": page_size, "after": end_cursor}-# result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)-# assert not result.errors-# content = result.data-# page_info = content["books"]["pageInfo"]-# assert page_info["hasNextPage"]-# assert page_info["hasPreviousPage"]--# Currently, page info has the bug, new pagination fixing it.-# We should uncomment this test in PR #5149.-# def test_pagination_forward_last_page_info(books):-# page_size = 20--# variables = {"first": page_size, "after": None}-# result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)-# assert not result.errors-# content = result.data-# end_cursor = content["books"]["pageInfo"]["endCursor"]--# variables = {"first": page_size, "after": end_cursor}-# result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)-# assert not result.errors-# content = result.data-# page_info = content["books"]["pageInfo"]-# assert page_info["hasNextPage"] is False-# assert page_info["hasPreviousPage"]+ reason="""Currently, page info has the bug, new pagination fixing it.+ We should uncomment this test in PR #5149."""+)+def test_pagination_forward_middle_page_info(books):+ page_size = 5++ variables = {"first": page_size, "after": None}+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)+ assert not result.errors+ content = result.data+ end_cursor = content["books"]["pageInfo"]["endCursor"]++ variables = {"first": page_size, "after": end_cursor}+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)+ assert not result.errors+ content = result.data+ page_info = content["books"]["pageInfo"]+ assert page_info["hasNextPage"]+ assert page_info["hasPreviousPage"]+++ reason="""Currently, page info has the bug, new pagination fixing it.+ We should uncomment this test in PR #5149."""+)+def test_pagination_forward_last_page_info(books):+ page_size = 20++ variables = {"first": page_size, "after": None}+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)+ assert not result.errors+ content = result.data+ end_cursor = content["books"]["pageInfo"]["endCursor"]++ variables = {"first": page_size, "after": end_cursor}+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)+ assert not result.errors+ content = result.data+ page_info = content["books"]["pageInfo"]+ assert page_info["hasNextPage"] is False+ assert page_info["hasPreviousPage"]def test_pagination_backward_first_page_info(books):@@ -188,40 +193,45 @@ def test_pagination_backward_first_page_info(books):assert page_info["hasPreviousPage"]-# Currently, page info has the bug, new pagination fixing it.-# We should uncomment this test in PR #5149.-# def test_pagination_backward_middle_page_info(books):-# page_size = 5--# variables = {"last": 5, "before": None}-# result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)-# assert not result.errors-# content = result.data-# start_cursor = content["books"]["pageInfo"]["startCursor"]--# variables = {"last": page_size, "before": start_cursor}-# result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)-# assert not result.errors-# content = result.data-# page_info = content["books"]["pageInfo"]-# assert page_info["hasNextPage"]-# assert page_info["hasPreviousPage"]--# Currently, page info has the bug, new pagination fixing it.-# We should uncomment this test in PR #5149.-# def test_pagination_backward_last_page_info(books):-# page_size = 20--# variables = {"last": page_size, "before": None}-# result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)-# assert not result.errors-# content = result.data-# start_cursor = content["books"]["pageInfo"]["startCursor"]--# variables = {"last": page_size, "before": start_cursor}-# result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)-# assert not result.errors-# content = result.data-# page_info = content["books"]["pageInfo"]-# assert page_info["hasNextPage"]-# assert page_info["hasPreviousPage"] is False+ reason="""Currently, page info has the bug, new pagination fixing it.+ We should uncomment this test in PR #5149."""+)+def test_pagination_backward_middle_page_info(books):+ page_size = 5++ variables = {"last": 5, "before": None}+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)+ assert not result.errors+ content = result.data+ start_cursor = content["books"]["pageInfo"]["startCursor"]++ variables = {"last": page_size, "before": start_cursor}+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)+ assert not result.errors+ content = result.data+ page_info = content["books"]["pageInfo"]+ assert page_info["hasNextPage"]+ assert page_info["hasPreviousPage"]+++ reason="""Currently, page info has the bug, new pagination fixing it.+ We should uncomment this test in PR #5149."""+)+def test_pagination_backward_last_page_info(books):+ page_size = 20++ variables = {"last": page_size, "before": None}+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)+ assert not result.errors+ content = result.data+ start_cursor = content["books"]["pageInfo"]["startCursor"]++ variables = {"last": page_size, "before": start_cursor}+ result = schema.execute(QUERY_PAGINATION_TEST, variables=variables)+ assert not result.errors+ content = result.data+ page_info = content["books"]["pageInfo"]+ assert page_info["hasNextPage"]+ assert page_info["hasPreviousPage"] is Falsediff --git a/tests/api/pagination/test_order.py b/tests/api/pagination/test_order.pyindex a3db02a09e..79c0fd333e 100644--- a/tests/api/pagination/test_order.py+++ b/tests/api/pagination/test_order.py@@ -525,64 +525,67 @@ def test_draft_orders_query_pagination_with_filter_search_by_id(# Currently sorting is not working properly for orders.-# We should uncomment this test after fixing-# @pytest.mark.parametrize(-# "order_sort, result_order",-# [-# ({"field": "NUMBER", "direction": "ASC"}, [0, 1, 2]),-# ({"field": "NUMBER", "direction": "DESC"}, [2, 1, 0]),-# ({"field": "CREATION_DATE", "direction": "ASC"}, [1, 0, 2]),-# ({"field": "CREATION_DATE", "direction": "DESC"}, [2, 0, 1]),-# ({"field": "CUSTOMER", "direction": "ASC"}, [2, 0, 1]),-# ({"field": "CUSTOMER", "direction": "DESC"}, [1, 0, 2]),-# ({"field": "FULFILLMENT_STATUS", "direction": "ASC"}, [2, 1, 0]),-# ({"field": "FULFILLMENT_STATUS", "direction": "DESC"}, [0, 1, 2]),-# ({"field": "TOTAL", "direction": "ASC"}, [0, 2, 1]),-# ({"field": "TOTAL", "direction": "DESC"}, [1, 2, 0]),-# ],-# )-# def test_query_orders_pagination_with_sort(-# order_sort, result_order, staff_api_client, permission_manage_orders, address-# ):-# created_orders = []-# with freeze_time("2017-01-14"):-# created_orders.append(-# Order.objects.create(-# token=str(uuid.uuid4()),-# billing_address=address,-# status=OrderStatus.PARTIALLY_FULFILLED,-# total=TaxedMoney(net=Money(10, "USD"), gross=Money(13, "USD")),-# )-# )-# with freeze_time("2012-01-14"):-# address2 = address.get_copy()-# address2.first_name = "Walter"-# address2.save()-# created_orders.append(-# Order.objects.create(-# token=str(uuid.uuid4()),-# billing_address=address2,-# status=OrderStatus.FULFILLED,-# total=TaxedMoney(net=Money(100, "USD"), gross=Money(130, "USD")),-# )-# )-# address3 = address.get_copy()-# address3.last_name = "Alice"-# address3.save()-# created_orders.append(-# Order.objects.create(-# token=str(uuid.uuid4()),-# billing_address=address3,-# status=OrderStatus.CANCELED,-# total=TaxedMoney(net=Money(20, "USD"), gross=Money(26, "USD")),-# )-# )-# page_size = 2-# variables = {"first": page_size, "after": None, "sort_by": order_sort}-# staff_api_client.user.user_permissions.add(permission_manage_orders)-# response = staff_api_client.post_graphql(QUERY_ORDERS_WITH_PAGINATION, variables)-# content = get_graphql_content(response)-# orders = content["data"]["orders"]["edges"]--# for order, order_number in enumerate(result_order):-# assert orders[order]["node"]["number"] == str(created_orders[order_number].pk)+ reason="""Currently sorting is not working properly for orders.+Turn on this test after merging #5149"""+)+ "order_sort, result_order",+ [+ ({"field": "NUMBER", "direction": "ASC"}, [0, 1, 2]),+ ({"field": "NUMBER", "direction": "DESC"}, [2, 1, 0]),+ ({"field": "CREATION_DATE", "direction": "ASC"}, [1, 0, 2]),+ ({"field": "CREATION_DATE", "direction": "DESC"}, [2, 0, 1]),+ ({"field": "CUSTOMER", "direction": "ASC"}, [2, 0, 1]),+ ({"field": "CUSTOMER", "direction": "DESC"}, [1, 0, 2]),+ ({"field": "FULFILLMENT_STATUS", "direction": "ASC"}, [2, 1, 0]),+ ({"field": "FULFILLMENT_STATUS", "direction": "DESC"}, [0, 1, 2]),+ ({"field": "TOTAL", "direction": "ASC"}, [0, 2, 1]),+ ({"field": "TOTAL", "direction": "DESC"}, [1, 2, 0]),+ ],+)+def test_query_orders_pagination_with_sort(+ order_sort, result_order, staff_api_client, permission_manage_orders, address+):+ created_orders = []+ with freeze_time("2017-01-14"):+ created_orders.append(+ Order.objects.create(+ token=str(uuid.uuid4()),+ billing_address=address,+ status=OrderStatus.PARTIALLY_FULFILLED,+ total=TaxedMoney(net=Money(10, "USD"), gross=Money(13, "USD")),+ )+ )+ with freeze_time("2012-01-14"):+ address2 = address.get_copy()+ address2.first_name = "Walter"+ address2.save()+ created_orders.append(+ Order.objects.create(+ token=str(uuid.uuid4()),+ billing_address=address2,+ status=OrderStatus.FULFILLED,+ total=TaxedMoney(net=Money(100, "USD"), gross=Money(130, "USD")),+ )+ )+ address3 = address.get_copy()+ address3.last_name = "Alice"+ address3.save()+ created_orders.append(+ Order.objects.create(+ token=str(uuid.uuid4()),+ billing_address=address3,+ status=OrderStatus.CANCELED,+ total=TaxedMoney(net=Money(20, "USD"), gross=Money(26, "USD")),+ )+ )+ page_size = 2+ variables = {"first": page_size, "after": None, "sort_by": order_sort}+ staff_api_client.user.user_permissions.add(permission_manage_orders)+ response = staff_api_client.post_graphql(QUERY_ORDERS_WITH_PAGINATION, variables)+ content = get_graphql_content(response)+ orders = content["data"]["orders"]["edges"]++ for order, order_number in enumerate(result_order):+ assert orders[order]["node"]["number"] == str(created_orders[order_number].pk)diff --git a/tests/api/pagination/test_warehouse.py b/tests/api/pagination/test_warehouse.pyindex cf4b9b309b..053408db88 100644--- a/tests/api/pagination/test_warehouse.py+++ b/tests/api/pagination/test_warehouse.py@@ -19,7 +19,6 @@ def warehouses_for_pagination(db, address):)-# After fix #5410 we should remove `id` from requested fields.QUERY_WAREHOUSES_PAGINATION = """query ($first: Int, $last: Int, $after: String, $before: String,