Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add transaction items deletion to cleardb command (#14198)
Jakubb02c60439c5c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex bd93d8aa53..faa3268e52 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,8 @@ All notable, unreleased changes to this project will be documented in this file.### Other changes+- Add transaction items deletion to cleardb command. - #14198 by @jakubkuc+# 3.17.0### Highlightsdiff --git a/saleor/core/management/commands/cleardb.py b/saleor/core/management/commands/cleardb.pyindex 2e49e61198..d5c4d5a13c 100644--- a/saleor/core/management/commands/cleardb.py+++ b/saleor/core/management/commands/cleardb.py@@ -16,7 +16,7 @@ from ....discount.models import Sale, Voucherfrom ....giftcard.models import GiftCardfrom ....order.models import Orderfrom ....page.models import Page, PageType-from ....payment.models import Payment, Transaction+from ....payment.models import Payment, Transaction, TransactionItemfrom ....product.models import Category, Collection, Product, ProductTypefrom ....shipping.models import ShippingMethod, ShippingZonefrom ....warehouse.models import Warehouse@@ -46,6 +46,9 @@ class Command(BaseCommand):Checkout.objects.all().delete()self.stdout.write("Removed checkouts")+ TransactionItem.objects.all().delete()+ self.stdout.write("Removed transaction items")+Transaction.objects.all().delete()self.stdout.write("Removed transactions")diff --git a/saleor/core/tests/test_core.py b/saleor/core/tests/test_core.pyindex 89e94186b1..a5853b8623 100644--- a/saleor/core/tests/test_core.py+++ b/saleor/core/tests/test_core.py@@ -14,6 +14,7 @@ from ...channel.models import Channelfrom ...discount.models import Promotion, PromotionRule, Voucher, VoucherChannelListingfrom ...giftcard.models import GiftCard, GiftCardEventfrom ...order.models import Order+from ...payment.models import TransactionItemfrom ...product import ProductTypeKindfrom ...product.models import ProductTypefrom ...shipping.models import ShippingZone@@ -420,6 +421,17 @@ def test_cleardb_preserves_data(admin_user, app, site_settings, staff_user):staff_user.refresh_from_db()+@override_settings(DEBUG=True)+def test_cleardb_remove_orders_and_transactions(transaction_item):+ transaction_item.refresh_from_db()++ call_command("cleardb")+ with pytest.raises(TransactionItem.DoesNotExist):+ transaction_item.refresh_from_db()+ with pytest.raises(Order.DoesNotExist):+ transaction_item.order.refresh_from_db()++def test_prepare_unique_attribute_value_slug(color_attribute):# givenvalue_1 = color_attribute.values.first()