Skip to content

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

Rename cart app to checkout

Anna Siwikf2f6a31ba258
diff --git a/saleor/account/views.py b/saleor/account/views.py
index 6c222bb857..1bbdb346ba 100755
--- a/saleor/account/views.py
+++ b/saleor/account/views.py
@@ -8,7 +8,7 @@ from django.template.response import TemplateResponse
from django.urls import reverse, reverse_lazy
from django.utils.translation import pgettext, ugettext_lazy as _
-from ..cart.utils import find_and_assign_anonymous_cart
+from ..checkout.utils import find_and_assign_anonymous_cart
from ..core.utils import get_paginator_items
from .forms import (
ChangePasswordForm, LoginForm, PasswordResetForm, SignupForm,
diff --git a/saleor/cart/__init__.py b/saleor/checkout/__init__.py
similarity index 100%
rename from saleor/cart/__init__.py
rename to saleor/checkout/__init__.py
diff --git a/saleor/cart/context_processors.py b/saleor/checkout/context_processors.py
similarity index 100%
rename from saleor/cart/context_processors.py
rename to saleor/checkout/context_processors.py
diff --git a/saleor/cart/forms.py b/saleor/checkout/forms.py
similarity index 100%
rename from saleor/cart/forms.py
rename to saleor/checkout/forms.py
diff --git a/saleor/cart/migrations/0001_auto_20170113_0435.py b/saleor/checkout/migrations/0001_auto_20170113_0435.py
similarity index 83%
rename from saleor/cart/migrations/0001_auto_20170113_0435.py
rename to saleor/checkout/migrations/0001_auto_20170113_0435.py
index cfc9c7688a..4685670cb4 100644
--- a/saleor/cart/migrations/0001_auto_20170113_0435.py
+++ b/saleor/checkout/migrations/0001_auto_20170113_0435.py
@@ -9,7 +9,11 @@ import jsonfield.fields
class Migration(migrations.Migration):
dependencies = [
- ('cart', 'fix_empty_data_in_lines'),
+ ('checkout', 'fix_empty_data_in_lines'),
+ ]
+
+ replaces = [
+ ('cart', '0001_auto_20170113_0435'),
]
operations = [
diff --git a/saleor/cart/migrations/0001_initial.py b/saleor/checkout/migrations/0001_initial.py
similarity index 92%
rename from saleor/cart/migrations/0001_initial.py
rename to saleor/checkout/migrations/0001_initial.py
index 74513ad4f6..6d001c57a4 100644
--- a/saleor/cart/migrations/0001_initial.py
+++ b/saleor/checkout/migrations/0001_initial.py
@@ -18,6 +18,10 @@ class Migration(migrations.Migration):
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
+ replaces = [
+ ('cart', '0001_initial'),
+ ]
+
operations = [
migrations.CreateModel(
name='Cart',
@@ -34,6 +38,7 @@ class Migration(migrations.Migration):
('voucher', models.ForeignKey(related_name='+', on_delete=django.db.models.deletion.SET_NULL, to='discount.Voucher', null=True)),
],
options={
+ 'db_table': 'cart_cart',
'ordering': ('-last_status_change',),
},
),
@@ -43,9 +48,12 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('quantity', models.PositiveIntegerField(verbose_name='quantity', validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(999)])),
('data', models.TextField(default='{}', blank=True)),
- ('cart', models.ForeignKey(related_name='lines', to='cart.Cart', on_delete=django.db.models.deletion.CASCADE)),
+ ('cart', models.ForeignKey(related_name='lines', to='checkout.Cart', on_delete=django.db.models.deletion.CASCADE)),
('product', models.ForeignKey(related_name='+', verbose_name='product', to='product.ProductVariant', on_delete=django.db.models.deletion.CASCADE)),
],
+ options={
+ 'db_table': 'cart_cartline',
+ },
),
migrations.AlterUniqueTogether(
name='cartline',
diff --git a/saleor/cart/migrations/0002_auto_20161014_1221.py b/saleor/checkout/migrations/0002_auto_20161014_1221.py
similarity index 84%
rename from saleor/cart/migrations/0002_auto_20161014_1221.py
rename to saleor/checkout/migrations/0002_auto_20161014_1221.py
index edf752fee1..9ed241380f 100644
--- a/saleor/cart/migrations/0002_auto_20161014_1221.py
+++ b/saleor/checkout/migrations/0002_auto_20161014_1221.py
@@ -9,7 +9,11 @@ class Migration(migrations.Migration):
dependencies = [
('product', '0012_auto_20160218_0812'),
- ('cart', '0001_initial'),
+ ('checkout', '0001_initial'),
+ ]
+
+ replaces = [
+ ('cart', '0002_auto_20161014_1221'),
]
operations = [
diff --git a/saleor/cart/migrations/0002_auto_20170206_0407.py b/saleor/checkout/migrations/0002_auto_20170206_0407.py
similarity index 91%
rename from saleor/cart/migrations/0002_auto_20170206_0407.py
rename to saleor/checkout/migrations/0002_auto_20170206_0407.py
index 48e1f9f780..061c1d2930 100644
--- a/saleor/cart/migrations/0002_auto_20170206_0407.py
+++ b/saleor/checkout/migrations/0002_auto_20170206_0407.py
@@ -11,7 +11,11 @@ import jsonfield.fields
class Migration(migrations.Migration):
dependencies = [
- ('cart', '0001_auto_20170113_0435'),
+ ('checkout', '0001_auto_20170113_0435'),
+ ]
+
+ replaces = [
+ ('cart', '0002_auto_20170206_0407'),
]
operations = [
@@ -51,7 +55,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='cartline',
name='cart',
- field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='cart.Cart', verbose_name='cart'),
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='checkout.Cart', verbose_name='cart'),
),
migrations.AlterField(
model_name='cartline',
diff --git a/saleor/cart/migrations/0003_auto_20170906_0556.py b/saleor/checkout/migrations/0003_auto_20170906_0556.py
similarity index 86%
rename from saleor/cart/migrations/0003_auto_20170906_0556.py
rename to saleor/checkout/migrations/0003_auto_20170906_0556.py
index eafccaae73..ce16d6fd78 100644
--- a/saleor/cart/migrations/0003_auto_20170906_0556.py
+++ b/saleor/checkout/migrations/0003_auto_20170906_0556.py
@@ -8,7 +8,11 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ('cart', '0002_auto_20170206_0407'),
+ ('checkout', '0002_auto_20170206_0407'),
+ ]
+
+ replaces = [
+ ('cart', '0003_auto_20170906_0556'),
]
operations = [
diff --git a/saleor/cart/migrations/0004_auto_20171129_1004.py b/saleor/checkout/migrations/0004_auto_20171129_1004.py
similarity index 80%
rename from saleor/cart/migrations/0004_auto_20171129_1004.py
rename to saleor/checkout/migrations/0004_auto_20171129_1004.py
index 8a71080148..919d5392a8 100644
--- a/saleor/cart/migrations/0004_auto_20171129_1004.py
+++ b/saleor/checkout/migrations/0004_auto_20171129_1004.py
@@ -8,7 +8,11 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
- ('cart', '0003_auto_20170906_0556'),
+ ('checkout', '0003_auto_20170906_0556'),
+ ]
+
+ replaces = [
+ ('cart', '0004_auto_20171129_1004'),
]
operations = [
diff --git a/saleor/cart/migrations/0005_auto_20180108_0814.py b/saleor/checkout/migrations/0005_auto_20180108_0814.py
similarity index 95%
rename from saleor/cart/migrations/0005_auto_20180108_0814.py
rename to saleor/checkout/migrations/0005_auto_20180108_0814.py
index 548d4afd31..b4c581bcb3 100644
--- a/saleor/cart/migrations/0005_auto_20180108_0814.py
+++ b/saleor/checkout/migrations/0005_auto_20180108_0814.py
@@ -15,7 +15,11 @@ import jsonfield.fields
class Migration(migrations.Migration):
dependencies = [
- ('cart', '0004_auto_20171129_1004'),
+ ('checkout', '0004_auto_20171129_1004'),
+ ]
+
+ replaces = [
+ ('cart', '0005_auto_20180108_0814'),
]
operations = [
@@ -72,7 +76,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='cartline',
name='cart',
- field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='cart.Cart'),
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='checkout.Cart'),
),
migrations.AlterField(
model_name='cartline',
diff --git a/saleor/cart/migrations/0006_auto_20180221_0825.py b/saleor/checkout/migrations/0006_auto_20180221_0825.py
similarity index 79%
rename from saleor/cart/migrations/0006_auto_20180221_0825.py
rename to saleor/checkout/migrations/0006_auto_20180221_0825.py
index ac4b2bca3f..5121c97ea1 100644
--- a/saleor/cart/migrations/0006_auto_20180221_0825.py
+++ b/saleor/checkout/migrations/0006_auto_20180221_0825.py
@@ -6,7 +6,11 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
- ('cart', '0005_auto_20180108_0814'),
+ ('checkout', '0005_auto_20180108_0814'),
+ ]
+
+ replaces = [
+ ('cart', '0006_auto_20180221_0825'),
]
operations = [
diff --git a/saleor/cart/migrations/0007_merge_cart_with_checkout.py b/saleor/checkout/migrations/0007_merge_cart_with_checkout.py
similarity index 88%
rename from saleor/cart/migrations/0007_merge_cart_with_checkout.py
rename to saleor/checkout/migrations/0007_merge_cart_with_checkout.py
index d970a65b5c..a74c0350a0 100644
--- a/saleor/cart/migrations/0007_merge_cart_with_checkout.py
+++ b/saleor/checkout/migrations/0007_merge_cart_with_checkout.py
@@ -11,7 +11,11 @@ class Migration(migrations.Migration):
('shipping', '0008_auto_20180108_0814'),
('product', '0063_required_attr_value_order'),
('account', '0018_auto_20180426_0641'),
- ('cart', '0006_auto_20180221_0825'),
+ ('checkout', '0006_auto_20180221_0825'),
+ ]
+
+ replaces = [
+ ('cart', '0007_merge_cart_with_checkout.'),
]
operations = [
@@ -67,4 +71,12 @@ class Migration(migrations.Migration):
name='voucher_code',
field=models.CharField(blank=True, max_length=12, null=True),
),
+ migrations.AlterModelTable(
+ name='cart',
+ table=None,
+ ),
+ migrations.AlterModelTable(
+ name='cartline',
+ table=None,
+ ),
]
diff --git a/saleor/cart/migrations/__init__.py b/saleor/checkout/migrations/__init__.py
similarity index 100%
rename from saleor/cart/migrations/__init__.py
rename to saleor/checkout/migrations/__init__.py
diff --git a/saleor/cart/migrations/fix_empty_data_in_lines.py b/saleor/checkout/migrations/fix_empty_data_in_lines.py
similarity index 77%
rename from saleor/cart/migrations/fix_empty_data_in_lines.py
rename to saleor/checkout/migrations/fix_empty_data_in_lines.py
index 26da4c6a76..eed49f4956 100644
--- a/saleor/cart/migrations/fix_empty_data_in_lines.py
+++ b/saleor/checkout/migrations/fix_empty_data_in_lines.py
@@ -6,7 +6,7 @@ from django.db import migrations
def convert_lines_data(apps, schema_editor):
- CartLine = apps.get_model('cart', 'CartLine')
+ CartLine = apps.get_model('checkout', 'CartLine')
# Iterate over all cart lines, due to wrong JSONField None handling
for line in CartLine.objects.all():
if line.data is None:
@@ -17,7 +17,11 @@ def convert_lines_data(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
- ('cart', '0002_auto_20161014_1221'),
+ ('checkout', '0002_auto_20161014_1221'),
+ ]
+
+ replaces = [
+ ('cart', 'fix_empty_data_in_lines'),
]
operations = [
diff --git a/saleor/cart/models.py b/saleor/checkout/models.py
similarity index 100%
rename from saleor/cart/models.py
rename to saleor/checkout/models.py
diff --git a/saleor/cart/urls.py b/saleor/checkout/urls.py
similarity index 93%
rename from saleor/cart/urls.py
rename to saleor/checkout/urls.py
index 31726f8d75..ffa5186666 100644
--- a/saleor/cart/urls.py
+++ b/saleor/checkout/urls.py
@@ -1,15 +1,8 @@
from django.conf.urls import url
from . import views
-from saleor.cart.views.discount import remove_voucher_view
+from .views.discount import remove_voucher_view
-cart_urlpatterns = [
- url(r'^$', views.cart_index, name='index'),
- url(r'^update/(?P<variant_id>\d+)/$',
- views.update_cart_line, name='update-line'),
- url(r'^summary/$', views.cart_summary, name='summary'),
- url(r'^shipping-options/$', views.cart_shipping_options,
- name='shipping-options')]
checkout_urlpatterns = [
url(r'^$', views.checkout_index, name='index'),
@@ -21,3 +14,12 @@ checkout_urlpatterns = [
url(r'^remove_voucher/', remove_voucher_view,
name='remove-voucher'),
url(r'^login/', views.checkout_login, name='login')]
+
+
+cart_urlpatterns = [
+ url(r'^$', views.cart_index, name='index'),
+ url(r'^update/(?P<variant_id>\d+)/$',
+ views.update_cart_line, name='update-line'),
+ url(r'^summary/$', views.cart_summary, name='summary'),
+ url(r'^shipping-options/$', views.cart_shipping_options,
+ name='shipping-options')]
diff --git a/saleor/cart/utils.py b/saleor/checkout/utils.py
similarity index 99%
rename from saleor/cart/utils.py
rename to saleor/checkout/utils.py
index 6735c9a385..e1b020478b 100644
--- a/saleor/cart/utils.py
+++ b/saleor/checkout/utils.py
@@ -14,9 +14,6 @@ from . import logger
from ..account.forms import get_address_form
from ..account.models import Address
from ..account.utils import store_user_address
-from ..cart.forms import (
- AddressChoiceForm, AnonymousUserBillingForm, AnonymousUserShippingForm,
- BillingAddressChoiceForm)
from ..core.exceptions import InsufficientStock
from ..core.utils import to_local_currency
from ..core.utils.taxes import ZERO_MONEY, get_taxes_for_country
@@ -26,6 +23,9 @@ from ..discount.utils import (
get_product_or_category_voucher_discount, get_shipping_voucher_discount,
get_value_voucher_discount, increase_voucher_usage)
from ..order.models import Order
+from .forms import (
+ AddressChoiceForm, AnonymousUserBillingForm, AnonymousUserShippingForm,
+ BillingAddressChoiceForm)
from .models import Cart
COOKIE_NAME = 'cart'
diff --git a/saleor/cart/views.py b/saleor/checkout/views.py
similarity index 100%
rename from saleor/cart/views.py
rename to saleor/checkout/views.py
diff --git a/saleor/cart/views/__init__.py b/saleor/checkout/views/__init__.py
similarity index 100%
rename from saleor/cart/views/__init__.py
rename to saleor/checkout/views/__init__.py
diff --git a/saleor/cart/views/discount.py b/saleor/checkout/views/discount.py
similarity index 100%
rename from saleor/cart/views/discount.py
rename to saleor/checkout/views/discount.py
diff --git a/saleor/cart/views/shipping.py b/saleor/checkout/views/shipping.py
similarity index 100%
rename from saleor/cart/views/shipping.py
rename to saleor/checkout/views/shipping.py
diff --git a/saleor/cart/views/summary.py b/saleor/checkout/views/summary.py
similarity index 100%
rename from saleor/cart/views/summary.py
rename to saleor/checkout/views/summary.py
diff --git a/saleor/cart/views/validators.py b/saleor/checkout/views/validators.py
similarity index 100%
rename from saleor/cart/views/validators.py
rename to saleor/checkout/views/validators.py
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index e14f355652..e1f820b36e 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -9,7 +9,7 @@ from payments import PaymentError, PaymentStatus
from ...account.i18n import (
AddressForm as StorefrontAddressForm, PossiblePhoneNumberFormField)
from ...account.models import User
-from ...cart.forms import QuantityField
+from ...checkout.forms import QuantityField
from ...core.exceptions import InsufficientStock
from ...core.utils.taxes import ZERO_TAXED_MONEY
from ...discount.models import Voucher
diff --git a/saleor/product/forms.py b/saleor/product/forms.py
index 79fb0443e9..1574a3bad0 100644
--- a/saleor/product/forms.py
+++ b/saleor/product/forms.py
@@ -5,7 +5,7 @@ from django.utils.encoding import smart_text
from django.utils.translation import pgettext_lazy
from django_prices.templatetags.prices_i18n import amount
-from ..cart.forms import AddToCartForm
+from ..checkout.forms import AddToCartForm
from ..core.utils.taxes import display_gross_prices
diff --git a/saleor/product/utils/__init__.py b/saleor/product/utils/__init__.py
index 96dbfd57fd..91c52992fc 100644
--- a/saleor/product/utils/__init__.py
+++ b/saleor/product/utils/__init__.py
@@ -4,7 +4,7 @@ from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.db.models import F
-from ...cart.utils import (
+from ...checkout.utils import (
get_cart_from_request, get_or_create_cart_from_request)
from ...core.utils import get_paginator_items
from ...core.utils.filters import get_now_sorted_by
diff --git a/saleor/product/views.py b/saleor/product/views.py
index 2d9c3d5896..38061bca9e 100644
--- a/saleor/product/views.py
+++ b/saleor/product/views.py
@@ -6,7 +6,7 @@ from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.urls import reverse
-from ..cart.utils import set_cart_cookie
+from ..checkout.utils import set_cart_cookie
from ..core.utils import serialize_decimal
from ..seo.schema.product import product_json_ld
from .filters import ProductCategoryFilter, ProductCollectionFilter
diff --git a/saleor/settings.py b/saleor/settings.py
index 043aae5996..b0deb678b0 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -123,7 +123,7 @@ context_processors = [
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request',
'saleor.core.context_processors.default_currency',
- 'saleor.cart.context_processors.cart_counter',
+ 'saleor.checkout.context_processors.cart_counter',
'saleor.core.context_processors.navigation',
'saleor.core.context_processors.search_enabled',
'saleor.site.context_processors.site',
@@ -187,7 +187,7 @@ INSTALLED_APPS = [
'saleor.account',
'saleor.discount',
'saleor.product',
- 'saleor.cart',
+ 'saleor.checkout',
'saleor.core',
'saleor.graphql',
'saleor.menu',
diff --git a/saleor/urls.py b/saleor/urls.py
index 37192dbfed..e597af2366 100644
--- a/saleor/urls.py
+++ b/saleor/urls.py
@@ -8,8 +8,8 @@ from django.views.i18n import JavaScriptCatalog, set_language
from graphene_django.views import GraphQLView
from .account.urls import urlpatterns as account_urls
-from .cart.urls import cart_urlpatterns as cart_urls
-from .cart.urls import checkout_urlpatterns as checkout_urls
+from .checkout.urls import cart_urlpatterns as cart_urls
+from .checkout.urls import checkout_urlpatterns as checkout_urls
from .core.sitemaps import sitemaps
from .core.urls import urlpatterns as core_urls
from .dashboard.urls import urlpatterns as dashboard_urls
diff --git a/tests/conftest.py b/tests/conftest.py
index e90e535154..bbfcef5112 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -15,9 +15,9 @@ from PIL import Image
from prices import Money
from saleor.account.models import Address, User
-from saleor.cart import utils
-from saleor.cart.models import Cart
-from saleor.cart.utils import add_variant_to_cart
+from saleor.checkout import utils
+from saleor.checkout.models import Cart
+from saleor.checkout.utils import add_variant_to_cart
from saleor.dashboard.order.utils import fulfill_order_line
from saleor.discount.models import Sale, Voucher
from saleor.menu.models import Menu, MenuItem
diff --git a/tests/test_cart.py b/tests/test_cart.py
index a1f432513b..c8115ceb2e 100644
--- a/tests/test_cart.py
+++ b/tests/test_cart.py
@@ -10,12 +10,12 @@ from django.http import HttpResponse
from django.urls import reverse
from prices import Money, TaxedMoney
-from saleor.cart import forms, utils
-from saleor.cart.context_processors import cart_counter
-from saleor.cart.models import Cart
-from saleor.cart.utils import (
+from saleor.checkout import forms, utils
+from saleor.checkout.context_processors import cart_counter
+from saleor.checkout.models import Cart
+from saleor.checkout.utils import (
add_variant_to_cart, change_cart_user, find_open_cart_for_user)
-from saleor.cart.views import update_cart_line
+from saleor.checkout.views import update_cart_line
from saleor.core.exceptions import InsufficientStock
from saleor.core.utils.taxes import ZERO_TAXED_MONEY
from saleor.discount.models import Sale
@@ -52,7 +52,7 @@ def user_cart(customer_user):
def local_currency(monkeypatch):
def side_effect(price, currency):
return price
- monkeypatch.setattr('saleor.cart.views.to_local_currency', side_effect)
+ monkeypatch.setattr('saleor.checkout.views.to_local_currency', side_effect)
def test_get_or_create_anonymous_cart_from_token(anonymous_cart, user_cart):
@@ -124,9 +124,9 @@ def test_get_or_create_cart_from_request(
mock_get_for_user = Mock(return_value=user_cart)
mock_get_for_anonymous = Mock(return_value=anonymous_cart)
monkeypatch.setattr(
- 'saleor.cart.utils.get_or_create_user_cart', mock_get_for_user)
+ 'saleor.checkout.utils.get_or_create_user_cart', mock_get_for_user)
monkeypatch.setattr(
- 'saleor.cart.utils.get_or_create_anonymous_cart_from_token',
+ 'saleor.checkout.utils.get_or_create_anonymous_cart_from_token',
mock_get_for_anonymous)
returned_cart = utils.get_or_create_cart_from_request(request, queryset)
mock_get_for_user.assert_called_once_with(customer_user, queryset)
@@ -147,14 +147,14 @@ def test_get_cart_from_request(
user_cart = Cart(user=customer_user)
mock_get_for_user = Mock(return_value=user_cart)
monkeypatch.setattr(
- 'saleor.cart.utils.get_user_cart', mock_get_for_user)
+ 'saleor.checkout.utils.get_user_cart', mock_get_for_user)
returned_cart = utils.get_cart_from_request(request, queryset)
mock_get_for_user.assert_called_once_with(customer_user, queryset)
assert returned_cart == user_cart
mock_get_for_user = Mock(return_value=None)
monkeypatch.setattr(
- 'saleor.cart.utils.get_user_cart', mock_get_for_user)
+ 'saleor.checkout.utils.get_user_cart', mock_get_for_user)
returned_cart = utils.get_cart_from_request(request, queryset)
mock_get_for_user.assert_called_once_with(customer_user, queryset)
assert not Cart.objects.filter(token=returned_cart.token).exists()
@@ -162,7 +162,7 @@ def test_get_cart_from_request(
anonymous_cart = Cart()
mock_get_for_anonymous = Mock(return_value=anonymous_cart)
monkeypatch.setattr(
- 'saleor.cart.utils.get_anonymous_cart_from_token',
+ 'saleor.checkout.utils.get_anonymous_cart_from_token',
mock_get_for_anonymous)
request = cart_request_factory(user=None, token=token)
returned_cart = utils.get_cart_from_request(request, queryset)
@@ -171,7 +171,7 @@ def test_get_cart_from_request(
mock_get_for_anonymous = Mock(return_value=None)
monkeypatch.setattr(
- 'saleor.cart.utils.get_anonymous_cart_from_token',
+ 'saleor.checkout.utils.get_anonymous_cart_from_token',
mock_get_for_anonymous)
returned_cart = utils.get_cart_from_request(request, queryset)
assert not Cart.objects.filter(token=returned_cart.token).exists()
@@ -281,7 +281,7 @@ def test_shipping_detection(cart, product):
def test_cart_counter(monkeypatch):
monkeypatch.setattr(
- 'saleor.cart.context_processors.get_cart_from_request',
+ 'saleor.checkout.context_processors.get_cart_from_request',
Mock(return_value=Mock(quantity=4)))
ret = cart_counter(Mock())
assert ret == {'cart_counter': 4}
@@ -323,17 +323,17 @@ def test_check_product_availability_and_warn(
monkeypatch.setattr(
'django.contrib.messages.warning', Mock(warning=Mock()))
monkeypatch.setattr(
- 'saleor.cart.utils.contains_unavailable_variants',
+ 'saleor.checkout.utils.contains_unavailable_variants',
Mock(return_value=False))
utils.check_product_availability_and_warn(MagicMock(), cart)
assert len(cart) == 1
monkeypatch.setattr(
- 'saleor.cart.utils.contains_unavailable_variants',
+ 'saleor.checkout.utils.contains_unavailable_variants',
Mock(return_value=True))
monkeypatch.setattr(
- 'saleor.cart.utils.remove_unavailable_variants',
+ 'saleor.checkout.utils.remove_unavailable_variants',
lambda c: add_variant_to_cart(cart, variant, 0, replace=True))
utils.check_product_availability_and_warn(MagicMock(), cart)
diff --git a/tests/test_checkout.py b/tests/test_checkout.py
index 68c4a7e6be..e83464d207 100644
--- a/tests/test_checkout.py
+++ b/tests/test_checkout.py
@@ -8,9 +8,9 @@ from freezegun import freeze_time
from prices import Money, TaxedMoney
from saleor.account.models import Address
-from saleor.cart import views
-from saleor.cart.forms import CartVoucherForm
-from saleor.cart.utils import (
+from saleor.checkout import views
+from saleor.checkout.forms import CartVoucherForm
+from saleor.checkout.utils import (
add_variant_to_cart, change_billing_address_in_cart,
change_shipping_address_in_cart, create_order, get_cart_data_for_checkout,
get_taxes_for_cart, get_voucher_discount_for_cart, get_voucher_for_cart,
@@ -35,7 +35,7 @@ def test_view_checkout_index(
__len__=Mock(return_value=cart_length),
is_shipping_required=Mock(return_value=is_shipping_required))
monkeypatch.setattr(
- 'saleor.cart.utils.get_cart_from_request', lambda req, qs: cart)
+ 'saleor.checkout.utils.get_cart_from_request', lambda req, qs: cart)
url = reverse('checkout:index')
request = rf.get(url, follow=True)
@@ -170,7 +170,7 @@ def test_view_checkout_shipping_method_without_address(
assert get_redirect_location(response) == redirect_url
-@patch('saleor.cart.views.summary.send_order_confirmation')
+@patch('saleor.checkout.views.summary.send_order_confirmation')
def test_view_checkout_summary(
mock_send_confirmation, client, shipping_method, address,
request_cart_with_item):
@@ -195,7 +195,7 @@ def test_view_checkout_summary(
mock_send_confirmation.delay.assert_called_once_with(order.pk)
-@patch('saleor.cart.views.summary.send_order_confirmation')
+@patch('saleor.checkout.views.summary.send_order_confirmation')
def test_view_checkout_summary_authorized_user(
mock_send_confirmation, authorized_client, customer_user,
shipping_method, address, request_cart_with_item):
@@ -221,7 +221,7 @@ def test_view_checkout_summary_authorized_user(
mock_send_confirmation.delay.assert_called_once_with(order.pk)
-@patch('saleor.cart.views.summary.send_order_confirmation')
+@patch('saleor.checkout.views.summary.send_order_confirmation')
def test_view_checkout_summary_save_language(
mock_send_confirmation, authorized_client, customer_user,
shipping_method, address, request_cart_with_item, settings):
@@ -487,7 +487,7 @@ def test_get_discount_for_cart_shipping_voucher_not_applicable(
def test_get_discount_for_cart_product_voucher_not_applicable(
settings, monkeypatch):
monkeypatch.setattr(
- 'saleor.cart.utils.get_product_variants_and_prices',
+ 'saleor.checkout.utils.get_product_variants_and_prices',
lambda cart, product: [])
voucher = Voucher(
code='unique', type=VoucherType.PRODUCT,
@@ -503,7 +503,7 @@ def test_get_discount_for_cart_product_voucher_not_applicable(
def test_get_discount_for_cart_category_voucher_not_applicable(
settings, monkeypatch):
monkeypatch.setattr(
- 'saleor.cart.utils.get_category_variants_and_prices',
+ 'saleor.checkout.utils.get_category_variants_and_prices',
lambda cart, product: [])
voucher = Voucher(
code='unique', type=VoucherType.CATEGORY,
diff --git a/tests/test_discounts.py b/tests/test_discounts.py
index 05b5f441eb..44c034a809 100644
--- a/tests/test_discounts.py
+++ b/tests/test_discounts.py
@@ -4,7 +4,7 @@ from unittest.mock import Mock
import pytest
from prices import Money, TaxedMoney
-from saleor.cart.utils import get_voucher_discount_for_cart
+from saleor.checkout.utils import get_voucher_discount_for_cart
from saleor.discount import (
DiscountValueType, VoucherApplyToProduct, VoucherType)
from saleor.discount.models import NotApplicable, Sale, Voucher
@@ -97,7 +97,7 @@ def test_products_voucher_checkout_discount_not(
settings, monkeypatch, prices, discount_value, discount_type, apply_to,
expected_value):
monkeypatch.setattr(
- 'saleor.cart.utils.get_product_variants_and_prices',
+ 'saleor.checkout.utils.get_product_variants_and_prices',
lambda cart, product: (
(None, TaxedMoney(
net=Money(price, 'USD'), gross=Money(price, 'USD')))
diff --git a/tests/test_order.py b/tests/test_order.py
index 95202cd962..61c2eb7231 100644
--- a/tests/test_order.py
+++ b/tests/test_order.py
@@ -9,7 +9,7 @@ from prices import Money, TaxedMoney
from tests.utils import get_redirect_location
from saleor.account.models import User
-from saleor.cart.utils import create_order
+from saleor.checkout.utils import create_order
from saleor.core.utils.taxes import (
DEFAULT_TAX_RATE_NAME, get_tax_rate_by_name, get_taxes_for_country)
from saleor.order import FulfillmentStatus, OrderStatus, models
diff --git a/tests/test_product.py b/tests/test_product.py
index fb671ef718..1bcf370b6e 100644
--- a/tests/test_product.py
+++ b/tests/test_product.py
@@ -6,9 +6,9 @@ import pytest
from django.urls import reverse
from prices import Money, TaxedMoney, TaxedMoneyRange
-from saleor.cart import utils
-from saleor.cart.models import Cart
-from saleor.cart.utils import add_variant_to_cart
+from saleor.checkout import utils
+from saleor.checkout.models import Cart
+from saleor.checkout.utils import add_variant_to_cart
from saleor.discount.models import Sale
from saleor.product import ProductAvailabilityStatus, models
from saleor.product.thumbnails import create_product_thumbnails