Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Sometimes Int was assigned as price instead of Money instance
Pacu28741049b2f09
diff --git a/tests/api/test_shipping_method.py b/tests/api/test_shipping_method.pyindex 71a44de738..2ec0b3a359 100644--- a/tests/api/test_shipping_method.py+++ b/tests/api/test_shipping_method.py@@ -375,6 +375,6 @@ def test_delete_shipping_method(admin_api_client, shipping_method):content = get_graphql_content(response)assert 'errors' not in contentdata = content['data']['shippingPriceDelete']['shippingMethod']- assert data['price']['amount'] == float(shipping_method.price)+ assert data['price']['amount'] == float(shipping_method.price.amount)with pytest.raises(shipping_method._meta.model.DoesNotExist):shipping_method.refresh_from_db()diff --git a/tests/conftest.py b/tests/conftest.pyindex 41da55c9ef..f37c83b055 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -227,16 +227,18 @@ def shipping_zone(db): # pylint: disable=W0613shipping_zone = ShippingZone.objects.create(name='Europe', countries=[code for code, name in countries])shipping_zone.shipping_methods.create(- name='DHL', minimum_order_price=0, type=ShippingMethodType.PRICE_BASED,- price=10, shipping_zone=shipping_zone)+ name='DHL', minimum_order_price=Money(0, 'USD'),+ type=ShippingMethodType.PRICE_BASED, price=Money(10, 'USD'),+ shipping_zone=shipping_zone)return shipping_zone@pytest.fixturedef shipping_method(shipping_zone):return ShippingMethod.objects.create(- name='DHL', minimum_order_price=0, type=ShippingMethodType.PRICE_BASED,- price=10, shipping_zone=shipping_zone)+ name='DHL', minimum_order_price=Money(0, 'USD'),+ type=ShippingMethodType.PRICE_BASED,+ price=Money(10, 'USD'), shipping_zone=shipping_zone)@pytest.fixturediff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex 73b1d4c840..e039bb0cbf 100644--- a/tests/dashboard/test_order.py+++ b/tests/dashboard/test_order.py@@ -44,11 +44,12 @@ def test_ajax_order_shipping_methods_list_different_country(method = shipping_zone.shipping_methods.get()shipping_methods_list = [{'id': method.pk, 'text': method.get_ajax_label()}]- # If shipping zone does not cover order's country, then its shipping methods- # should not be included+ # If shipping zone does not cover order's country,+ # then its shipping methods should not be includedassert order.shipping_address.country.code != 'DE'zone = ShippingZone.objects.create(name='Shipping zone', countries=['DE'])- zone.shipping_methods.create(price=15, name='DHL')+ zone.shipping_methods.create(+ price=Money(15, settings.DEFAULT_CURRENCY), name='DHL')url = reverse('dashboard:ajax-order-shipping-methods', kwargs={'order_pk': order.pk})@@ -192,7 +193,8 @@ def test_view_refund_order_payment_confirmed('amount': str(payment_confirmed.captured_amount)})assert response.status_code == 302assert order.payments.last().status == PaymentStatus.REFUNDED- assert order.payments.last().get_captured_price() == Money(0, 'USD')+ assert order.payments.last().get_captured_price() == Money(+ 0, settings.DEFAULT_CURRENCY)@pytest.mark.integration@@ -779,7 +781,8 @@ def test_view_create_from_draft_order_not_draft_order(def test_view_create_from_draft_order_shipping_zone_not_valid(admin_client, draft_order, shipping_zone):- method = shipping_zone.shipping_methods.create(name='DHL', price=10)+ method = shipping_zone.shipping_methods.create(+ name='DHL', price=Money(10, settings.DEFAULT_CURRENCY))shipping_zone.countries = ['DE']shipping_zone.save()# Shipping zone is not valid, as shipping address is listed outside the@@ -940,7 +943,8 @@ def test_view_order_shipping_edit(def test_view_order_shipping_edit_not_draft_order(admin_client, order_with_lines, shipping_zone):- method = shipping_zone.shipping_methods.create(price=5, name='DHL')+ method = shipping_zone.shipping_methods.create(+ price=Money(5, settings.DEFAULT_CURRENCY), name='DHL')url = reverse('dashboard:order-shipping-edit',kwargs={'order_pk': order_with_lines.pk})diff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex 8b88d4f9c5..16b8bfd477 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -561,7 +561,8 @@ def test_view_variant_images(admin_client, product_with_image):def test_view_ajax_available_variants_list(admin_client, product, category):unavailable_product = Product.objects.create(- name='Test product', price=10, product_type=product.product_type,+ name='Test product', price=Money(10, settings.DEFAULT_CURRENCY),+ product_type=product.product_type,category=category, is_published=False)unavailable_product.variants.create()url = reverse('dashboard:ajax-available-variants')@@ -1031,8 +1032,8 @@ def test_product_form_assign_collection_to_product(product):def test_product_form_sanitize_product_description(product_type, category):product = Product.objects.create(- name='Test Product', price=10, description='', pk=10,- product_type=product_type, category=category)+ name='Test Product', price=Money(10, settings.DEFAULT_CURRENCY),+ description='', pk=10, product_type=product_type, category=category)data = model_to_dict(product)data['description'] = ('<b>bold</b><p><i>italic</i></p><h2>Header</h2><h3>subheader</h3>'diff --git a/tests/test_product.py b/tests/test_product.pyindex d02864993c..e1d313a625 100644--- a/tests/test_product.py+++ b/tests/test_product.py@@ -5,6 +5,7 @@ from unittest.mock import patchimport pytest+from django.conf import settingsfrom django.core import serializersfrom django.urls import reversefrom prices import Money, TaxedMoney, TaxedMoneyRange@@ -73,12 +74,12 @@ def test_filtering_by_attribute(db, color_attribute, category):name='New class', has_variants=True)product_type_b.variant_attributes.add(color_attribute)product_a = models.Product.objects.create(- name='Test product a', price=10, product_type=product_type_a,- category=category)+ name='Test product a', price=Money(10, settings.DEFAULT_CURRENCY),+ product_type=product_type_a, category=category)models.ProductVariant.objects.create(product=product_a, sku='1234')product_b = models.Product.objects.create(- name='Test product b', price=10, product_type=product_type_b,- category=category)+ name='Test product b', price=Money(10, settings.DEFAULT_CURRENCY),+ product_type=product_type_b, category=category)variant_b = models.ProductVariant.objects.create(product=product_b,sku='12345')color = color_attribute.values.first()diff --git a/tests/test_shipping.py b/tests/test_shipping.pyindex 72476e8a0f..4078e9e8a3 100644--- a/tests/test_shipping.py+++ b/tests/test_shipping.py@@ -110,7 +110,7 @@ def test_applicable_shipping_methods_inproper_shipping_method_type(type=ShippingMethodType.WEIGHT_BASED)weight_method = shipping_zone.shipping_methods.create(minimum_order_weight=Weight(kg=1), maximum_order_weight=Weight(kg=10),- minimum_order_price=1000, type=ShippingMethodType.PRICE_BASED)+ minimum_order_price=money(1000), type=ShippingMethodType.PRICE_BASED)result = ShippingMethod.objects.applicable_shipping_methods(price=money(5), weight=Weight(kg=5), country_code='PL')assert price_method not in result