fix migration coverage for orders

This commit is contained in:
Matthias 2022-02-13 04:49:08 +01:00
parent 10170b5466
commit a4c6d0e6c5
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
3 changed files with 8 additions and 8 deletions

View File

@ -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
"""

View File

@ -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
"""

View File

@ -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.