2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-04 20:51:00 +00:00

Adds unit testing for fancy new metadata class

This commit is contained in:
Oliver
2021-06-23 20:58:05 +10:00
parent eaa5913c8c
commit 82a6ff7772
6 changed files with 119 additions and 21 deletions

View File

@ -1,5 +1,6 @@
# Generated by Django 3.0.7 on 2020-11-10 10:11
import logging
import sys
from moneyed import CURRENCIES
@ -7,6 +8,9 @@ from django.db import migrations, connection
from company.models import SupplierPriceBreak
logger = logging.getLogger('inventree')
def migrate_currencies(apps, schema_editor):
"""
Migrate from the 'old' method of handling currencies,
@ -19,7 +23,7 @@ def migrate_currencies(apps, schema_editor):
for the SupplierPriceBreak model, to a new django-money compatible currency.
"""
print("Updating currency references for SupplierPriceBreak model...")
logger.info("Updating currency references for SupplierPriceBreak model...")
# A list of available currency codes
currency_codes = CURRENCIES.keys()
@ -39,7 +43,7 @@ def migrate_currencies(apps, schema_editor):
suffix = suffix.strip().upper()
if suffix not in currency_codes:
print("Missing suffix:", suffix)
logger.warning(f"Missing suffix: '{suffix}'")
while suffix not in currency_codes:
# Ask the user to input a valid currency
@ -72,7 +76,7 @@ def migrate_currencies(apps, schema_editor):
count += 1
if count > 0:
print(f"Updated {count} SupplierPriceBreak rows")
logger.info(f"Updated {count} SupplierPriceBreak rows")
def reverse_currencies(apps, schema_editor):
"""