Skip to content

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

Update tests

akjanika75ae0f96234
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
index 86fd157c6a..30a669a359 100644
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@ -50,7 +50,8 @@ class OrderLine(DjangoObjectType):
class Meta:
description = 'Represents order line of particular order.'
model = models.OrderLine
- exclude_fields = ['variant', 'unit_price_gross', 'unit_price_net']
+ exclude_fields = [
+ 'variant', 'unit_price_gross', 'unit_price_net', 'order']
class OrderNote(DjangoObjectType):
@@ -63,6 +64,7 @@ class Fulfillment(DjangoObjectType):
class Meta:
description = 'Represents order fulfillment.'
model = models.Fulfillment
+ exclude_fields = ['order']
class FulfillmentLine(DjangoObjectType):
diff --git a/tests/api/test_order.py b/tests/api/test_order.py
index 404f8bae7b..06c084b296 100644
--- a/tests/api/test_order.py
+++ b/tests/api/test_order.py
@@ -5,7 +5,7 @@ from django.shortcuts import reverse
from tests.utils import get_graphql_content
-def test_order_query(admin_api_client, order_with_lines):
+def test_order_query(admin_api_client, fulfilled_order):
query = """
query OrdersQuery {
orders(first: 1) {
@@ -13,7 +13,11 @@ def test_order_query(admin_api_client, order_with_lines):
node {
orderId
status
+ statusDisplay
+ paymentStatus
+ paymentStatusDisplay
userEmail
+ isPaid
shippingPrice {
gross {
amount
@@ -25,6 +29,12 @@ def test_order_query(admin_api_client, order_with_lines):
notes {
content
}
+ fulfillments {
+ fulfillmentOrder
+ }
+ history {
+ content
+ }
}
}
}
@@ -35,15 +45,24 @@ def test_order_query(admin_api_client, order_with_lines):
content = get_graphql_content(response)
assert 'errors' not in content
order_data = content['data']['orders']['edges'][0]['node']
- assert order_data['orderId'] == order_with_lines.pk
- assert order_data['status'] == order_with_lines.status.upper()
- assert order_data['userEmail'] == order_with_lines.user_email
+ assert order_data['orderId'] == fulfilled_order.pk
+ assert order_data['status'] == fulfilled_order.status.upper()
+ assert order_data['statusDisplay'] == fulfilled_order.get_status_display()
+ assert order_data[
+ 'paymentStatus'] == fulfilled_order.get_last_payment_status()
+ payment_status_display = fulfilled_order.get_last_payment_status_display()
+ assert order_data['paymentStatusDisplay'] == payment_status_display
+ assert order_data['isPaid'] == fulfilled_order.is_fully_paid()
+ assert order_data['userEmail'] == fulfilled_order.user_email
assert order_data[
'shippingPrice'][
'gross'][
- 'amount'] == order_with_lines.shipping_price.gross.amount
- assert len(order_data['lines']) == order_with_lines.lines.count()
- assert len(order_data['notes']) == order_with_lines.notes.count()
+ 'amount'] == fulfilled_order.shipping_price.gross.amount
+ assert len(order_data['lines']) == fulfilled_order.lines.count()
+ assert len(order_data['notes']) == fulfilled_order.notes.count()
+ fulfillment_order = fulfilled_order.fulfillments.first().fulfillment_order
+ assert order_data[
+ 'fulfillments'][0]['fulfillmentOrder'] == fulfillment_order
def test_non_staff_user_can_only_see_his_order(user_api_client, order):