Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add tests for ignoring cancelled fulfillment in me API
Unknown5fee4eaeec96
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6ac1a9201c..7fae19ff2c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -33,7 +33,6 @@ All notable, unreleased changes to this project will be documented in this file.- Add json fields to models for content/description - #3756 by @michaljelonek- Fix storefront styles after bootstrap is updated to 4.3.1 - #3753 by @jxltom- Fix logo size in different browser and devices with different sizes - #3722 by @jxltom-- Do not return cancelled fulfillments in me API - #3778 by @jxltom## 2.3.0diff --git a/tests/api/test_account.py b/tests/api/test_account.pyindex 464797ef22..da273dca62 100644--- a/tests/api/test_account.py+++ b/tests/api/test_account.py@@ -12,6 +12,7 @@ from saleor.account.models import Address, Userfrom saleor.graphql.account.mutations import (CustomerDelete, SetPassword, StaffDelete, StaffUpdate, UserDelete)from saleor.graphql.core.enums import PermissionEnum+from saleor.order.models import FulfillmentStatusfrom tests.api.utils import get_graphql_contentfrom .utils import assert_no_permission, convert_dict_keys_to_camel_case@@ -321,6 +322,71 @@ def test_me_query_checkout(user_api_client, cart):assert data['checkout']['token'] == str(cart.token)+def test_me_with_cancelled_fulfillments(+ user_api_client, fulfilled_order_with_cancelled_fulfillment):+ query = """+ query Me {+ me {+ orders (first: 1) {+ edges {+ node {+ id+ fulfillments {+ status+ }+ }+ }+ }+ }+ }+ """+ response = user_api_client.post_graphql(query)+ content = get_graphql_content(response)+ order_id = graphene.Node.to_global_id(+ 'Order', fulfilled_order_with_cancelled_fulfillment.id)+ data = content['data']['me']+ order = data['orders']['edges'][0]['node']+ assert order['id'] == order_id+ fulfillments = order['fulfillments']+ assert len(fulfillments) == 1+ assert fulfillments[0]['status'] == FulfillmentStatus.FULFILLED.upper()+++def test_user_with_cancelled_fulfillments(+ staff_api_client, customer_user, permission_manage_users,+ fulfilled_order_with_cancelled_fulfillment):+ query = """+ query User($id: ID!) {+ user(id: $id) {+ orders (first: 1) {+ edges {+ node {+ id+ fulfillments {+ status+ }+ }+ }+ }+ }+ }+ """+ user_id = graphene.Node.to_global_id('User', customer_user.id)+ variables = {'id': user_id}+ staff_api_client.user.user_permissions.add(permission_manage_users)+ response = staff_api_client.post_graphql(query, variables)+ content = get_graphql_content(response)+ order_id = graphene.Node.to_global_id(+ 'Order', fulfilled_order_with_cancelled_fulfillment.id)+ data = content['data']['user']+ order = data['orders']['edges'][0]['node']+ assert order['id'] == order_id+ fulfillments = order['fulfillments']+ assert len(fulfillments) == 2+ assert fulfillments[0]['status'] == FulfillmentStatus.FULFILLED.upper()+ assert fulfillments[1]['status'] == FulfillmentStatus.CANCELED.upper()++def test_customer_register(user_api_client):query = """mutation RegisterCustomer($password: String!, $email: String!) {diff --git a/tests/conftest.py b/tests/conftest.pyindex ed3c697186..2f611bc89f 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -26,7 +26,7 @@ from saleor.discount import VoucherTypefrom saleor.discount.models import Sale, Voucher, VoucherTranslationfrom saleor.menu.models import Menu, MenuItemfrom saleor.order import OrderEvents, OrderStatus-from saleor.order.models import Order, OrderEvent+from saleor.order.models import FulfillmentStatus, Order, OrderEventfrom saleor.order.utils import recalculate_orderfrom saleor.page.models import Pagefrom saleor.payment import ChargeStatus, TransactionKind@@ -552,6 +552,18 @@ def fulfilled_order(order_with_lines):return order+def fulfilled_order_with_cancelled_fulfillment(fulfilled_order):+ fulfillment = fulfilled_order.fulfillments.create()+ line_1 = fulfilled_order.lines.first()+ line_2 = fulfilled_order.lines.last()+ fulfillment.lines.create(order_line=line_1, quantity=line_1.quantity)+ fulfillment.lines.create(order_line=line_2, quantity=line_2.quantity)+ fulfillment.status = FulfillmentStatus.CANCELED+ fulfillment.save()+ return fulfilled_order++@pytest.fixturedef fulfillment(fulfilled_order):return fulfilled_order.fulfillments.first()