From a4c6d0e6c5a2f736ee7d9511ba8dad7271471fc2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 13 Feb 2022 04:49:08 +0100 Subject: [PATCH] fix migration coverage for orders --- InvenTree/order/migrations/0052_auto_20211014_0631.py | 4 ++-- InvenTree/order/migrations/0055_auto_20211025_0645.py | 8 ++++---- InvenTree/order/migrations/0058_auto_20211126_1210.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/InvenTree/order/migrations/0052_auto_20211014_0631.py b/InvenTree/order/migrations/0052_auto_20211014_0631.py index b400437d20..64c7cd97c7 100644 --- a/InvenTree/order/migrations/0052_auto_20211014_0631.py +++ b/InvenTree/order/migrations/0052_auto_20211014_0631.py @@ -37,14 +37,14 @@ def build_refs(apps, schema_editor): if result and len(result.groups()) == 1: try: ref = int(result.groups()[0]) - except: + except: # pragma: no cover ref = 0 order.reference_int = ref order.save() -def unbuild_refs(apps, schema_editor): +def unbuild_refs(apps, schema_editor): # pragma: no cover """ Provided only for reverse migration compatibility """ diff --git a/InvenTree/order/migrations/0055_auto_20211025_0645.py b/InvenTree/order/migrations/0055_auto_20211025_0645.py index d45e92aead..d9ee366f5f 100644 --- a/InvenTree/order/migrations/0055_auto_20211025_0645.py +++ b/InvenTree/order/migrations/0055_auto_20211025_0645.py @@ -33,7 +33,7 @@ def add_shipment(apps, schema_editor): line__order=order ) - if allocations.count() == 0 and order.status != SalesOrderStatus.PENDING: + if allocations.count() == 0 and order.status != SalesOrderStatus.PENDING: # pragma: no cover continue # Create a new Shipment instance against this order @@ -41,13 +41,13 @@ def add_shipment(apps, schema_editor): order=order, ) - if order.status == SalesOrderStatus.SHIPPED: + if order.status == SalesOrderStatus.SHIPPED: # pragma: no cover shipment.shipment_date = order.shipment_date shipment.save() # Iterate through each allocation associated with this order - for allocation in allocations: + for allocation in allocations: # pragma: no cover allocation.shipment = shipment allocation.save() @@ -57,7 +57,7 @@ def add_shipment(apps, schema_editor): print(f"\nCreated SalesOrderShipment for {n} SalesOrder instances") -def reverse_add_shipment(apps, schema_editor): +def reverse_add_shipment(apps, schema_editor): # pragma: no cover """ Reverse the migration, delete and SalesOrderShipment instances """ diff --git a/InvenTree/order/migrations/0058_auto_20211126_1210.py b/InvenTree/order/migrations/0058_auto_20211126_1210.py index 2736416e66..a1836ff380 100644 --- a/InvenTree/order/migrations/0058_auto_20211126_1210.py +++ b/InvenTree/order/migrations/0058_auto_20211126_1210.py @@ -22,7 +22,7 @@ def calculate_shipped_quantity(apps, schema_editor): StockItem = apps.get_model('stock', 'stockitem') SalesOrderLineItem = apps.get_model('order', 'salesorderlineitem') - for item in SalesOrderLineItem.objects.all(): + for item in SalesOrderLineItem.objects.all(): # pragma: no cover if item.order.status == SalesOrderStatus.SHIPPED: item.shipped = item.quantity @@ -40,7 +40,7 @@ def calculate_shipped_quantity(apps, schema_editor): item.save() -def reverse_calculate_shipped_quantity(apps, schema_editor): +def reverse_calculate_shipped_quantity(apps, schema_editor): # pragma: no cover """ Provided only for reverse migration compatibility. This function does nothing.