Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Tests
Pacu2fd2f01889ff0
diff --git a/saleor/checkout/utils.py b/saleor/checkout/utils.pyindex 7d61779917..9a5d213a5a 100644--- a/saleor/checkout/utils.py+++ b/saleor/checkout/utils.py@@ -766,10 +766,12 @@ def check_shipping_method(cart):country_code = cart.shipping_address.country.code# There should be only one ShippingZone per countryvalid_shipping_zone = ShippingZone.objects.filter(- countries__contains=country_code).get()- if (+ countries__contains=country_code).first()++ shipping_method_not_applicable = (cart.shipping_method and- cart.shipping_method.shipping_zone.get() != valid_shipping_zone):+ cart.shipping_method.shipping_zone != valid_shipping_zone)+ if not valid_shipping_zone or shipping_method_not_applicable:cart.shipping_method = Nonecart.save()return Falsediff --git a/saleor/checkout/views/__init__.py b/saleor/checkout/views/__init__.pyindex d1e6b92378..f8d6a5979f 100644--- a/saleor/checkout/views/__init__.py+++ b/saleor/checkout/views/__init__.py@@ -69,7 +69,6 @@ def checkout_shipping_method(request, cart):form = CartShippingRateForm(request.POST or None, taxes=taxes, instance=cart,initial={'shipping_method': cart.shipping_method})- import pdb; pdb.set_trace()if form.is_valid():form.save()return redirect('checkout:summary')diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex b222ead548..2326565f32 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -9,7 +9,7 @@ from django.conf import settingsfrom django.contrib.sites.models import Sitefrom django.core.files import Filefrom django.template.defaultfilters import slugify-from django_countries import countries+from django_countries import countries as django_countriesfrom django_countries.fields import Countryfrom faker import Factoryfrom faker.providers import BaseProvider@@ -34,7 +34,7 @@ from ...product.models import (from ...product.thumbnails import create_product_thumbnailsfrom ...product.utils.attributes import get_name_from_attributesfrom ...shipping.models import (- ANY_COUNTRY, ShippingMethod, ShippingRate, ShippingZone)+ ANY_COUNTRY, ShippingRate, ShippingZone)from ...shipping.utils import get_taxed_shipping_pricefake = Factory.create()@@ -248,7 +248,7 @@ class SaleorProvider(BaseProvider):return random.choice(DELIVERY_REGIONS)def shipping_method(self):- return random.choice(ShippingMethod.objects.all())+ return random.choice(ShippingRate.objects.all())fake.add_provider(SaleorProvider)@@ -457,8 +457,8 @@ def create_fake_order(discounts, taxes):'user_email': get_email(address.first_name, address.last_name)}- shipping_method = ShippingMethod.objects.order_by('?').first()- shipping_price = shipping_method.price_per_country.first().price+ shipping_method = ShippingRate.objects.order_by('?').first()+ shipping_price = shipping_method.priceshipping_price = get_taxed_shipping_price(shipping_price, taxes)order_data.update({'shipping_method_name': shipping_method.name,@@ -510,29 +510,21 @@ def create_product_sales(how_many=5):def create_shipping_methods():- django_countries = [code for code, name in countries]+ countries = [code for code, name in django_countries]shipping_zone = ShippingZone.objects.create(- name='European countries', countries=django_countries[::2])- #FIXME we should make sure that no country will be placed in two ShippingZones-+ name='European countries', countries=countries[::2])for i in range(4):ShippingRate.objects.create(shipping_zone=shipping_zone,name=fake.company(),price=fake.money())shipping_zone = ShippingZone.objects.create(- name='European countries', countries=django_countries[1::2])+ name='European countries', countries=countries[1::2])for i in range(4):ShippingRate.objects.create(shipping_zone=shipping_zone,name=fake.company(),price=fake.money())- shipping_method = ShippingMethod.objects.create(name='UPC')- shipping_method.price_per_country.create(price=fake.money())- yield 'Shipping method #%d' % shipping_method.id- shipping_method = ShippingMethod.objects.create(name='DHL')- shipping_method.price_per_country.create(price=fake.money())- yield 'Shipping method #%d' % shipping_method.iddef create_vouchers():diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex 7e1827fa5f..da63b34c41 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -59,8 +59,7 @@ class CreateOrderFromDraftForm(forms.ModelForm):shipping_address = self.instance.shipping_addressshipping_not_valid = (method and shipping_address and- method.country_code != ANY_COUNTRY and- shipping_address.country.code != method.country_code)+ shipping_address.country.code not in method.shipping_zone.countries)if shipping_not_valid:errors.append(forms.ValidationError(pgettext_lazy('Create draft order form error',diff --git a/saleor/shipping/models.py b/saleor/shipping/models.pyindex 688228875d..be4711e74d 100644--- a/saleor/shipping/models.py+++ b/saleor/shipping/models.py@@ -64,6 +64,11 @@ class ShippingRate(models.Model):def get_total_price(self, taxes=None):return get_taxed_shipping_price(self.price, taxes)+ def get_ajax_label(self):+ price_html = format_money(self.price)+ label = mark_safe('%s %s' % (self, price_html))+ return label+class ShippingMethod(models.Model):diff --git a/tests/api/test_order.py b/tests/api/test_order.pyindex 639ed27612..a8d6be80c5 100644--- a/tests/api/test_order.py+++ b/tests/api/test_order.py@@ -163,7 +163,7 @@ def test_draft_order_create(shipping_address = {'firstName': 'John', 'country': 'PL'}shipping_id = graphene.Node.to_global_id(- 'ShippingMethodCountry', shipping_price.id)+ 'ShippingRate', shipping_price.id)voucher_id = graphene.Node.to_global_id('Voucher', voucher.id)variables = json.dumps({diff --git a/tests/api/test_shipping_method.py b/tests/api/test_shipping_method.pyindex 77c6049297..31eadfc956 100644--- a/tests/api/test_shipping_method.py+++ b/tests/api/test_shipping_method.py@@ -32,7 +32,7 @@ def test_shipping_method_query(user_api_client, shipping_method):}"""- ID = graphene.Node.to_global_id('ShippingMethod', shipping.id)+ ID = graphene.Node.to_global_id('ShippingZone', shipping.id)variables = json.dumps({'id': ID})response = user_api_client.post(reverse('api'), {'query': query, 'variables': variables})@@ -42,7 +42,7 @@ def test_shipping_method_query(user_api_client, shipping_method):assert 'errors' not in contentassert shipping_data['name'] == shipping.nameassert shipping_data['description'] == shipping.description- no_ppc = shipping_method.price_per_country.count()+ no_ppc = shipping_method.shipping_methods.count()assert len(shipping_data['pricePerCountry']) == no_ppcprice_range = shipping.price_rangedata_price_range = shipping_data['priceRange']@@ -99,7 +99,7 @@ def test_update_shipping_method(admin_api_client, shipping_method):"""name = 'Parabolic name'shipping_id = graphene.Node.to_global_id(- 'ShippingMethod', shipping_method.pk)+ 'ShippingZone', shipping_method.pk)assert shipping_method.name != namevariables = json.dumps({'id': shipping_id, 'name': name})response = admin_api_client.post(@@ -112,7 +112,7 @@ def test_update_shipping_method(admin_api_client, shipping_method):def test_delete_shipping_method(admin_api_client, shipping_method):query = """- mutation deleteShippingMethod($id: ID!) {+ mutation deleteShippingZone($id: ID!) {shippingMethodDelete(id: $id) {shippingMethod {name@@ -121,7 +121,7 @@ def test_delete_shipping_method(admin_api_client, shipping_method):}"""shipping_method_id = graphene.Node.to_global_id(- 'ShippingMethod', shipping_method.pk)+ 'ShippingZone', shipping_method.pk)variables = json.dumps({'id': shipping_method_id})response = admin_api_client.post(reverse('api'), {'query': query, 'variables': variables})@@ -153,7 +153,7 @@ def test_create_shipping_price(admin_api_client, shipping_method):code = 'PL'price = '12.34'shipping_method_id = graphene.Node.to_global_id(- 'ShippingMethod', shipping_method.pk)+ 'ShippingZone', shipping_method.pk)variables = json.dumps({'shippingMethod': shipping_method_id,@@ -182,13 +182,13 @@ def test_update_shipping_price(admin_api_client, shipping_method, shipping_price}}"""- # shipping_price = shipping_method.price_per_country.first()+ # shipping_price = shipping_method.shipping_methods.first()price = '12.34'assert not str(shipping_price.price) == priceshipping_method_id = graphene.Node.to_global_id(- 'ShippingMethod', shipping_method.pk)+ 'ShippingZone', shipping_method.pk)shipping_price_id = graphene.Node.to_global_id(- 'ShippingMethodCountry', shipping_price.pk)+ 'ShippingRate', shipping_price.pk)variables = json.dumps({'shippingMethod': shipping_method_id,@@ -213,7 +213,7 @@ def test_delete_shipping_price(admin_api_client, shipping_price):}"""shipping_price_id = graphene.Node.to_global_id(- 'ShippingMethodCountry', shipping_price.pk)+ 'ShippingRate', shipping_price.pk)variables = json.dumps({'id': shipping_price_id})response = admin_api_client.post(reverse('api'), {'query': query, 'variables': variables})diff --git a/tests/conftest.py b/tests/conftest.pyindex 2af2e2b7f9..5ea8561afa 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -3,6 +3,7 @@ from io import BytesIOfrom unittest.mock import MagicMock, Mockimport pytest+from django.contrib.auth.models import Permissionfrom django.contrib.sites.models import Sitefrom django.core.files import File@@ -10,13 +11,13 @@ from django.core.files.uploadedfile import SimpleUploadedFilefrom django.forms import ModelFormfrom django.test.client import MULTIPART_CONTENT, Clientfrom django.utils.encoding import smart_text+from django_countries import countriesfrom django_prices_vatlayer.models import VATfrom django_prices_vatlayer.utils import get_tax_for_ratefrom graphql_jwt.shortcuts import get_tokenfrom payments import FraudStatus, PaymentStatusfrom PIL import Imagefrom prices import Money-from saleor.account.models import Address, Userfrom saleor.checkout import utilsfrom saleor.checkout.models import Cart@@ -30,10 +31,11 @@ from saleor.order.models import Orderfrom saleor.order.utils import recalculate_orderfrom saleor.page.models import Pagefrom saleor.product.models import (- AttributeChoiceValue, Category,- Collection, Product, ProductAttribute, ProductAttributeTranslation,- ProductImage, ProductTranslation, ProductType, ProductVariant)-from saleor.shipping.models import ShippingMethod, ShippingMethodCountry+ AttributeChoiceValue, Category, Collection, Product, ProductAttribute,+ ProductAttributeTranslation, ProductImage, ProductTranslation, ProductType,+ ProductVariant)+from saleor.shipping.models import (+ ShippingZone, ShippingRate, ShippingRate, ShippingZone)from saleor.site.models import AuthorizationKey, SiteSettings@@ -212,17 +214,19 @@ def authorized_client(client, customer_user):@pytest.fixturedef shipping_method(db): # pylint: disable=W0613- shipping_method = ShippingMethod.objects.create(name='DHL')- shipping_method.price_per_country.create(price=10)- return shipping_method+ shipping_zone = ShippingZone.objects.create(+ name='Europe', countries=[code for code, name in countries])+ shipping_zone.shipping_methods.create(+ name='DHL', price=10)+ return shipping_zone@pytest.fixturedef shipping_price(shipping_method):- return ShippingMethodCountry.objects.create(- country_code='PL',+ return ShippingRate.objects.create(+ name='DHL',price=10,- shipping_method=shipping_method)+ shipping_zone=shipping_method)@pytest.fixture@@ -439,7 +443,7 @@ def order_with_lines(order.shipping_address = order.billing_address.get_copy()order.shipping_method_name = shipping_method.name- method = shipping_method.price_per_country.get()+ method = shipping_method.shipping_methods.get()order.shipping_method = methodorder.shipping_price = method.get_total_price(taxes)order.save()diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex 0b06e9d694..7b5d8ff3df 100644--- a/tests/dashboard/test_order.py+++ b/tests/dashboard/test_order.py@@ -23,7 +23,7 @@ from saleor.product.models import ProductVariantdef test_ajax_order_shipping_methods_list(admin_client, order, shipping_method):- method = shipping_method.price_per_country.get()+ method = shipping_method.shipping_methods.get()shipping_methods_list = [{'id': method.pk, 'text': method.get_ajax_label()}]url = reverse(@@ -40,10 +40,10 @@ def test_ajax_order_shipping_methods_list_different_country(admin_client, order, shipping_method):order.shipping_address = order.billing_address.get_copy()order.save()- method = shipping_method.price_per_country.get()+ method = shipping_method.shipping_methods.get()shipping_methods_list = [{'id': method.pk, 'text': method.get_ajax_label()}]- shipping_method.price_per_country.create(price=15, country_code='DE')+ shipping_method.shipping_methods.create(price=15, country_code='DE')url = reverse('dashboard:ajax-order-shipping-methods', kwargs={'order_pk': order.pk})@@ -773,7 +773,7 @@ def test_view_create_from_draft_order_not_draft_order(def test_view_create_from_draft_order_shipping_method_not_valid(admin_client, draft_order, shipping_method):- method = shipping_method.price_per_country.create(+ method = shipping_method.shipping_methods.create(country_code='DE', price=10)draft_order.shipping_method = methoddraft_order.save()@@ -910,7 +910,7 @@ def test_view_order_customer_remove(admin_client, draft_order):def test_view_order_shipping_edit(admin_client, draft_order, shipping_method, settings, vatlayer):- method = shipping_method.price_per_country.create(+ method = shipping_method.shipping_methods.create(price=Money(5, settings.DEFAULT_CURRENCY), country_code='PL')url = reverse('dashboard:order-shipping-edit', kwargs={'order_pk': draft_order.pk})@@ -930,7 +930,7 @@ def test_view_order_shipping_edit(def test_view_order_shipping_edit_not_draft_order(admin_client, order_with_lines, shipping_method):- method = shipping_method.price_per_country.create(+ method = shipping_method.shipping_methods.create(price=5, country_code='PL')url = reverse('dashboard:order-shipping-edit',diff --git a/tests/dashboard/test_shipping.py b/tests/dashboard/test_shipping.pyindex faf2d2eb8f..3f0361ef04 100644--- a/tests/dashboard/test_shipping.py+++ b/tests/dashboard/test_shipping.py@@ -1,7 +1,7 @@from django.urls import reversefrom prices import Money-from saleor.shipping.models import ShippingMethod, ShippingMethodCountry+from saleor.shipping.models import ShippingZone, ShippingRatedef test_shipping_method_list(admin_client, shipping_method):@@ -11,36 +11,36 @@ def test_shipping_method_list(admin_client, shipping_method):def test_shipping_method_add(admin_client):- assert ShippingMethod.objects.count() == 0+ assert ShippingZone.objects.count() == 0url = reverse('dashboard:shipping-method-add')data = {'name': 'Zium', 'description': 'Fastest zium'}response = admin_client.post(url, data, follow=True)assert response.status_code == 200- assert ShippingMethod.objects.count() == 1+ assert ShippingZone.objects.count() == 1def test_shipping_method_add_not_valid(admin_client):- assert ShippingMethod.objects.count() == 0+ assert ShippingZone.objects.count() == 0url = reverse('dashboard:shipping-method-add')data = {}response = admin_client.post(url, data, follow=True)assert response.status_code == 200- assert ShippingMethod.objects.count() == 0+ assert ShippingZone.objects.count() == 0def test_shipping_method_edit(admin_client, shipping_method):- assert ShippingMethod.objects.count() == 1+ assert ShippingZone.objects.count() == 1url = reverse('dashboard:shipping-method-update',kwargs={'pk': shipping_method.pk})data = {'name': 'Flash', 'description': 'In a flash!'}response = admin_client.post(url, data, follow=True)assert response.status_code == 200- assert ShippingMethod.objects.count() == 1- assert ShippingMethod.objects.all()[0].name == 'Flash'+ assert ShippingZone.objects.count() == 1+ assert ShippingZone.objects.all()[0].name == 'Flash'def test_shipping_method_details(admin_client, shipping_method):- assert ShippingMethod.objects.count() == 1+ assert ShippingZone.objects.count() == 1url = reverse('dashboard:shipping-method-details',kwargs={'pk': shipping_method.pk})response = admin_client.post(url, follow=True)@@ -48,38 +48,38 @@ def test_shipping_method_details(admin_client, shipping_method):def test_shipping_method_delete(admin_client, shipping_method):- assert ShippingMethod.objects.count() == 1+ assert ShippingZone.objects.count() == 1url = reverse('dashboard:shipping-method-delete',kwargs={'pk': shipping_method.pk})response = admin_client.post(url, follow=True)assert response.status_code == 200- assert ShippingMethod.objects.count() == 0+ assert ShippingZone.objects.count() == 0def test_shipping_rate_add(admin_client, shipping_method):- assert ShippingMethodCountry.objects.count() == 1+ assert ShippingRate.objects.count() == 1url = reverse('dashboard:shipping-rate-add',kwargs={'shipping_method_pk': shipping_method.pk})data = {'country_code': 'FR', 'price': '50','shipping_method': shipping_method.pk}response = admin_client.post(url, data, follow=True)assert response.status_code == 200- assert ShippingMethodCountry.objects.count() == 2+ assert ShippingRate.objects.count() == 2def test_shipping_rate_add_not_valid(admin_client, shipping_method):- assert ShippingMethodCountry.objects.count() == 1+ assert ShippingRate.objects.count() == 1url = reverse('dashboard:shipping-rate-add',kwargs={'shipping_method_pk': shipping_method.pk})data = {}response = admin_client.post(url, data, follow=True)assert response.status_code == 200- assert ShippingMethodCountry.objects.count() == 1+ assert ShippingRate.objects.count() == 1def test_shipping_rate_edit(admin_client, shipping_method):- assert ShippingMethodCountry.objects.count() == 1- country = shipping_method.price_per_country.all()[0]+ assert ShippingRate.objects.count() == 1+ country = shipping_method.shipping_methods.all()[0]assert country.price == Money(10, 'USD')url = reverse('dashboard:shipping-rate-edit',kwargs={'shipping_method_pk': shipping_method.pk,@@ -88,18 +88,18 @@ def test_shipping_rate_edit(admin_client, shipping_method):'shipping_method': shipping_method.pk}response = admin_client.post(url, data, follow=True)assert response.status_code == 200- assert ShippingMethodCountry.objects.count() == 1+ assert ShippingRate.objects.count() == 1- shipping_price = shipping_method.price_per_country.all()[0].price+ shipping_price = shipping_method.shipping_methods.all()[0].priceassert shipping_price == Money(50, 'USD')def test_shipping_rate_delete(admin_client, shipping_method):- assert ShippingMethodCountry.objects.count() == 1- country = shipping_method.price_per_country.all()[0]+ assert ShippingRate.objects.count() == 1+ country = shipping_method.shipping_methods.all()[0]url = reverse('dashboard:shipping-rate-delete',kwargs={'shipping_method_pk': shipping_method.pk,'rate_pk': country.pk})response = admin_client.post(url, follow=True)assert response.status_code == 200- assert ShippingMethodCountry.objects.count() == 0+ assert ShippingRate.objects.count() == 0diff --git a/tests/test_cart.py b/tests/test_cart.pyindex 57258ecbc9..2cadbeaca3 100644--- a/tests/test_cart.py+++ b/tests/test_cart.py@@ -655,7 +655,7 @@ def test_cart_total_with_discount(request_cart_with_item, sale, vatlayer):def test_cart_taxes(request_cart_with_item, shipping_method, vatlayer):cart = request_cart_with_item- cart.shipping_method = shipping_method.price_per_country.get()+ cart.shipping_method = shipping_method.shipping_methods.get()cart.save()taxed_price = TaxedMoney(net=Money('8.13', 'USD'), gross=Money(10, 'USD'))assert cart.get_shipping_price(taxes=vatlayer) == taxed_pricediff --git a/tests/test_checkout.py b/tests/test_checkout.pyindex 3269ca0811..4782430b90 100644--- a/tests/test_checkout.py+++ b/tests/test_checkout.py@@ -137,7 +137,7 @@ def test_view_checkout_shipping_method(request_cart_with_item.email = '[email protected]'request_cart_with_item.save()url = reverse('checkout:shipping-method')- data = {'shipping_method': shipping_method.price_per_country.first().pk}+ data = {'shipping_method': shipping_method.shipping_methods.first().pk}response = client.get(url)@@ -157,7 +157,7 @@ def test_view_checkout_shipping_method_authorized_user(request_cart_with_item.shipping_address = addressrequest_cart_with_item.save()url = reverse('checkout:shipping-method')- data = {'shipping_method': shipping_method.price_per_country.first().pk}+ data = {'shipping_method': shipping_method.shipping_methods.first().pk}response = authorized_client.get(url)@@ -199,7 +199,7 @@ def test_view_checkout_summary(request_cart_with_item.shipping_address = addressrequest_cart_with_item.email = '[email protected]'request_cart_with_item.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())request_cart_with_item.save()url = reverse('checkout:summary')data = {'address': 'shipping_address'}@@ -225,7 +225,7 @@ def test_view_checkout_summary_authorized_user(request_cart_with_item.user = customer_userrequest_cart_with_item.email = customer_user.emailrequest_cart_with_item.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())request_cart_with_item.save()url = reverse('checkout:summary')data = {'address': 'shipping_address'}@@ -259,7 +259,7 @@ def test_view_checkout_summary_save_language(request_cart_with_item.user = customer_userrequest_cart_with_item.email = customer_user.emailrequest_cart_with_item.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())request_cart_with_item.save()url = reverse('checkout:summary')data = {'address': 'shipping_address'}@@ -311,7 +311,7 @@ def test_view_checkout_summary_with_invalid_voucher(request_cart_with_item.shipping_address = addressrequest_cart_with_item.email = '[email protected]'request_cart_with_item.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())request_cart_with_item.save()url = reverse('checkout:summary')@@ -344,7 +344,7 @@ def test_view_checkout_summary_with_invalid_voucher_code(request_cart_with_item.shipping_address = addressrequest_cart_with_item.email = '[email protected]'request_cart_with_item.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())request_cart_with_item.save()url = reverse('checkout:summary')@@ -366,7 +366,7 @@ def test_view_checkout_place_order_with_expired_voucher_code(cart.shipping_address = addresscart.email = '[email protected]'cart.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())# set voucher to be expiredyesterday = datetime.date.today() - datetime.timedelta(days=1)@@ -404,7 +404,7 @@ def test_view_checkout_place_order_with_item_out_of_stock(cart.shipping_address = addresscart.email = '[email protected]'cart.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())# save the cartcart.save()@@ -433,7 +433,7 @@ def test_view_checkout_place_order_without_shipping_address(# add shipping information to the cartcart.email = '[email protected]'cart.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())# save the cartcart.save()@@ -455,7 +455,7 @@ def test_view_checkout_summary_remove_voucher(request_cart_with_item.shipping_address = addressrequest_cart_with_item.email = '[email protected]'request_cart_with_item.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())request_cart_with_item.save()remove_voucher_url = reverse('checkout:summary')diff --git a/tests/test_core.py b/tests/test_core.pyindex 8f3dd82a4c..7591a7893b 100644--- a/tests/test_core.py+++ b/tests/test_core.py@@ -18,7 +18,7 @@ from saleor.core.utils.text import get_cleaner, strip_htmlfrom saleor.discount.models import Sale, Voucherfrom saleor.order.models import Orderfrom saleor.product.models import Product, ProductImage, ProductVariant-from saleor.shipping.models import ShippingMethod+from saleor.shipping.models import ShippingZonetype_schema = {'Vegetable': {@@ -82,10 +82,10 @@ def test_create_superuser(db, client):def test_create_shipping_methods(db):- assert ShippingMethod.objects.all().count() == 0+ assert ShippingZone.objects.all().count() == 0for _ in random_data.create_shipping_methods():pass- assert ShippingMethod.objects.all().count() == 2+ assert ShippingZone.objects.all().count() == 2def test_create_fake_user(db):diff --git a/tests/test_order.py b/tests/test_order.pyindex e1196c44d9..8486686560 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -399,7 +399,7 @@ def test_order_payment_flow(request_cart_with_item.billing_address = address.get_copy()request_cart_with_item.email = '[email protected]'request_cart_with_item.shipping_method = (- shipping_method.price_per_country.first())+ shipping_method.shipping_methods.first())request_cart_with_item.save()order = create_order(diff --git a/tests/test_shipping.py b/tests/test_shipping.pyindex e651e6dad7..153dbe83f8 100644--- a/tests/test_shipping.py+++ b/tests/test_shipping.py@@ -5,7 +5,7 @@ import pytestfrom prices import Money, TaxedMoneyfrom saleor.core.i18n import ANY_COUNTRY, COUNTRY_CODE_CHOICESfrom saleor.core.utils import format_money, get_country_name_by_code-from saleor.shipping.models import ShippingMethodCountry+from saleor.shipping.models import ShippingRatefrom saleor.shipping.utils import country_choices, get_taxed_shipping_price@@ -25,7 +25,7 @@ def test_get_taxed_shipping_price(def test_shipping_get_total_price(monkeypatch, shipping_method, vatlayer):- method = shipping_method.price_per_country.get()+ method = shipping_method.shipping_methods.get()price = Money(10, 'USD')taxed_price = TaxedMoney(net=Money('8.13', 'USD'), gross=Money(10, 'USD'))@@ -37,7 +37,7 @@ def test_shipping_get_total_price(monkeypatch, shipping_method, vatlayer):def test_shipping_get_ajax_label(shipping_method):- method = shipping_method.price_per_country.get()+ method = shipping_method.shipping_methods.get()label = method.get_ajax_label()proper_label = '%(shipping_method)s %(country_code_display)s %(price)s' % {'shipping_method': method.shipping_method,@@ -47,12 +47,12 @@ def test_shipping_get_ajax_label(shipping_method):def test_country_choices(shipping_method):- any_country_shipping_method = ShippingMethodCountry.objects.filter(+ any_country_shipping_method = ShippingRate.objects.filter(country_code=ANY_COUNTRY)assert any_country_shipping_method.exists()assert country_choices() == COUNTRY_CODE_CHOICESany_country_shipping_method.delete()- ShippingMethodCountry.objects.create(+ ShippingRate.objects.create(country_code='PL', price=10, shipping_method=shipping_method)assert country_choices() == [('PL', get_country_name_by_code('PL'))]