Skip to content

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

Fix tests

Pacu2af8a236ce7a1
diff --git a/saleor/order/__init__.py b/saleor/order/__init__.py
index 40bde7ec5b..ebbed6b769 100644
--- a/saleor/order/__init__.py
+++ b/saleor/order/__init__.py
@@ -112,12 +112,11 @@ def get_money_from_params(amount):
Can be safely removed after migrating to Dashboard 2.0
"""
- money_amount = amount
- money_currency = settings.DEFAULT_CURRENCY
+ if isinstance(amount, Money):
+ return amount
if isinstance(amount, dict):
- money_amount = amount['amount']
- money_currency = amount['currency']
- return Money(amount=money_amount, currency=money_currency)
+ return Money(amount=amount['amount'], currency=amount['currency'])
+ return Money(amount, settings.DEFAULT_CURRENCY)
def display_order_event(order_event):
diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.py
index e372fc6079..1843611c17 100644
--- a/tests/dashboard/test_order.py
+++ b/tests/dashboard/test_order.py
@@ -1,11 +1,12 @@
import json
import pytest
-
from django.conf import settings
from django.urls import reverse
from payments import PaymentStatus
from prices import Money
+from tests.utils import get_form_errors, get_redirect_location
+
from saleor.checkout import AddressType
from saleor.core.utils.taxes import ZERO_MONEY, ZERO_TAXED_MONEY
from saleor.dashboard.order.forms import ChangeQuantityForm
@@ -15,11 +16,10 @@ from saleor.dashboard.order.utils import (
from saleor.discount.utils import increase_voucher_usage
from saleor.order import (
FulfillmentStatus, OrderEvents, OrderEventsEmails, OrderStatus)
-from saleor.order.models import Order, OrderLine, OrderEvent
+from saleor.order.models import Order, OrderEvent, OrderLine
from saleor.order.utils import add_variant_to_order, change_order_line_quantity
from saleor.product.models import ProductVariant
from saleor.shipping.models import ShippingZone
-from tests.utils import get_form_errors, get_redirect_location
def test_ajax_order_shipping_methods_list(
@@ -1232,7 +1232,7 @@ def test_order_event_display(admin_user, type, order):
'quantity': 12,
'email_type': OrderEventsEmails.PAYMENT.value,
'email': '[email protected]',
- 'amount': json.dumps(Money(80, 'USD')),
+ 'amount': {'_type': 'Money', 'amount': '10.00', 'currency': 'USD'},
'composed_id': 12,
'tracking_number': '5421AB',
'oversold_items': ['Blue Shirt', 'Red Shirt']}